Skip to content

healthcare API: update all HL7v2 v1beta1 samples to v1 #3388

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 7 commits into from
Apr 17, 2020
Merged

healthcare API: update all HL7v2 v1beta1 samples to v1 #3388

merged 7 commits into from
Apr 17, 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:33
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 13, 2020
@noerog noerog assigned tmatsuo and unassigned crwilcox Apr 13, 2020
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.

I reviewed files other then hl7v2_stores_test.py.

I'm sending this review, but I found an issue on the approach we're taking. We'll need to make some more change to the datasets samples and tests.

api_version = 'v1'
service_name = 'healthcare'

return discovery.build(
Copy link
Contributor

Choose a reason for hiding this comment

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

This fits in one line.

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.

import sys
import uuid

from gcp_devrel.testing import eventually_consistent
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 this line?

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.



@pytest.fixture(scope='module')
def test_dataset():
Copy link
Contributor

Choose a reason for hiding this comment

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

For these fixtures, can you also add retries like we did in datasets? It will make the tests more robust.

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.

assert 'Deleted HL7v2 message' in out


def test_ingest_hl7v2_message(test_dataset, test_hl7v2_store, capsys):
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought this test used to be eventually consistent. Has the situation changed?

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 thought the list_messages part was made eventually consistent because you thought the list_messages method was flaky, but it wasn't flaky--it was broken for a short amount of time because the response body from the method changed.

I don't see much reason to keep it eventually consistent but please let me know if you do.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good :)

FYI, to verify whether the test is flaky or not, you can utilize flaky. You can add a decorator like the following temporarily:

@pytest.mark.flaky(max_runs=100, min_passes=100)

Then you can verify this locally:

$ python -m nox -s py-3.6 -- hl7v2_messages_test.py

hl7v2_store_id,
hl7v2_message_file)

hl7v2_messages_list = hl7v2_messages.list_hl7v2_messages(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the indent is off here.

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.

hl7v2_store_id,
hl7v2_message_file)

hl7v2_messages_list = hl7v2_messages.list_hl7v2_messages(
Copy link
Contributor

Choose a reason for hiding this comment

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

Indent is off here

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.


assert len(hl7v2_messages_list) > 0
hl7v2_message_name = hl7v2_messages_list[0].get('name')
nonlocal hl7v2_message_id
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove nonlocal line

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.

label_key,
label_value)

hl7v2_messages.delete_hl7v2_message(
Copy link
Contributor

Choose a reason for hiding this comment

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

The same concern about cleaning up.

If the API doesn't allow recursive deletion, one idea is to list the messages and delete them in the clean up code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it matter if we're deleting the HL7v2 store anyway? Deleting the store deletes any messages inside of it.

Copy link
Contributor

Choose a reason for hiding this comment

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

If the API behaves like that, it's fine.

However, note that it will be not OK once the API changes the behavior (not allowing recursive deletion).

api_version = 'v1'
service_name = 'healthcare'

return discovery.build(
Copy link
Contributor

Choose a reason for hiding this comment

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

It fits in one line.

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.

@@ -0,0 +1,3 @@
pytest==5.3.2
gcp-devrel-py-tools==0.0.16
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove these two lines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You highlited pytest and gcp-devrel-py-tools. Did you mean to highlight gcp-devrel-py-tools and google-cloud-core? We need pytest don't we?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah sorry, yes, remove gcp-devrel-py-tools and google-cloud-core.

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.

Overall, it looks good. Please address my comments.

assert 'Deleted HL7v2 message' in out


def test_ingest_hl7v2_message(test_dataset, test_hl7v2_store, capsys):
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good :)

FYI, to verify whether the test is flaky or not, you can utilize flaky. You can add a decorator like the following temporarily:

@pytest.mark.flaky(max_runs=100, min_passes=100)

Then you can verify this locally:

$ python -m nox -s py-3.6 -- hl7v2_messages_test.py

label_key,
label_value)

hl7v2_messages.delete_hl7v2_message(
Copy link
Contributor

Choose a reason for hiding this comment

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

If the API behaves like that, it's fine.

However, note that it will be not OK once the API changes the behavior (not allowing recursive deletion).

retry_on_exception=retry_if_server_exception)
def clean_up():
try:
hl7v2_stores.delete_hl7v2_store_id(
Copy link
Contributor

Choose a reason for hiding this comment

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

s/delete_hl7v2_store_id/delete_hl7v2_store/ ?

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.



def test_get_set_hl7v2_store_iam_policy(test_dataset, capsys):
hl7v2_stores.create_hl7v2_store(
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 move creation/deletion to the fixture?

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.



def test_patch_hl7v2_store(test_dataset, capsys):
hl7v2_stores.create_hl7v2_store(
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 use the fixture?

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

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

Looks great, thanks!

Comment on lines 24 to 25
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'datasets')) # noqa
import datasets
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this not work?

Suggested change
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'datasets')) # noqa
import datasets
from ... import datasets

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.

Comment on lines 24 to 25
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'datasets')) # noqa
import datasets
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'datasets')) # noqa
import datasets
from ... import datasets

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.

Comment on lines 184 to 187
assert 'Created HL7v2 store' in out
assert 'Name' in out
assert 'hl7V2Stores' in out
assert 'Deleted HL7v2 store' in out
Copy link
Contributor

Choose a reason for hiding this comment

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

These asserts should probably happen after each function is run to avoid one function from accidentally testing positive for all 3

Comment on lines 167 to 168
request = client.projects().locations().datasets().hl7V2Stores(
).getIamPolicy(resource=hl7v2_store_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
request = client.projects().locations().datasets().hl7V2Stores(
).getIamPolicy(resource=hl7v2_store_name)
request = client.projects().locations().datasets().hl7V2Stores().getIamPolicy(
resource=hl7v2_store_name)

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.

@kurtisvg
Copy link
Contributor

Also if you have the noxfile-template copied locally, you can use it to run black on your code:

nox -S blacken

To auto format the code.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to determine that you authored the commits in this PR. Maybe you used a different email address in the git commits than was used to sign the CLA? If someone else authored these commits, then please add them to this pull request and have them confirm that they're okay with them being contributed to Google. If there are co-authors, make sure they're formatted properly.

In order to pass this check, please resolve this problem and then comment@googlebot I fixed it... If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot removed the cla: yes This human has signed the Contributor License Agreement. label Apr 17, 2020
@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label Apr 17, 2020
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Apr 17, 2020
@noerog noerog merged commit d6bf6c0 into GoogleCloudPlatform:master Apr 17, 2020
@noerog noerog deleted the chc-api-hl7v2 branch April 17, 2020 20:26
@tmatsuo
Copy link
Contributor

tmatsuo commented Apr 19, 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.

5 participants