-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Conversation
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 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( |
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 fits in one line.
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.
import sys | ||
import uuid | ||
|
||
from gcp_devrel.testing import eventually_consistent |
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 this line?
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.
|
||
|
||
@pytest.fixture(scope='module') | ||
def test_dataset(): |
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.
For these fixtures, can you also add retries like we did in datasets? It will make the tests more robust.
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.
assert 'Deleted HL7v2 message' in out | ||
|
||
|
||
def test_ingest_hl7v2_message(test_dataset, test_hl7v2_store, capsys): |
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 thought this test used to be eventually consistent. Has the situation changed?
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 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.
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.
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( |
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 think the indent is off here.
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.
hl7v2_store_id, | ||
hl7v2_message_file) | ||
|
||
hl7v2_messages_list = hl7v2_messages.list_hl7v2_messages( |
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.
Indent is off here
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.
|
||
assert len(hl7v2_messages_list) > 0 | ||
hl7v2_message_name = hl7v2_messages_list[0].get('name') | ||
nonlocal hl7v2_message_id |
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.
Remove nonlocal
line
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.
label_key, | ||
label_value) | ||
|
||
hl7v2_messages.delete_hl7v2_message( |
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.
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.
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.
Does it matter if we're deleting the HL7v2 store anyway? Deleting the store deletes any messages inside of 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.
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( |
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 fits in one line.
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.
@@ -0,0 +1,3 @@ | |||
pytest==5.3.2 | |||
gcp-devrel-py-tools==0.0.16 |
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.
Remove these two 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.
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?
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.
Ah sorry, yes, remove gcp-devrel-py-tools
and google-cloud-core
.
* 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.
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): |
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.
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( |
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 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( |
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.
s/delete_hl7v2_store_id/delete_hl7v2_store/ ?
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.
|
||
|
||
def test_get_set_hl7v2_store_iam_policy(test_dataset, capsys): | ||
hl7v2_stores.create_hl7v2_store( |
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 move creation/deletion to the fixture?
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.
|
||
|
||
def test_patch_hl7v2_store(test_dataset, capsys): | ||
hl7v2_stores.create_hl7v2_store( |
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 use the fixture?
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.
Looks great, thanks!
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'datasets')) # noqa | ||
import datasets |
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.
Does this not work?
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'datasets')) # noqa | |
import datasets | |
from ... import datasets |
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.
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'datasets')) # noqa | ||
import datasets |
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.
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'datasets')) # noqa | |
import datasets | |
from ... import datasets |
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.
assert 'Created HL7v2 store' in out | ||
assert 'Name' in out | ||
assert 'hl7V2Stores' in out | ||
assert 'Deleted HL7v2 store' in out |
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.
These asserts should probably happen after each function is run to avoid one function from accidentally testing positive for all 3
request = client.projects().locations().datasets().hl7V2Stores( | ||
).getIamPolicy(resource=hl7v2_store_name) |
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.
request = client.projects().locations().datasets().hl7V2Stores( | |
).getIamPolicy(resource=hl7v2_store_name) | |
request = client.projects().locations().datasets().hl7V2Stores().getIamPolicy( | |
resource=hl7v2_store_name) |
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.
Also if you have the noxfile-template copied locally, you can use it to run
To auto format the code. |
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 ℹ️ Googlers: Go here for more info. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Co-Authored-By: Kurtis Van Gent <[email protected]>
Co-Authored-By: Kurtis Van Gent <[email protected]>
Originally from #3300 but split up here