Skip to content

Commit

Permalink
feat: upgrades aind-data-schema (#217)
Browse files Browse the repository at this point in the history
* feat: upgrades aind-data-schema

* feat: adds pydantic settings

* feat: updates aind-metadata-mapper
  • Loading branch information
jtyoung84 authored Apr 8, 2024
1 parent f8232c6 commit d84c2f3
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 55 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ readme = "README.md"
dynamic = ["version"]

dependencies = [
'aind-metadata-mapper==0.5.0'
'aind-metadata-mapper==0.6.1',
'pydantic-settings>=2.0'
]

[project.optional-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions src/aind_metadata_service/sharepoint/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ def _merge_two_responses(
)
else:
left_procedures: List[Procedures] = left_model_response.aind_models
right_procedures: List[
Procedures
] = right_model_response.aind_models
right_procedures: List[Procedures] = (
right_model_response.aind_models
)
procedures = self._merge_procedures(
left_procedures=left_procedures,
right_procedures=right_procedures,
Expand Down
6 changes: 0 additions & 6 deletions src/aind_metadata_service/sharepoint/nsb2019/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -1423,13 +1423,7 @@ def get_craniotomy_procedure(self) -> Craniotomy:
return Craniotomy.model_construct(
craniotomy_type=self.aind_craniotomy_type,
craniotomy_hemisphere=self.aind_hp_loc,
craniotomy_coordinates_ml=self.aind_hp_m_l,
craniotomy_coordinates_ap=self.aind_hp_a_p,
craniotomy_coordinates_reference=(
self.aind_craniotomy_coordinates_reference
),
bregma_to_lambda_distance=self.aind_breg2_lamb,
craniotomy_size=self.aind_craniotomy_size,
dura_removed=self.aind_hp_durotomy,
)

Expand Down
8 changes: 4 additions & 4 deletions src/aind_metadata_service/smartsheet/protocols/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ def _get_protocol_list(
"""
rows_associated_with_protocol_name: List[ProtocolInformation] = []
for row in self.model.rows:
opt_protocol: Optional[
ProtocolInformation
] = self._map_row_to_protocol(
row=row, input_protocol_name=protocol_name
opt_protocol: Optional[ProtocolInformation] = (
self._map_row_to_protocol(
row=row, input_protocol_name=protocol_name
)
)
if opt_protocol is not None:
rows_associated_with_protocol_name.append(opt_protocol)
Expand Down
6 changes: 3 additions & 3 deletions src/aind_metadata_service/tars/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ def integrate_injection_materials(
new_material.titer = (
injection_material.titer
)
procedure.injection_materials[
idx
] = new_material
procedure.injection_materials[idx] = (
new_material
)
elif (
tars_response.status_code
== StatusCodes.NO_DATA_FOUND.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@
{
"craniotomy_type": "Whole hemisphere craniotomy",
"craniotomy_hemisphere": null,
"craniotomy_coordinates_ml": "2.8",
"craniotomy_coordinates_ap": "1.3",
"craniotomy_coordinates_reference": null,
"bregma_to_lambda_distance": null,
"craniotomy_size": null,
"dura_removed": false,
"procedure_type": "Craniotomy",
"craniotomy_coordinates_unit": "millimeter",
"bregma_to_lambda_unit": "millimeter",
"craniotomy_size_unit": "millimeter",
"implant_part_number": null,
"protective_material": null,
"recovery_time": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@
{
"craniotomy_type": "Other",
"craniotomy_hemisphere": null,
"craniotomy_coordinates_ml": "2.8",
"craniotomy_coordinates_ap": "1.3",
"craniotomy_coordinates_reference": null,
"bregma_to_lambda_distance": null,
"craniotomy_size": null,
"dura_removed": null,
"procedure_type": "Craniotomy",
"craniotomy_coordinates_unit": "millimeter",
"bregma_to_lambda_unit": "millimeter",
"craniotomy_size_unit": "millimeter",
"implant_part_number": null,
"protective_material": null,
"recovery_time": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@
{
"craniotomy_type": "Other",
"craniotomy_hemisphere": null,
"craniotomy_coordinates_ml": "2.8",
"craniotomy_coordinates_ap": "1.3",
"craniotomy_coordinates_reference": null,
"bregma_to_lambda_distance": null,
"craniotomy_size": null,
"dura_removed": false,
"procedure_type": "Craniotomy",
"craniotomy_coordinates_unit": "millimeter",
"bregma_to_lambda_unit": "millimeter",
"craniotomy_size_unit": "millimeter",
"implant_part_number": null,
"protective_material": null,
"recovery_time": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,11 @@
"procedures": [
{
"craniotomy_type": "3 mm",
"craniotomy_coordinates_reference": null,
"bregma_to_lambda_distance": null,
"craniotomy_size": "3",
"recovery_time": "25.0",
"procedure_type": "Craniotomy",
"craniotomy_hemisphere": null,
"craniotomy_coordinates_ml": null,
"craniotomy_coordinates_ap": null,
"craniotomy_coordinates_unit": "millimeter",
"bregma_to_lambda_unit": "millimeter",
"craniotomy_size_unit": "millimeter",
"implant_part_number": "3mm stacked coverslip",
"dura_removed": null,
"protective_material": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@
"procedures": [
{
"craniotomy_type": "5 mm",
"craniotomy_coordinates_reference": "Lambda",
"bregma_to_lambda_distance": null,
"craniotomy_size": "5",
"recovery_time": null,
"procedure_type": "Craniotomy",
"craniotomy_hemisphere": null,
"craniotomy_coordinates_ml": null,
"craniotomy_coordinates_ap": null,
"craniotomy_coordinates_unit": "millimeter",
"bregma_to_lambda_unit": "millimeter",
"craniotomy_size_unit": "millimeter",
"implant_part_number": "2006",
"dura_removed": null,
"protective_material": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,11 @@
"procedures": [
{
"craniotomy_type": "5 mm",
"craniotomy_coordinates_reference": "Lambda",
"bregma_to_lambda_distance": null,
"craniotomy_size": "5",
"recovery_time": "30.0",
"procedure_type": "Craniotomy",
"craniotomy_hemisphere": null,
"craniotomy_coordinates_ml": null,
"craniotomy_coordinates_ap": null,
"craniotomy_coordinates_unit": "millimeter",
"bregma_to_lambda_unit": "millimeter",
"craniotomy_size_unit": "millimeter",
"implant_part_number": "5mm stacked coverslip",
"dura_removed": null,
"protective_material": null,
Expand Down
6 changes: 5 additions & 1 deletion tests/slims/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,10 @@ def test_get_model_response_internal_server_error(
@patch(
"aind_metadata_service.slims.client.SlimsClient.get_record_response"
)
def test_get_model_response_exception(self, mock_get_record_response):
@patch("logging.error")
def test_get_model_response_exception(
self, mock_log_error: MagicMock, mock_get_record_response: MagicMock
):
"""Test case: Exception during execution"""
mock_get_record_response.side_effect = Exception("Some error")
self.assertEqual(
Expand All @@ -356,6 +359,7 @@ def test_get_model_response_exception(self, mock_get_record_response):
self.client.get_rig_model_response("12345").status_code,
StatusCodes.INTERNAL_SERVER_ERROR,
)
mock_log_error.assert_called()

@patch("aind_metadata_service.slims.client.requests.get")
def test_get_response_with_oauth(self, mock_requests_get):
Expand Down
3 changes: 2 additions & 1 deletion tests/smartsheet/test_perfusions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ def setUpClass(cls):
contents = json.load(f)
cls.example_sheet_contents = contents
cls.example_sheet = json.dumps(contents)
# TODO: Add protocol id
cls.expected_model = [
Surgery(
Surgery.model_construct(
start_date=date(2023, 10, 2),
experimenter_full_name="Jane Smith",
iacuc_protocol="2109",
Expand Down

0 comments on commit d84c2f3

Please sign in to comment.