-
Notifications
You must be signed in to change notification settings - Fork 6.6k
healthcare API: update all DICOM v1beta1 samples to v1 #3387
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
Conversation
* healthcare API: update all v1beta1 samples to v1 * healthcare API: use v1 instead of v1beta1 endpoint * healthcare API: remove FHIR conditional methods from v1 because they are only in v1beta1 * add requirements-test.txt files * Change test response for searching for studies to 204 * fix missing param in execute_bundle.json causing test failures * fix HL7v2 store failure. notificationConfig was deprecated in favor of notificationConfigs * address review comments: use ADC and simplify credentials auth * delete new FHIR files, they are now in #3384 * delete new DICOM files, they are now in #3387 * delete new HL7v2 files, they are now in #3388 * clean up test_dataset fixture * remove try block from the sample * more robust test setup and cleanup Co-authored-by: Takashi Matsuo <[email protected]>
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.
You may want to do some research on whether we still need requests
before actually make changes.
content_type = 'application/dicom' | ||
headers = {'Content-Type': content_type} | ||
|
||
try: |
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.
Can you remove try-except?
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.
Done.
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.
Seems like it reverted and it still has try-except.
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.
Fixed.
service_name = "healthcare" | ||
|
||
return discovery.build(service_name, api_version) | ||
|
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.
Nit: can you remove 2 empty lines after the return
statement and [END healthcare_get_client]
?
Also here and there.
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 would but that's an effect of running the black tool that we're supposed to be using to lint everything. I'd have to manually go back and remove the lines every time I run the lint tool.
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.
@kurtisvg Is there a way to instruct black not inserting the empty lines?
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.
If you indent the comment to match the function line, Black will likely treat it as part of the function and won't add the extra lines (otherwise I believe it's a PEP8 rule to have 2 empty lines after a top level function).
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.
That's not ideal because that goes against style for writing comments, no?
content_type = 'application/dicom' | ||
headers = {'Content-Type': content_type} | ||
|
||
try: |
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.
Seems like it reverted and it still has try-except.
assert "Retrieved study" in out | ||
|
||
# Delete downloaded study | ||
os.remove("study.multipart") |
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.
Not a big deal, but can you put the os.remove()
call in finally
clause?
try:
...
...
finally:
os.remove("study.multipart")
also for some tests below
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.
Done.
service_name = "healthcare" | ||
|
||
return discovery.build(service_name, api_version) | ||
|
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.
If you indent the comment to match the function line, Black will likely treat it as part of the function and won't add the extra lines (otherwise I believe it's a PEP8 rule to have 2 empty lines after a top level function).
datasets.delete_dataset(project_id, cloud_region, dataset_id) | ||
except HttpError as err: | ||
# The API returns 403 when the dataset doesn't exist. | ||
if err.resp.status == 404 or err.resp.status == 403: |
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.
What about 404?
Can we update the comment to include why we are suppressing. Why do we want to surpress when it doesn't exist?
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.
It's a 403 when calling delete on a dataset that doesn't exist. Calling delete on a DICOM store that doesn't exist returns 404. Calling delete on a DICOM store that's in a dataset when the dataset doesn't exist returns a 403.
We can suppress it because if the dataset doesn't exist then we don't need to delete it.
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.
Can we add that to the comment :) (L85-87 is a good example)
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.
One nit then LGTM.
datasets.delete_dataset(project_id, cloud_region, dataset_id) | ||
except HttpError as err: | ||
# The API returns 403 when the dataset doesn't exist. | ||
if err.resp.status == 404 or err.resp.status == 403: |
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.
Can we add that to the comment :) (L85-87 is a good example)
Sure, I actually expanded the comment on deleting the DICOM store. The dataset behavior is straightforward--if it doesn't exist, server returns 403. |
Originally from #3300 but split up here