-
Notifications
You must be signed in to change notification settings - Fork 350
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
feat: add wait for creation and more informative exception when properties are not available #566
feat: add wait for creation and more informative exception when properties are not available #566
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.
LGTM, thanks Sasha! Added a few questions.
@@ -255,6 +255,8 @@ def get_model_with_custom_project_mock(): | |||
get_model_mock.return_value = gca_model.Model( | |||
display_name=_TEST_MODEL_NAME, | |||
name=_TEST_MODEL_RESOURCE_NAME_CUSTOM_PROJECT, | |||
artifact_uri=_TEST_ARTIFACT_URI, | |||
description=_TEST_DESCRIPTION, |
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 presume these are being added to ensure that accessing these fields will still raise a RuntimeError
if _gca_resource
is not set?
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 fields were added to test properties would return without throwing a RuntimeError
if gca_resource
is set, though these tests could have asserted for empty strings per underlying proto implementation so this may not be necessary.
while not getattr(self._gca_resource, "name", None): | ||
# breaks out of loop if creation has failed async | ||
if self._are_futures_done() and not getattr( | ||
self._gca_resource, "name", None | ||
): | ||
self._raise_future_exception() | ||
|
||
time.sleep(1) |
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.
Is this frequency of polling alright? Since it doesn't call the service I'm presuming so.
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.
Correct, it doesn't call the service. Also, when in this loop there is no _gca_resource
available so the resource either hasn't been created yet or our creation request hasn't returned yet.
Includes fixes to some properties.