Skip to content

Commit

Permalink
Merge pull request hed-standard#991 from IanCa/develop
Browse files Browse the repository at this point in the history
Fix crash in unmerged schema validation.
  • Loading branch information
VisLab authored Jul 25, 2024
2 parents 763e0fb + 0a2056c commit e0d4a21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
7 changes: 5 additions & 2 deletions hed/schema/schema_attribute_validator_hed_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ def __init__(self, hed_schema):
# Add the standard schema if we have a with_standard
if "" not in prev_versions and self.hed_schema.with_standard:
prev_version = self._get_previous_version(self.hed_schema.with_standard, "")
prev_versions[""] = prev_version
self.library_data[""] = get_library_data("")
if prev_version:
prev_versions[""] = prev_version
library_data = get_library_data("")
if library_data:
self.library_data[""] = get_library_data("")

if prev_versions:
self._previous_schemas = {library: load_schema_version(full_version) for library, full_version in
Expand Down
18 changes: 10 additions & 8 deletions hed/schema/schema_io/base2schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def _load(self):
"""
self._loading_merged = True
# Do a full load of the standard schema if this is a partnered schema
if not self.appending_to_schema and self._schema.with_standard and not self._schema.merged:
# todo: this could simply cache the schema, rather than a full load, if it's not a merged schema.
if not self.appending_to_schema and self._schema.with_standard:
from hed.schema.hed_schema_io import load_schema_version
saved_attr = self._schema.header_attributes
saved_format = self._schema.source_format
Expand All @@ -117,13 +118,14 @@ def _load(self):
raise HedFileError(HedExceptions.BAD_WITH_STANDARD,
message=f"Cannot load withStandard schema '{self._schema.with_standard}'",
filename=e.filename)
# Copy the non-alterable cached schema
self._schema = copy.deepcopy(base_version)
self._schema.filename = self.filename
self._schema.name = self.name # Manually set name here as we don't want to pass it to load_schema_version
self._schema.header_attributes = saved_attr
self._schema.source_format = saved_format
self._loading_merged = False
if not self._schema.merged:
# Copy the non-alterable cached schema
self._schema = copy.deepcopy(base_version)
self._schema.filename = self.filename
self._schema.name = self.name # Manually set name here as we don't want to pass it to load_schema_version
self._schema.header_attributes = saved_attr
self._schema.source_format = saved_format
self._loading_merged = False

self._parse_data()
self._schema.finalize_dictionaries()
Expand Down

0 comments on commit e0d4a21

Please sign in to comment.