Skip to content
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

fix: Add retries when polling during monitoring runs #786

Merged
merged 4 commits into from Oct 27, 2021

Conversation

sasha-gitg
Copy link
Member

@product-auto-label product-auto-label bot added the api: aiplatform Issues related to the AI Platform API. label Oct 25, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 25, 2021
@@ -532,7 +536,9 @@ def _get_gca_resource(self, resource_name: str) -> proto.Message:
location=self.location,
)

return getattr(self.api_client, self._getter_method)(name=resource_name)
return getattr(self.api_client, self._getter_method)(
Copy link
Contributor

Choose a reason for hiding this comment

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

How about delete and list methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

The purpose of the PR is to address intermittent failure during polling and the goal is to scope to that issue.

We can follow up on list and delete. delete will take additional care as the request to delete may get through to the service but we may not receive a response and retrying delete will throw an exception.

Copy link
Contributor

@ivanmkc ivanmkc left a comment

Choose a reason for hiding this comment

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

I'm wondering if this would actually change anything as there is already a default retry associated with the client methods.

For example, EndpointServiceAsyncClient has:

    async def get_endpoint(
        self,
        request: endpoint_service.GetEndpointRequest = None,
        *,
        name: str = None,
        retry: retries.Retry = gapic_v1.method.DEFAULT,
        timeout: float = None,
        metadata: Sequence[Tuple[str, str]] = (),
    ) -> endpoint.Endpoint:

Is the default retry not sufficient?

@@ -48,6 +49,9 @@

logging.basicConfig(level=logging.INFO, stream=sys.stdout)

# This is the default retry callback to be used with get methods.
_DEFAULT_RETRY = retry.Retry()
Copy link

@helinwang helinwang Oct 25, 2021

Choose a reason for hiding this comment

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

IIUC gapic_v1.method.DEFAULT is used when no retry is provided (https://github.com/googleapis/python-aiplatform/search?q=retry%3D). I wonder if there is any difference between _DEFAULT_RETRY and gapic_v1.method.DEFAULT?
If there is no difference, I think we need a more aggressive _DEFAULT_RETRY to fix the current problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

gapic_v1.method.DEFAULT is a sentinel value that is used to set the default retry passed into the constructor of the Gapic callable.

See usage here: https://github.com/googleapis/python-api-core/blob/main/google/api_core/gapic_v1/method.py#L125

The default retry is None: https://github.com/googleapis/python-api-core/blob/main/google/api_core/gapic_v1/method.py#L147

cc: @ivanmkc

@helinwang
Copy link

LGTM, thanks Sasha!

Copy link
Contributor

@ivanmkc ivanmkc left a comment

Choose a reason for hiding this comment

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

LGTM

@sasha-gitg sasha-gitg merged commit 45401c0 into googleapis:main Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: aiplatform Issues related to the AI Platform API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants