Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions hed/schema/hed_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ def save_as_dataframes(self, base_filename, save_merged=False):
- File cannot be saved for some reason.
"""
output_dfs = Schema2DF().process_schema(self, save_merged)
if hasattr(self, 'extras') and self.extras:
output_dfs.update(self.extras)
df_util.save_dataframes(base_filename, output_dfs)

def set_schema_prefix(self, schema_namespace):
Expand Down
6 changes: 3 additions & 3 deletions hed/schema/hed_schema_df_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
PROPERTY_KEYS = [ANNOTATION_KEY, DATA_KEY, OBJECT_KEY]
DF_SUFFIXES = {TAG_KEY, STRUCT_KEY, VALUE_CLASS_KEY,
UNIT_CLASS_KEY, UNIT_KEY, UNIT_MODIFIER_KEY,
*PROPERTY_KEYS, ATTRIBUTE_PROPERTY_KEY}
*PROPERTY_KEYS, ATTRIBUTE_PROPERTY_KEY, PREFIXES_KEY, EXTERNAL_ANNOTATION_KEY}


DF_EXTRA_SUFFIXES = {PREFIXES_KEY, EXTERNAL_ANNOTATION_KEY}
DF_SUFFIXES_OMN = {*DF_SUFFIXES, *DF_EXTRA_SUFFIXES}

#DF_SUFFIXES_OMN = {*DF_SUFFIXES, *DF_EXTRA_SUFFIXES}
DF_SUFFIXES_OMN = DF_SUFFIXES

section_mapping_hed_id = {
STRUCT_KEY: None,
Expand Down
2 changes: 2 additions & 0 deletions hed/schema/schema_io/df2schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def _parse_data(self):
f"{len(self.fatal_errors)} issues found when parsing schema. See the .issues "
f"parameter on this exception for more details.", self.name,
issues=self.fatal_errors)
extras = {key: self.input_data[key] for key in constants.DF_EXTRA_SUFFIXES if key in self.input_data}
self._schema.extras = extras

def _get_prologue_epilogue(self, file_data):
prologue, epilogue = "", ""
Expand Down
9 changes: 6 additions & 3 deletions tests/schema/test_hed_schema_io_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ def test_from_dataframes(self):
filenames = convert_filenames_to_dict(filename)
new_file_strings = {}
for key, value in filenames.items():
with open(value, "r") as f:
all_lines = f.readlines()
new_file_strings[key] = "".join(all_lines)
try:
with open(value, "r") as f:
all_lines = f.readlines()
new_file_strings[key] = "".join(all_lines)
except FileNotFoundError as e:
pass

reloaded_schema = from_dataframes(new_file_strings)
self.assertEqual(schema, reloaded_schema)
Expand Down