Skip to content

Commit 2ee0384

Browse files
committed
fix: updates schema version check to handle new core schemas
1 parent d9bb93b commit 2ee0384

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

src/aind_data_schema/core/session.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,9 @@ class ManipulatorModule(DomeModule):
218218
title="Manipulator coordinates",
219219
)
220220
anatomical_coordinates: Optional[Coordinates3d] = Field(default=None, title="Anatomical coordinates")
221-
anatomical_reference: Optional[Literal[CoordinateReferenceLocation.BREGMA,
222-
CoordinateReferenceLocation.LAMBDA]] = Field(
223-
default=None, title="Anatomical coordinate reference"
224-
)
221+
anatomical_reference: Optional[Literal[CoordinateReferenceLocation.BREGMA, CoordinateReferenceLocation.LAMBDA]] = (
222+
Field(default=None, title="Anatomical coordinate reference")
223+
)
225224
surface_z: Optional[Decimal] = Field(default=None, title="Surface z")
226225
surface_z_unit: SizeUnit = Field(SizeUnit.UM, title="Surface z unit")
227226
dye: Optional[str] = Field(default=None, title="Dye")

src/aind_data_schema/utils/schema_version_bump.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ def _get_list_of_models_that_changed(self) -> List[AindCoreModel]:
5050
if default_filename.find(".") != -1:
5151
schema_filename = default_filename[: default_filename.find(".")] + "_schema.json"
5252
main_branch_schema_path = self.json_schemas_location / schema_filename
53-
with open(main_branch_schema_path, "r") as f:
54-
main_branch_schema_contents = json.load(f)
55-
diff = dictdiffer.diff(main_branch_schema_contents, core_model_json)
56-
if len(list(diff)) > 0:
57-
schemas_that_need_updating.append(core_model)
53+
if main_branch_schema_path.exists():
54+
with open(main_branch_schema_path, "r") as f:
55+
main_branch_schema_contents = json.load(f)
56+
diff = dictdiffer.diff(main_branch_schema_contents, core_model_json)
57+
if len(list(diff)) > 0:
58+
schemas_that_need_updating.append(core_model)
5859
return schemas_that_need_updating
5960

6061
@staticmethod

tests/test_bump_schema_versions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ def setUpClass(cls):
2828

2929
@patch("builtins.open")
3030
@patch("json.load")
31-
def test_get_list_of_models_that_changed(self, mock_json_load: MagicMock, _: MagicMock):
31+
@patch("pathlib.Path.exists")
32+
def test_get_list_of_models_that_changed(self, mock_exists: MagicMock, mock_json_load: MagicMock, _: MagicMock):
3233
"""Tests get_list_of_models_that_changed method."""
3334
mock_json_load.side_effect = self.mock_open_values
35+
mock_exists.return_value = True
3436

3537
handler = SchemaVersionHandler(json_schemas_location=Path("."))
3638
models_that_changed = handler._get_list_of_models_that_changed()

tests/test_rig_session_compatibility.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests rig session compatibility check"""
2+
23
import json
34
import unittest
45
from datetime import date, datetime, timezone

0 commit comments

Comments
 (0)