Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.22.2 #227

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ all = [
]

schema = [
"aind-data-schema>=1.2.0,<2.0",
"aind-data-schema>=1.2.0,<1.3.0",
]

bergamo = [
Expand Down
2 changes: 1 addition & 1 deletion src/aind_metadata_mapper/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Init package"""

__version__ = "0.22.1"
__version__ = "0.22.2"
21 changes: 13 additions & 8 deletions src/aind_metadata_mapper/gather_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,28 @@ def get_funding_info(domain: str, url_path: str, project_name: str):
else:
funding_info = []
investigators = set()
parsed_funding_info = []
for f in funding_info:
project_fundees = (
project_investigators = (
""
if f.get("fundee", None) is None
else f.get("fundee", "").split(",")
if f.get("investigators", None) is None
else f.get("investigators", "").split(",")
)
pid_names = [
investigators_pid_names = [
PIDName(name=p.strip()).model_dump_json()
for p in project_fundees
for p in project_investigators
]
if project_fundees is not [""]:
investigators.update(pid_names)
if project_investigators is not [""]:
investigators.update(investigators_pid_names)
funding_info_without_investigators = {
k: v for k, v in f.items() if k != "investigators"
}
parsed_funding_info.append(funding_info_without_investigators)
investigators = [
PIDName.model_validate_json(i) for i in investigators
]
investigators.sort(key=lambda x: x.name)
return funding_info, investigators
return parsed_funding_info, investigators

# Returns a dict with platform, subject_id, and acq_datetime
file_name = RawDataDescription.default_filename()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"registry_identifier": "03cpe7c52"
},
"grant_number": null,
"fundee": "Anna Apple, John Smith"
"fundee": "Anna Apple, John Smith",
"investigators": "Anna Apple"
},
{
"funder": {
Expand All @@ -25,7 +26,8 @@
"registry_identifier": "01s5ya894"
},
"grant_number": "1U01NS133760",
"fundee": "Anna Apple, John Smith, Don Key"
"fundee": "Anna Apple, John Smith, Don Key",
"investigators": null
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"registry_identifier": "03cpe7c52"
},
"grant_number": null,
"fundee": "Anna Apple, John Smith"
"fundee": "Anna Apple, John Smith",
"investigators": "Anna Apple"
}
}
8 changes: 5 additions & 3 deletions tests/test_gather_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def test_get_raw_data_description(self, mock_get: MagicMock):
)
metadata_job = GatherMetadataJob(settings=job_settings)
contents = metadata_job.get_raw_data_description()
expected_investigators = ["Anna Apple", "John Smith"]
expected_investigators = ["Anna Apple"]
actual_investigators = [i["name"] for i in contents["investigators"]]
self.assertEqual(expected_investigators, actual_investigators)
self.assertEqual("ecephys", contents["platform"]["abbreviation"])
Expand Down Expand Up @@ -360,7 +360,7 @@ def test_get_raw_data_description_multi_response(
)
metadata_job = GatherMetadataJob(settings=job_settings)
contents = metadata_job.get_raw_data_description()
expected_investigators = ["Anna Apple", "Don Key", "John Smith"]
expected_investigators = ["Anna Apple"]
actual_investigators = [i["name"] for i in contents["investigators"]]
self.assertEqual(2, len(contents["funding_source"]))
self.assertEqual(expected_investigators, actual_investigators)
Expand Down Expand Up @@ -782,7 +782,8 @@ def test_gather_non_automated_metadata_with_ser_issues(
metadata_job._gather_non_automated_metadata()
mock_write_file.assert_called()

def test_get_main_metadata_with_warnings(self):
@patch("logging.warning")
def test_get_main_metadata_with_warnings(self, mock_warn: MagicMock):
"""Tests get_main_metadata method raises validation warnings"""
job_settings = JobSettings(
directory_to_write_to=RESOURCES_DIR,
Expand Down Expand Up @@ -812,6 +813,7 @@ def test_get_main_metadata_with_warnings(self):
)
self.assertEqual("Missing", main_metadata["metadata_status"])
self.assertEqual("632269", main_metadata["subject"]["subject_id"])
mock_warn.assert_called_once()

@patch("logging.warning")
def test_get_main_metadata_with_ser_issues(self, mock_log: MagicMock):
Expand Down
Loading