Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Jan 25, 2024
1 parent 0908d65 commit 37939f3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 32 deletions.
25 changes: 9 additions & 16 deletions src/pynwb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,23 @@
from hdmf.backends.hdf5 import HDF5IO as _HDF5IO
from hdmf.build import BuildManager, TypeMap
import hdmf.common
from hdmf.term_set import TermSetConfigurator

CORE_NAMESPACE = 'core'

from .spec import NWBDatasetSpec, NWBGroupSpec, NWBNamespace # noqa E402
from .validate import validate # noqa: F401, E402


CUR_DIR = os.path.dirname(os.path.realpath(__file__))
path_to_config = os.path.join(CUR_DIR, 'config/NWB_CONFIG.yaml')
NWB_CONFIG = TermSetConfigurator(path=path_to_config)

@docval({'name': 'config_path', 'type': str, 'doc': 'Path to the configuartion file.',

Check failure on line 22 in src/pynwb/__init__.py

View workflow job for this annotation

GitHub Actions / Check for spelling errors

configuartion ==> configuration
'default': None})
def load_termset_config(config_path: str):
"""
If a user does not provide a config_path, then this method will unload any present configuration
and load the default curated configuration.
If a user provides a config_path, then this method will:
- Search the current configuation for data_types that are already present. These data_types will be
This method will:
- Search the current configuration for data_types that are already present. These data_types will be
replaced with the new configuration.
- If the data_type is not present, then they will be loaded alongside the default curated configuration.
"""
if config_path is None:
NWB_CONFIG.unload_termset_config()
NWB_CONFIG.load_termset_config()
else:
NWB_CONFIG.load_termset_config(config_path)
__TYPE_MAP.ts_config.load_termset_config(config_path)

def unload_termset_config():
"""
Expand Down Expand Up @@ -74,10 +62,13 @@ def _get_resources():
global __NS_CATALOG
global __TYPE_MAP

CUR_DIR = os.path.dirname(os.path.realpath(__file__))
path_to_config = os.path.join(CUR_DIR, 'config/nwb_config.yaml')

__NS_CATALOG = NamespaceCatalog(NWBGroupSpec, NWBDatasetSpec, NWBNamespace)

hdmf_typemap = hdmf.common.get_type_map()
__TYPE_MAP = TypeMap(__NS_CATALOG)
__TYPE_MAP = TypeMap(__NS_CATALOG, config_path=path_to_config)
__TYPE_MAP.merge(hdmf_typemap, ns_catalog=True)


Expand Down Expand Up @@ -170,6 +161,8 @@ def register_class(**kwargs):

def _dec(cls):
__TYPE_MAP.register_container_type(namespace, neurodata_type, cls)
cls.type_map = __TYPE_MAP
cls.namespace = namespace
return cls
if container_cls is None:
return _dec
Expand Down
13 changes: 7 additions & 6 deletions src/pynwb/config/nwb_config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Subject:
namespace:
namespace_version:
fields:
species: src/pynwb/config/nwb_subject_termset.yaml
# field2: ...
namespaces:
core:
version: TBD
data_types:
Subject:
species: src/pynwb/config/nwb_subject_termset.yaml
field2: '...'
9 changes: 0 additions & 9 deletions src/pynwb/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ def _error_on_new_warn_on_construct(self, error_msg: str):
raise ValueError(error_msg)
warn(error_msg)

def get_config(self):
from . import NWB_CONFIG #update path
return NWB_CONFIG

def get_type_map(self):
from . import get_type_map
tm = get_type_map()
return tm


@register_class('NWBContainer', CORE_NAMESPACE)
class NWBContainer(NWBMixin, Container):
Expand Down
2 changes: 1 addition & 1 deletion src/pynwb/nwb-schema

0 comments on commit 37939f3

Please sign in to comment.