Skip to content

Commit

Permalink
check
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Jan 13, 2024
1 parent 5fa60cd commit 988a442
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/hdmf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


# a global TermSetConfigurator
global TS_CONFIG
TS_CONFIG = TermSetConfigurator()

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

Check failure on line 12 in src/hdmf/__init__.py

View workflow job for this annotation

GitHub Actions / Check for spelling errors

configuartion ==> configuration
Expand Down
22 changes: 10 additions & 12 deletions src/hdmf/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,16 @@ def init_validation(self, fields):
from . import TS_CONFIG #update path
# Before calling super().__init__() and before setting fields, check for config file for
# validation via TermSetWrapper.
with open(TS_CONFIG.path, 'r') as config:
termset_config = yaml.safe_load(config)
object_name = self.__class__.__name__

for obj_config in termset_config:
if obj_config['data_type'] == object_name:
for attr in obj_config['fields']:
if attr in fields: # make sure any custom fields are not handled (i.e., make an extension)
termset_path = obj_config['fields'][attr]
termset = TermSet(term_schema_path=termset_path)
fields[attr] = TermSetWrapper(value=fields[attr], termset=termset)
termset_config = TS_CONFIG.load_termset_config()
object_name = self.__class__.__name__

for obj_config in termset_config:
if obj_config['data_type'] == object_name:
for attr in obj_config['fields']:
if attr in fields: # make sure any custom fields are not handled (i.e., make an extension)
termset_path = obj_config['fields'][attr]
termset = TermSet(term_schema_path=termset_path)
fields[attr] = TermSetWrapper(value=fields[attr], termset=termset)

@property
def read_io(self):
Expand Down Expand Up @@ -801,7 +800,6 @@ class Data(AbstractContainer):
"""
A class for representing dataset containers
"""

@docval({'name': 'name', 'type': str, 'doc': 'the name of this container'},
{'name': 'data', 'type': ('scalar_data', 'array_data', 'data'), 'doc': 'the source of the data'})
def __init__(self, **kwargs):
Expand Down
10 changes: 8 additions & 2 deletions src/hdmf/term_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,19 @@ def __init__(self):
# def config_path(self):
# return self.__config_path

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

Check failure on line 319 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(config_path: str):
"""
Load the configuration file for validation on the fields defined for the objects within the file.
By default, the curated configuration file is used, but can take in a custom file.
"""
self.path = config_path
if config_path not None:
self.path = config_path

with open(self.path, 'r') as config:
termset_config = yaml.safe_load(config)
return termset_config

def unload_termset_config():
"""
Expand Down

0 comments on commit 988a442

Please sign in to comment.