Skip to content

Commit

Permalink
support multiple config files
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Jan 18, 2024
1 parent 0b83e58 commit fa9e0f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 28 deletions.
11 changes: 3 additions & 8 deletions src/hdmf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
def get_termset_config():
return TS_CONFIG.config

def get_config_types():
return TS_CONFIG.get_data_types()

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

Check failure on line 15 in src/hdmf/__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):
Expand All @@ -28,12 +25,10 @@ def load_termset_config(config_path: str):
- If the data_type is not present, then they will be loaded alongside the default curated configuration.
"""
if config_path is None:
TS_CONFIG.path = "/Users/mavaylon/Research/NWB/hdmf2/hdmf/docs/gallery/example_config.yaml"
TS_CONFIG.unload_termset_config()
TS_CONFIG.load_termset_config()




else:
TS_CONFIG.load_termset_config(config_path)

def unload_termset_config():
"""
Expand Down
32 changes: 12 additions & 20 deletions src/hdmf/term_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,6 @@ def __init__(self):
self.config = None
self.load_termset_config()

def get_data_types(self):
"""
Return list of data_types within current configuration file.
"""
data_types = []
for data_type_dict in self.config:
data_types.append(data_type_dict['data_type'])

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

Check failure on line 318 in src/hdmf/term_set.py

View workflow job for this annotation

GitHub Actions / Check for spelling errors

configuartion ==> configuration
'default': None})
def load_termset_config(self,config_path):
Expand All @@ -334,18 +326,18 @@ def load_termset_config(self,config_path):
with open(self.path[0], 'r') as config:
termset_config = yaml.safe_load(config)
self.config = termset_config

# # Check data_types within new config to see if they already exist in the current config
# with open(config_path, 'r') as config:
# termset_config = yaml.safe_load(config)
# for data_type_dict in termset_config:
# if data_type_dict['data_type'] in self.get_data_types():
# pass
#
#
# # append path to new config to self.path
# if config_path is not None:
# self.path.append(config_path)
else:
# Check data_types within new config to see if they already exist in the current config
with open(config_path, 'r') as config:
termset_config = yaml.safe_load(config)
for data_type in termset_config:
if data_type in self.config:
self.config[data_type] = termset_config[data_type]
termset_config.pop(data_type)
self.config.update(termset_config)

# append path to new config to self.path
self.path.append(config_path)


def unload_termset_config():
Expand Down

0 comments on commit fa9e0f0

Please sign in to comment.