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: pass retry from Job.result() to Job.done() #41

Merged
merged 16 commits into from Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 5 additions & 7 deletions google/cloud/bigquery/job.py
Expand Up @@ -819,8 +819,9 @@ def result(self, retry=DEFAULT_RETRY, timeout=None):
"""
if self.state is None:
self._begin(retry=retry, timeout=timeout)
# TODO: modify PollingFuture so it can pass a retry argument to done().
return super(_AsyncJob, self).result(timeout=timeout)

kwargs = {} if retry is DEFAULT_RETRY else {"retry": retry}
tswast marked this conversation as resolved.
Show resolved Hide resolved
return super(_AsyncJob, self).result(timeout=timeout, **kwargs)

def cancelled(self):
"""Check if the job has been cancelled.
Expand Down Expand Up @@ -1845,7 +1846,7 @@ def destination(self):
"""
return TableReference.from_api_repr(
_helpers._get_sub_prop(
self._properties, ["configuration", "copy", "destinationTable"],
self._properties, ["configuration", "copy", "destinationTable"]
)
)

Expand Down Expand Up @@ -2043,10 +2044,7 @@ def __init__(self, job_id, source, destination_uris, client, job_config=None):
self._configuration = job_config

if source:
source_ref = {
"projectId": source.project,
"datasetId": source.dataset_id,
}
source_ref = {"projectId": source.project, "datasetId": source.dataset_id}

if isinstance(source, (Table, TableListItem, TableReference)):
source_ref["tableId"] = source.table_id
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -29,7 +29,7 @@
# 'Development Status :: 5 - Production/Stable'
release_status = "Development Status :: 5 - Production/Stable"
dependencies = [
"google-api-core[grpc] >= 1.22.2, < 2.0.0dev",
"google-api-core[grpc] >= 1.23.0, < 2.0.0dev",
"proto-plus >= 1.10.0",
"google-cloud-core >= 1.4.1, < 2.0dev",
"google-resumable-media >= 0.6.0, < 2.0dev",
Expand Down
2 changes: 1 addition & 1 deletion testing/constraints-3.6.txt
@@ -1,4 +1,4 @@
google-api-core==1.22.2
google-api-core==1.23.0
google-cloud-bigquery-storage==2.0.0
google-cloud-core==1.4.1
google-resumable-media==0.6.0
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/test_job.py
Expand Up @@ -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)
Expand All @@ -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
],
)
Expand Down Expand Up @@ -2757,7 +2757,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)

Expand All @@ -2779,7 +2779,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)

Expand Down Expand Up @@ -3205,7 +3205,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):
Expand Down Expand Up @@ -3620,7 +3620,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):
Expand Down