-
Notifications
You must be signed in to change notification settings - Fork 10
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
TCIA Adapter #121
Merged
Merged
TCIA Adapter #121
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
df37728
feat: initial TCIAAdapter
m0nhawk 0e1615f
feat: updates for fields
m0nhawk 4e6f5a9
test: add tests for TCIA Adapter
m0nhawk 2e64eab
test: remove test (TCIA doesn't support filters? or does it?)
m0nhawk 3d1f466
test: fixes
m0nhawk 77aa3ef
test: debugging
m0nhawk 45b7a7f
test: debug
m0nhawk 61f7345
test: debug
m0nhawk 1f92f66
test: not needed
m0nhawk bfb6d9c
test: update
m0nhawk 075f6b3
test: fix
m0nhawk 8fb5cb8
test: fix
m0nhawk e73962d
test: add test for series endpoint
m0nhawk db6c261
test: fix
m0nhawk 07a80b6
test: fix
m0nhawk 5f196bc
fix: pin poetry to pre-2.0
m0nhawk bd914fa
Update AZLINUX_BASE_VERSION argument in Dockerfile
m0nhawk 3347918
Update AZLINUX_BASE_VERSION to master
m0nhawk dea672c
test: fix
m0nhawk fec2b65
test: reduce fail coverage to 93 for debugging
m0nhawk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
import respx | ||
import httpx | ||
|
||
from mds.agg_mds.adapters import get_metadata | ||
|
||
|
||
@respx.mock | ||
def test_get_metadata_tcia(): | ||
tcia_response_study = """ | ||
[ | ||
{ | ||
"StudyInstanceUID": "study_id_1", | ||
"StudyDate": "", | ||
"StudyDescription": "Collection One.", | ||
"PatientAge": "", | ||
"PatientID": "", | ||
"PatientName": "", | ||
"PatientSex": "", | ||
"EthnicGroup": "", | ||
"Collection": "Collection1", | ||
"SeriesCount": 1, | ||
"LongitudinalTemporalEventType": "", | ||
"LongitudinalTemporalOffsetFromEvent": 0 | ||
}, | ||
{ | ||
"StudyInstanceUID": "study_id_2", | ||
"StudyDate": "", | ||
"StudyDescription": "Collection Two.", | ||
"PatientAge": "", | ||
"PatientID": "", | ||
"PatientName": "", | ||
"PatientSex": "", | ||
"EthnicGroup": "", | ||
"Collection": "Collection2", | ||
"SeriesCount": 2, | ||
"LongitudinalTemporalEventType": "", | ||
"LongitudinalTemporalOffsetFromEvent": 1 | ||
} | ||
] | ||
""" | ||
|
||
field_mappings_study = { | ||
"_unique_id": "path:StudyInstanceUID", | ||
"commons": "TCIA", | ||
"study_title": "path:StudyDescription", | ||
"program_name": "path:Collection", | ||
"description": "", | ||
"tags": [], | ||
} | ||
|
||
tcia_response_series = """ | ||
[ | ||
{ | ||
"SeriesInstanceUID": "series_id_1", | ||
"StudyInstanceUID": "study_id_1", | ||
"Modality": "A", | ||
"ProtocolName": "", | ||
"SeriesDate": "1970-01-01 00:00:00.0", | ||
"SeriesDescription": "", | ||
"SeriesNumber": 1, | ||
"Collection": "Collection1", | ||
"PatientID": "", | ||
"Manufacturer": "", | ||
"ManufacturerModelName": "", | ||
"ImageCount": 10, | ||
"TimeStamp": "1970-01-01 00:00:00.0", | ||
"LicenseName": "", | ||
"LicenseURI": "", | ||
"CollectionURI": "", | ||
"FileSize": 100, | ||
"DateReleased": "1970-01-01 00:00:00.0", | ||
"StudyDesc": "", | ||
"StudyDate": "1970-01-01 00:00:00.0", | ||
"ThirdPartyAnalysis": "" | ||
}, | ||
{ | ||
"SeriesInstanceUID": "series_id_2", | ||
"StudyInstanceUID": "study_id_2", | ||
"Modality": "B", | ||
"ProtocolName": "", | ||
"SeriesDate": "1970-01-01 10:00:00.0", | ||
"SeriesDescription": "", | ||
"BodyPartExamined": "", | ||
"SeriesNumber": 2, | ||
"Collection": "Collection2", | ||
"PatientID": "", | ||
"Manufacturer": "", | ||
"ManufacturerModelName": "", | ||
"SoftwareVersions": "", | ||
"ImageCount": 20, | ||
"TimeStamp": "1970-01-01 10:00:00.0", | ||
"LicenseName": "", | ||
"LicenseURI": "", | ||
"CollectionURI": "", | ||
"FileSize": 200, | ||
"DateReleased": "1970-01-01 10:00:00.0", | ||
"StudyDesc": "", | ||
"StudyDate": "1970-01-01 10:00:00.0", | ||
"ThirdPartyAnalysis": "" | ||
} | ||
] | ||
""" | ||
|
||
field_mappings_series = { | ||
"_unique_id": "path:SeriesInstanceUID", | ||
"study_id": "path:StudyInstanceUID", | ||
"commons": "TCIA", | ||
"study_title": "path:SeriesDescription", | ||
"program_name": "path:Collection", | ||
"image_count": "path:ImageCount", | ||
"description": "", | ||
"tags": [], | ||
} | ||
|
||
respx.get("http://test/ok").mock(side_effect=httpx.HTTPError) | ||
assert ( | ||
get_metadata( | ||
"tcia", "http://test/ok", filters=None, mappings=field_mappings_study | ||
) | ||
== {} | ||
) | ||
|
||
respx.get("http://test/ok").mock(side_effect=Exception) | ||
assert ( | ||
get_metadata( | ||
"tcia", "http://test/ok", filters=None, mappings=field_mappings_study | ||
) | ||
== {} | ||
) | ||
|
||
respx.get( | ||
"http://test/ok", | ||
).mock(return_value=httpx.Response(status_code=200, content=tcia_response_study)) | ||
|
||
filters = {"size": 5} | ||
|
||
assert get_metadata( | ||
"tcia", "http://test/ok", filters=filters, mappings=field_mappings_study | ||
) == { | ||
"study_id_1": { | ||
"_guid_type": "discovery_metadata", | ||
"gen3_discovery": { | ||
"_unique_id": "study_id_1", | ||
"commons": "TCIA", | ||
"description": "TCIA data from collection: Collection1.", | ||
"program_name": "Collection1", | ||
"study_title": "Collection One.", | ||
"tags": [{"category": "program_name", "name": "Collection1"}], | ||
}, | ||
}, | ||
"study_id_2": { | ||
"_guid_type": "discovery_metadata", | ||
"gen3_discovery": { | ||
"_unique_id": "study_id_2", | ||
"commons": "TCIA", | ||
"description": "TCIA data from collection: Collection2.", | ||
"program_name": "Collection2", | ||
"study_title": "Collection Two.", | ||
"tags": [{"category": "program_name", "name": "Collection2"}], | ||
}, | ||
}, | ||
} | ||
|
||
respx.get( | ||
"http://test/ok", | ||
).mock(return_value=httpx.Response(status_code=200, content=tcia_response_series)) | ||
|
||
assert get_metadata( | ||
"tcia", "http://test/ok", filters=filters, mappings=field_mappings_series | ||
) == { | ||
"series_id_1": { | ||
"_guid_type": "discovery_metadata", | ||
"gen3_discovery": { | ||
"_unique_id": "series_id_1", | ||
"study_id": "study_id_1", | ||
"commons": "TCIA", | ||
"study_title": "", | ||
"program_name": "Collection1", | ||
"image_count": 10, | ||
"description": "TCIA data from collection: Collection1.", | ||
"tags": [{"category": "program_name", "name": "Collection1"}], | ||
}, | ||
}, | ||
"series_id_2": { | ||
"_guid_type": "discovery_metadata", | ||
"gen3_discovery": { | ||
"_unique_id": "series_id_2", | ||
"study_id": "study_id_2", | ||
"commons": "TCIA", | ||
"study_title": "", | ||
"program_name": "Collection2", | ||
"image_count": 20, | ||
"description": "TCIA data from collection: Collection2.", | ||
"tags": [{"category": "program_name", "name": "Collection2"}], | ||
}, | ||
}, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On some level this is how the subject metadata coming out of adapter should be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just tests. From what I see it has the same structure to what you provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate that. My request was to meet the testing standards, but looking at time crunch, if it works as required, I’m fine moving forward
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am as well.