Title: Retry should have a public way to access the predicate · Issue #15026 · googleapis/google-cloud-python · GitHub
Open Graph Title: Retry should have a public way to access the predicate · Issue #15026 · googleapis/google-cloud-python
X Title: Retry should have a public way to access the predicate · Issue #15026 · googleapis/google-cloud-python
Description: Is your feature request related to a problem? Please describe. In BigQuery, there are some operations like "start a query" that can actually take multiple API requests. It's usually just jobs.insert, but if there's a conflict, then we al...
Open Graph Description: Is your feature request related to a problem? Please describe. In BigQuery, there are some operations like "start a query" that can actually take multiple API requests. It's usually just jobs.inser...
X Description: Is your feature request related to a problem? Please describe. In BigQuery, there are some operations like "start a query" that can actually take multiple API requests. It's usually j...
Opengraph URL: https://github.com/googleapis/google-cloud-python/issues/15026
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Retry should have a public way to access the predicate","articleBody":" **Is your feature request related to a problem? Please describe.**\n\nIn BigQuery, there are some operations like \"start a query\" that can actually take multiple API requests. It's usually just `jobs.insert`, but if there's a conflict, then we also make calls to `jobs.get`. In addition, these have different predicates, such as wanting to retry `jobs.get` on 404 in this context but not others.\n\n **Describe the solution you'd like**\n\nIdeally, I could take a user-provided generic retry and tweak if for the given scenario. For example:\n\n```python\nget_job_retry = retry.with_predicate(\n lambda exc: isinstance(exc, core_exceptions.NotFound)\n # Reference the original retry to avoid recursion.\n or retry._predicate(exc)\n)\n```\n\nor\n\n```python\ndef do_query_predicate(exc) -> bool:\n if isinstance(exc, core_exceptions.RetryError):\n exc = exc.cause\n\n # Per https://github.com/googleapis/python-bigquery/issues/2134, sometimes\n # we get a 404 error. In this case, if we get this far, assume that the job\n # doesn't actually exist and try again. We can't add 404 to the default\n # job_retry because that happens for errors like \"this table does not\n # exist\", which probably won't resolve with a retry.\n if isinstance(exc, core_exceptions.NotFound):\n message = exc.message\n # Don't try to retry table/dataset not found, just job not found.\n # The URL contains jobs, so use whitespace to disambiguate.\n return message is not None and \" job\" in message.lower()\n\n # Reference the original job_retry to avoid recursion.\n return job_retry._predicate(exc)\n)\n```\n\n **Describe alternatives you've considered**\n\n1. Just as I already have two retry objects in the parameters for the `query()` API, I could update it to have two more for these specific situations.\n2. We could also add a method `with_additional_predicate` that adds an `or` clause + this function to the previous predicate.\n\n **Additional context**\n\nhttps://github.com/googleapis/python-bigquery/pull/2135 is an issue where I will likely add more \"retry\" parameters for finer-grained control, but would have preferred taking a user's retry object and amending the predicate.\n","author":{"url":"https://github.com/tswast","@type":"Person","name":"tswast"},"datePublished":"2025-02-20T16:42:07Z","url":"https://github.com/googleapis/google-cloud-python/issues/15026"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1e1f3b45-3516-60ba-cecc-e43fefac2131 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9BD8:20741A:EFDECA:13CA04D:6AFE98F3 |
| html-safe-nonce | 63443ad7959362f70277f1ba1336bd03412300f1eaecb3f53fb5d18b824d1a17 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkQ4OjIwNzQxQTpFRkRFQ0E6MTNDQTA0RDo2QUZFOThGMyIsInZpc2l0b3JfaWQiOiI5NzgwMjYyNTA1MTU2ODM1NzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 99deb0a7e1cd27ea99918cb2ff8d7f997f4a8dcb905115e9d05b504a124fec10 |
| hovercard-subject-tag | issue:3804911196 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-cloud-python/15026/issue_layout |
| twitter:image | https://opengraph.githubassets.com/033e84ac8e4e4cb5dccf2335dbba95450bf91bf3c7049d315bc608120a8abd5b/googleapis/google-cloud-python/issues/15026 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/033e84ac8e4e4cb5dccf2335dbba95450bf91bf3c7049d315bc608120a8abd5b/googleapis/google-cloud-python/issues/15026 |
| og:image:alt | Is your feature request related to a problem? Please describe. In BigQuery, there are some operations like "start a query" that can actually take multiple API requests. It's usually just jobs.inser... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tswast |
| hostname | github.com |
| expected-hostname | github.com |
| None | b3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/google-cloud-python git https://github.com/googleapis/google-cloud-python.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 16316451 |
| octolytics-dimension-repository_nwo | googleapis/google-cloud-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 16316451 |
| octolytics-dimension-repository_network_root_nwo | googleapis/google-cloud-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4a10310af51a1bfffbedc4fd81cb582acf0cb0ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width