@@ -43,11 +43,11 @@ class SchemaComparer:
4343 MISC_SECTION : "Misc Metadata" ,
4444 HED_ID_SECTION : "Modified Hed Ids" ,
4545 EXTRAS_SECTION : "Extras" ,
46+ SOURCES : "Sources" ,
47+ PREFIXES : "Prefixes" ,
48+ ANNOTATION_PROPERTY_EXTERNAL : "AnnotationPropertyExternal" ,
4649 }
4750
48- # TODO: Check that the cases of these are correct.
49- DF_EXTRAS = {SOURCES , PREFIXES , ANNOTATION_PROPERTY_EXTERNAL }
50-
5151 def __init__ (self , schema1 , schema2 ):
5252 """Initialize the SchemaComparer with two schemas.
5353
@@ -305,8 +305,6 @@ def _add_unequal_entries(self, change_dict, unequal_entries):
305305 for section_key , changes in unequal_entries .items ():
306306 if section_key == self .MISC_SECTION :
307307 self ._add_misc_section_changes (change_dict , section_key , changes )
308- elif section_key in self .DF_EXTRAS :
309- self ._add_extras_section_changes (change_dict , section_key , changes )
310308 else :
311309 for tag , (entry1 , entry2 ) in changes .items ():
312310 if section_key == HedSectionKey .UnitClasses :
@@ -339,35 +337,6 @@ def _add_misc_section_changes(change_dict, section_key, changes):
339337 )
340338 change_dict [section_key ].append ({"change_type" : change_type , "change" : change_desc , "tag" : misc_section })
341339
342- def _add_extras_section_changes (self , change_dict , section_key , changes ):
343- """Add changes for extras sections (dataframes) to the change dictionary.
344-
345- Handles changes to dataframe-based extras like Sources, Prefixes, and AnnotationPropertyExternal.
346- Note: Extras sections are actually handled by _add_extras_changes which directly compares
347- the dataframes from schema.extras. This method handles any extras-related entries that
348- might appear in the unequal_entries from compare_schemas.
349-
350- Parameters:
351- change_dict (defaultdict): Change dictionary to append to.
352- section_key (str): The section identifier (e.g., SOURCES, PREFIXES).
353- changes (dict): Dictionary mapping entry names to (entry1, entry2) tuples.
354- """
355- # Extras sections (Sources, Prefixes, AnnotationPropertyExternal) are stored as dataframes
356- # in schema.extras rather than as schema entries, so they're handled separately
357- # by _add_extras_changes. If we somehow get extras entries here, treat them generically.
358- for name , (entry1 , entry2 ) in changes .items ():
359- # Compare the entries as generic schema entries
360- if hasattr (entry1 , "attributes" ) and hasattr (entry2 , "attributes" ):
361- if entry1 .attributes != entry2 .attributes :
362- change_dict [section_key ].append (
363- {"change_type" : "Patch" , "change" : f"{ name } attributes modified" , "tag" : name }
364- )
365- if hasattr (entry1 , "description" ) and hasattr (entry2 , "description" ):
366- if entry1 .description != entry2 .description :
367- change_dict [section_key ].append (
368- {"change_type" : "Patch" , "change" : f"{ name } description modified" , "tag" : name }
369- )
370-
371340 @staticmethod
372341 def _add_unit_classes_changes (change_dict , section_key , entry1 , entry2 ):
373342 """Add changes in unit class definitions to the change dictionary.
@@ -546,7 +515,7 @@ def _add_extras_changes(self, change_dict):
546515 Parameters:
547516 change_dict (defaultdict): Change dictionary to append to.
548517 """
549- from hed .schema .schema_io .df_constants import UNIQUE_EXTRAS_KEYS
518+ from hed .schema .schema_io .df_constants import UNIQUE_EXTRAS_KEYS , in_library as _in_library
550519
551520 extras1 = getattr (self .schema1 , "extras" , {}) or {}
552521 extras2 = getattr (self .schema2 , "extras" , {}) or {}
@@ -575,9 +544,9 @@ def _add_extras_changes(self, change_dict):
575544
576545 key_cols = UNIQUE_EXTRAS_KEYS .get (key )
577546 if not key_cols :
578- key_cols = list ( set (df1 .columns ) & set (df2 .columns ))
547+ key_cols = [ c for c in set (df1 .columns ) & set (df2 .columns ) if c != _in_library ]
579548
580- compare_cols = list ( set (df1 .columns ) & set (df2 .columns ))
549+ compare_cols = [ c for c in set (df1 .columns ) & set (df2 .columns ) if c != _in_library ]
581550 if not compare_cols :
582551 continue
583552
0 commit comments