Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 325
feat: pass retry from Job.result() to Job.done()#41
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
29fb5e5
feat(bigquery): pass retry from Job.result() to Job.done().
bdfe0e4
Merge branch 'master' into retry_from_result_to_done
cde2c2c
fix merge conflicts
878be0b
drop the comment
11cc5de
use kwargs sentinel
789cf49
check the mock retry
06f13bd
update dependencies
e415fdd
Merge branch 'master' into retry_from_result_to_done
30aea1d
Merge branch 'master' into retry_from_result_to_done
tswast dc33f0a
Merge branch 'master' into retry_from_result_to_done
925621e
use kwargs pattern
531d3d8
Merge branch 'retry_from_result_to_done' of https://github.com/q-logi…
a200fb2
Merge branch 'master' into retry_from_result_to_done
tswast d30bb6b
Merge branch 'master' of https://github.com/googleapis/python-bigquer…
HemangChothani 0827daa
feat: added unit test for retry
HemangChothani 7b214f6
feat: added more exceptions
HemangChothani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -864,7 +864,7 @@ def test_cancel_w_custom_retry(self): | ||
| job = self._set_properties_job() | ||
| api_request_patcher = mock.patch.object( | ||
| job._client._connection, "api_request", side_effect=[ValueError, response], | ||
| job._client._connection, "api_request", side_effect=[ValueError, response] | ||
| ) | ||
| retry = DEFAULT_RETRY.with_deadline(1).with_predicate( | ||
| lambda exc: isinstance(exc, ValueError) | ||
| @@ -885,7 +885,7 @@ def test_cancel_w_custom_retry(self): | ||
| [ | ||
| mock.call(method="POST", path=api_path, query_params={}, timeout=7.5), | ||
| mock.call( | ||
| method="POST", path=api_path, query_params={}, timeout=7.5, | ||
| method="POST", path=api_path, query_params={}, timeout=7.5 | ||
| ), # was retried once | ||
| ], | ||
| ) | ||
| @@ -1034,7 +1034,6 @@ def test_result_w_retry_wo_state(self): | ||
| custom_predicate = mock.Mock() | ||
| custom_predicate.return_value = True | ||
| custom_retry = google.api_core.retry.Retry(predicate=custom_predicate) | ||
| self.assertIs(job.result(retry=custom_retry), job) | ||
| begin_call = mock.call( | ||
| @@ -2757,7 +2756,7 @@ def test_cancel_w_bound_client(self): | ||
| final_attributes.assert_called_with({"path": PATH}, client, job) | ||
| conn.api_request.assert_called_once_with( | ||
| method="POST", path=PATH, query_params={}, timeout=None, | ||
| method="POST", path=PATH, query_params={}, timeout=None | ||
| ) | ||
| self._verifyResourceProperties(job, RESOURCE) | ||
| @@ -2779,7 +2778,7 @@ def test_cancel_w_alternate_client(self): | ||
| conn1.api_request.assert_not_called() | ||
| conn2.api_request.assert_called_once_with( | ||
| method="POST", path=PATH, query_params={}, timeout=None, | ||
| method="POST", path=PATH, query_params={}, timeout=None | ||
| ) | ||
| self._verifyResourceProperties(job, RESOURCE) | ||
| @@ -3205,7 +3204,7 @@ def test_exists_miss_w_bound_client(self): | ||
| final_attributes.assert_called_with({"path": PATH}, client, job) | ||
| conn.api_request.assert_called_once_with( | ||
| method="GET", path=PATH, query_params={"fields": "id"}, timeout=None, | ||
| method="GET", path=PATH, query_params={"fields": "id"}, timeout=None | ||
| ) | ||
| def test_exists_hit_w_alternate_client(self): | ||
| @@ -3620,7 +3619,7 @@ def test_exists_miss_w_bound_client(self): | ||
| final_attributes.assert_called_with({"path": PATH}, client, job) | ||
| conn.api_request.assert_called_once_with( | ||
| method="GET", path=PATH, query_params={"fields": "id"}, timeout=None, | ||
| method="GET", path=PATH, query_params={"fields": "id"}, timeout=None | ||
| ) | ||
| def test_exists_hit_w_alternate_client(self): | ||
| @@ -4812,6 +4811,60 @@ def test_result_with_max_results(self): | ||
| tabledata_list_request[1]["query_params"]["maxResults"], max_results | ||
| ) | ||
| def test_result_w_retry(self): | ||
| from google.cloud.bigquery.table import RowIterator | ||
| query_resource = { | ||
| "jobComplete": False, | ||
| "jobReference": {"projectId": self.PROJECT, "jobId": self.JOB_ID}, | ||
| } | ||
| query_resource_done = { | ||
| "jobComplete": True, | ||
| "jobReference": {"projectId": self.PROJECT, "jobId": self.JOB_ID}, | ||
| "schema": {"fields": [{"name": "col1", "type": "STRING"}]}, | ||
| "totalRows": "2", | ||
| } | ||
| job_resource = self._make_resource(started=True) | ||
| job_resource_done = self._make_resource(started=True, ended=True) | ||
| job_resource_done["configuration"]["query"]["destinationTable"] = { | ||
| "projectId": "dest-project", | ||
| "datasetId": "dest_dataset", | ||
| "tableId": "dest_table", | ||
| } | ||
| connection = _make_connection( | ||
| exceptions.NotFound("not normally retriable"), | ||
| query_resource, | ||
| exceptions.NotFound("not normally retriable"), | ||
| query_resource_done, | ||
tswast marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| exceptions.NotFound("not normally retriable"), | ||
| job_resource_done, | ||
| ) | ||
| client = _make_client(self.PROJECT, connection=connection) | ||
| job = self._get_target_class().from_api_repr(job_resource, client) | ||
| custom_predicate = mock.Mock() | ||
| custom_predicate.return_value = True | ||
| custom_retry = google.api_core.retry.Retry(predicate=custom_predicate) | ||
| self.assertIsInstance(job.result(retry=custom_retry), RowIterator) | ||
| query_results_call = mock.call( | ||
| method="GET", | ||
| path=f"/projects/{self.PROJECT}/queries/{self.JOB_ID}", | ||
| query_params={"maxResults": 0}, | ||
| timeout=None, | ||
| ) | ||
| reload_call = mock.call( | ||
| method="GET", | ||
| path=f"/projects/{self.PROJECT}/jobs/{self.JOB_ID}", | ||
| query_params={}, | ||
| timeout=None, | ||
| ) | ||
| connection.api_request.assert_has_calls( | ||
| [query_results_call, query_results_call, reload_call] | ||
| ) | ||
| def test_result_w_empty_schema(self): | ||
| from google.cloud.bigquery.table import _EmptyRowIterator | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.