Skip to content

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

Merged
merged 9 commits into from
Apr 21, 2020
Merged

healthcare API: update all DICOM v1beta1 samples to v1 #3387

merged 9 commits into from
Apr 21, 2020

Conversation

noerog
Copy link
Contributor

@noerog noerog commented Apr 13, 2020

Originally from #3300 but split up here

@noerog noerog requested a review from a team as a code owner April 13, 2020 22:15
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 13, 2020
tmatsuo pushed a commit that referenced this pull request Apr 15, 2020
* 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]>
Copy link
Contributor

@tmatsuo tmatsuo left a 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:
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

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.

Copy link
Contributor Author

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)

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor

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).

Copy link
Contributor Author

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:
Copy link
Contributor

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")
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@noerog noerog requested a review from kurtisvg April 21, 2020 00:00
service_name = "healthcare"

return discovery.build(service_name, api_version)

Copy link
Contributor

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:
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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)

Copy link
Contributor

@kurtisvg kurtisvg left a 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:
Copy link
Contributor

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)

@noerog
Copy link
Contributor Author

noerog commented Apr 21, 2020

One nit then LGTM.

Sure, I actually expanded the comment on deleting the DICOM store. The dataset behavior is straightforward--if it doesn't exist, server returns 403.

@noerog noerog merged commit 002c18a into GoogleCloudPlatform:master Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants