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

feat: Enable custom predicates for media operations #1385

Merged
merged 5 commits into from
Dec 3, 2024

Conversation

andrewsg
Copy link
Contributor

@andrewsg andrewsg commented Nov 21, 2024

This refactor unifies the old resumable media retry code with the newer google.api_core retry code, enabling custom predicates for media operations.

Fixes #1361

@andrewsg andrewsg added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Nov 21, 2024
@andrewsg andrewsg requested review from a team as code owners November 21, 2024 18:09
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: storage Issues related to the googleapis/python-storage API. labels Nov 21, 2024
@andrewsg andrewsg removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Nov 21, 2024
Copy link
Contributor

@cojenco cojenco left a comment

Choose a reason for hiding this comment

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

Looking good, very excited about retry unification!

@@ -35,19 +39,34 @@
requests.ConnectionError,
requests_exceptions.ChunkedEncodingError,
requests_exceptions.Timeout,
http.client.BadStatusLine,
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks for consolidating the retryable errors. Looking at the requests docs requests.ConnectionError should be equivalent to requests.exceptions.ConnectionError so we're good!

google/cloud/storage/_media/common.py Show resolved Hide resolved
return _request_helpers.wait_and_retry(
retriable_request, self._get_status_code, self._retry_strategy
)
return _request_helpers.wait_and_retry(retriable_request, self._retry_strategy)


Copy link
Contributor

Choose a reason for hiding this comment

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

nit: to match download, we probably want to add the retry arg docstrings for MultipartUpload, ResumableUpload etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done

google/cloud/storage/blob.py Show resolved Hide resolved
and the object will configure backoff and timeout options. Custom
predicates (customizable error codes) are not supported for media
operations such as this one.
and the object will configure backoff and timeout options.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Do we want to call out the default retry? I recall we received some feedback around stating the default value in our docstrings

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 like to incorporate DEFAULT_RETRY into the docs somehow without copy/pasting it into every method. Not sure how to do that yet. I'd prefer not to include it in this change as it's already quite large but it's a good idea.

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, let's update that in a separate PR

@andrewsg andrewsg merged commit a2e9b57 into 3.0-devel Dec 3, 2024
4 checks passed
@andrewsg andrewsg deleted the 3.0-retry-unification branch December 3, 2024 00:00
@andrewsg andrewsg mentioned this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/python-storage API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants