From d0510919d729b4244833f2f367e091e675f0db2e Mon Sep 17 00:00:00 2001 From: mavaylon1 Date: Mon, 15 Jul 2024 10:01:37 -0700 Subject: [PATCH 1/4] termset schema --- src/hdmf/container.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/hdmf/container.py b/src/hdmf/container.py index 287809406..7d8d00436 100644 --- a/src/hdmf/container.py +++ b/src/hdmf/container.py @@ -112,6 +112,13 @@ def _field_config(self, arg_name, val, type_map): itself is only one file. When a user loads custom configs, the config is appended/modified. The modifications are not written to file, avoiding permanent modifications. """ + # check for TermSet defined within schema + spec = type_map.get_map(self).spec + if 'termset' in spec: + termset_path = os.path.join(CUR_DIR, spec['termset']) + + # Check for Loaded configuration + # Note: A loaded configuation should override TermSet defined in the schema configurator = type_map.type_config if len(configurator.path)>0: @@ -162,9 +169,10 @@ def _field_config(self, arg_name, val, type_map): return val termset_path = os.path.join(CUR_DIR, config_termset_path['termset']) - termset = TermSet(term_schema_path=termset_path) - val = TermSetWrapper(value=val, termset=termset) - return val + + termset = TermSet(term_schema_path=termset_path) + val = TermSetWrapper(value=val, termset=termset) + return val @classmethod def _getter(cls, field): From 43b3619cfd40f488e95b6ceab03ddd63b9d735ca Mon Sep 17 00:00:00 2001 From: mavaylon1 Date: Mon, 15 Jul 2024 10:04:41 -0700 Subject: [PATCH 2/4] path --- src/hdmf/container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hdmf/container.py b/src/hdmf/container.py index 7d8d00436..aa1a6e863 100644 --- a/src/hdmf/container.py +++ b/src/hdmf/container.py @@ -115,7 +115,7 @@ def _field_config(self, arg_name, val, type_map): # check for TermSet defined within schema spec = type_map.get_map(self).spec if 'termset' in spec: - termset_path = os.path.join(CUR_DIR, spec['termset']) + termset_path = spec['termset'] # Check for Loaded configuration # Note: A loaded configuation should override TermSet defined in the schema From e6294bc0e2801d9a3b36c2ec6630d630b3f55c6c Mon Sep 17 00:00:00 2001 From: mavaylon1 Date: Mon, 15 Jul 2024 10:06:49 -0700 Subject: [PATCH 3/4] path --- src/hdmf/container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hdmf/container.py b/src/hdmf/container.py index aa1a6e863..3f0c7dc32 100644 --- a/src/hdmf/container.py +++ b/src/hdmf/container.py @@ -118,7 +118,7 @@ def _field_config(self, arg_name, val, type_map): termset_path = spec['termset'] # Check for Loaded configuration - # Note: A loaded configuation should override TermSet defined in the schema + # Note: A loaded configuration should override TermSet defined in the schema configurator = type_map.type_config if len(configurator.path)>0: From 9547f07de66ed7b12b95f4ca14527b307a42783b Mon Sep 17 00:00:00 2001 From: mavaylon1 Date: Mon, 15 Jul 2024 10:16:36 -0700 Subject: [PATCH 4/4] fix --- src/hdmf/container.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hdmf/container.py b/src/hdmf/container.py index 3f0c7dc32..86c30589b 100644 --- a/src/hdmf/container.py +++ b/src/hdmf/container.py @@ -113,8 +113,14 @@ def _field_config(self, arg_name, val, type_map): The modifications are not written to file, avoiding permanent modifications. """ # check for TermSet defined within schema - spec = type_map.get_map(self).spec - if 'termset' in spec: + try: + spec = type_map.get_map(self).spec + check_spec = True + except ValueError: + # Class may not be mapped to a data type (test suite) + check_spec = False + + if check_spec and 'termset' in spec: termset_path = spec['termset'] # Check for Loaded configuration