Skip to content

Commit

Permalink
Merge pull request #298 from AllenNeuralDynamics/build-merge-main
Browse files Browse the repository at this point in the history
Merges main
  • Loading branch information
jtyoung84 authored Nov 16, 2024
2 parents 007c852 + 9eb496c commit 1c6492d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/aind_metadata_service/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""REST service to retrieve metadata from databases."""

__version__ = "0.15.0"
__version__ = "0.15.1"
14 changes: 10 additions & 4 deletions src/aind_metadata_service/smartsheet/funding/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,26 @@ class FundingMapper(SmartSheetMapper):
"""Primary class to handle mapping data models and returning a response"""

@staticmethod
def _parse_institution(input_name: str) -> Union[Organization, str]:
def _parse_institution(
input_name: Optional[str],
) -> Optional[Union[Organization, str]]:
"""
Generate Institution from string
Parameters
----------
input_name : str
input_name : Optional[str]
Institution name
Returns
-------
Union[Institution, str]
Optional[Union[Institution, str]]
Either an Institution parsed from the name. If the Institution can't
be generated from the name, then it returns the input name.
"""
if Organization().name_map.get(input_name) is not None:
if input_name is None:
return None
elif Organization().name_map.get(input_name) is not None:
return Organization().name_map.get(input_name)
elif Organization().abbreviation_map.get(input_name) is not None:
return Organization().abbreviation_map.get(input_name)
Expand Down Expand Up @@ -73,6 +77,8 @@ def _map_row_to_funding(
investigators = row_dict.get(FundingColumnNames.INVESTIGATORS)
if input_project_name != project_name:
return None
elif funder is None and grant_number is None and investigators is None:
return None
else:
try:
return Funding(
Expand Down
32 changes: 29 additions & 3 deletions tests/resources/smartsheet/test_funding_sheet.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,32 @@
"modifiedAt": "2023-12-20T18:32:10+00:00Z",
"rowNumber": 1
},
{
"cells": [
{
"columnId": 3981351074090884,
"displayValue": "AIND Scientific Activities",
"value": "AIND Scientific Activities"
},
{
"columnId": 1729551260405636
},
{
"columnId": 2990791841501060
},
{
"columnId": 3446515788894084
},
{
"columnId": 4825776004222852
}
],
"createdAt": "2023-07-31T20:57:28+00:00Z",
"expanded": true,
"id": 2014892103339909,
"modifiedAt": "2023-12-20T18:32:10+00:00Z",
"rowNumber": 2
},
{
"cells": [
{
Expand Down Expand Up @@ -141,7 +167,7 @@
"expanded": true,
"id": 3850275791343492,
"modifiedAt": "2023-12-20T18:32:10+00:00Z",
"rowNumber": 2,
"rowNumber": 3,
"siblingId": 2014892103339908
},
{
Expand Down Expand Up @@ -174,11 +200,11 @@
"expanded": true,
"id": 8831127549939588,
"modifiedAt": "2023-12-20T18:33:23+00:00Z",
"rowNumber": 3,
"rowNumber": 4,
"siblingId": 4327527922569092
}
],
"totalRowCount": 3,
"totalRowCount": 4,
"userPermissions": {
"summaryPermissions": "READ_WRITE"
},
Expand Down

0 comments on commit 1c6492d

Please sign in to comment.