Skip to content

Commit

Permalink
fix: partial fix for modalities with underscores
Browse files Browse the repository at this point in the history
  • Loading branch information
dbirman committed Oct 7, 2024
1 parent 97f1696 commit 5f8484a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/aind_data_schema/core/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ def validate_expected_files_by_modality(self):
for modality in modalities:
for file in CORE_FILES:
# For each field, check if this is a required/excluded file
file_requirement = getattr(getattr(ExpectedFiles, str(modality.abbreviation).upper()), file)
abbreviation = modality["abbreviation"].replace("-", "_").upper()
file_requirement = getattr(getattr(ExpectedFiles, abbreviation), file)

if file not in requirement_dict:
requirement_dict[file] = file_requirement
Expand Down
28 changes: 28 additions & 0 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,34 @@ def test_validate_ecephys_metadata(self):
)
self.assertIn("Injection is missing injection_materials.", str(context.exception))



def test_validate_underscore_modality(self):
"""Tests that ecephys validator works as expected"""
viral_material = ViralMaterial.model_construct()
nano_inj = NanojectInjection.model_construct()
ionto_inj = IontophoresisInjection.model_construct(injection_materials=[viral_material])

# Tests missing metadata
surgery1 = Surgery.model_construct(procedures=[nano_inj, ionto_inj])
with self.assertRaises(ValueError) as context:
Metadata(
name="ecephys_655019_2023-04-03_18-17-09",
location="bucket",
data_description=DataDescription.model_construct(
label="some label",
platform=Platform.ECEPHYS,
creation_time=time(12, 12, 12),
modality=[Modality.BEHAVIOR_VIDEOS],
),
procedures=Procedures.model_construct(subject_procedures=[surgery1]),
rig=Rig.model_construct(),
)
self.assertIn(
"ecephys metadata missing required file: subject",
str(context.exception),
)

def test_validate_rig_session_compatibility(self):
"""Tests that rig/session compatibility validator works as expected"""
mouse_platform = MousePlatform.model_construct(name="platform1")
Expand Down

0 comments on commit 5f8484a

Please sign in to comment.