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: pass None for retry in gapic calls #881

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions google/cloud/bigtable/data/_async/_mutate_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __init__(
table_name=table.table_name,
app_profile_id=table.app_profile_id,
metadata=metadata,
retry=None,
)
# create predicate for determining which errors are retryable
self.is_retryable = retries.if_exception_type(
Expand Down
1 change: 1 addition & 0 deletions google/cloud/bigtable/data/_async/_read_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def _read_rows_attempt(self) -> AsyncGenerator[Row, None]:
self.request,
timeout=next(self.attempt_timeout_gen),
metadata=self._metadata,
retry=None,
)
chunked_stream = self.chunk_stream(gapic_stream)
return self.merge_rows(chunked_stream)
Expand Down
3 changes: 3 additions & 0 deletions google/cloud/bigtable/data/_async/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ async def execute_rpc():
app_profile_id=self.app_profile_id,
timeout=next(attempt_timeout_gen),
metadata=metadata,
retry=None,
)
return [(s.row_key, s.offset_bytes) async for s in results]

Expand Down Expand Up @@ -1120,6 +1121,7 @@ async def check_and_mutate_row(
},
metadata=metadata,
timeout=operation_timeout,
retry=None,
)
return result.predicate_matched

Expand Down Expand Up @@ -1173,6 +1175,7 @@ async def read_modify_write_row(
},
metadata=metadata,
timeout=operation_timeout,
retry=None,
)
# construct Row from result
return Row._from_pb(result.row)
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/bigtable_v2/services/bigtable/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
from google.oauth2 import service_account # type: ignore

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore
OptionalRetry = Union[retries.Retry, object, None] # type: ignore

from google.cloud.bigtable_v2.types import bigtable
from google.cloud.bigtable_v2.types import data
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/bigtable_v2/services/bigtable/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
from google.oauth2 import service_account # type: ignore

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore
OptionalRetry = Union[retries.Retry, object, None] # type: ignore

from google.cloud.bigtable_v2.types import bigtable
from google.cloud.bigtable_v2.types import data
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/data/_async/test__mutate_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ def test_ctor(self):
assert client.mutate_rows.call_count == 1
# gapic_fn should call with table details
inner_kwargs = client.mutate_rows.call_args[1]
assert len(inner_kwargs) == 3
assert len(inner_kwargs) == 4
assert inner_kwargs["table_name"] == table.table_name
assert inner_kwargs["app_profile_id"] == table.app_profile_id
assert inner_kwargs["retry"] is None
metadata = inner_kwargs["metadata"]
assert len(metadata) == 1
assert metadata[0][0] == "x-goog-request-params"
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/data/_async/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,7 @@ async def test_read_rows_attempt_timeout(
# check timeouts
for _, call_kwargs in read_rows.call_args_list[:-1]:
assert call_kwargs["timeout"] == per_request_t
assert call_kwargs["retry"] is None
# last timeout should be adjusted to account for the time spent
assert (
abs(
Expand Down Expand Up @@ -1884,6 +1885,7 @@ async def test_sample_row_keys_default_timeout(self):
_, kwargs = sample_row_keys.call_args
assert abs(kwargs["timeout"] - expected_timeout) < 0.1
assert result == []
assert kwargs["retry"] is None

@pytest.mark.asyncio
async def test_sample_row_keys_gapic_params(self):
Expand All @@ -1905,11 +1907,12 @@ async def test_sample_row_keys_gapic_params(self):
await table.sample_row_keys(attempt_timeout=expected_timeout)
args, kwargs = sample_row_keys.call_args
assert len(args) == 0
assert len(kwargs) == 4
assert len(kwargs) == 5
assert kwargs["timeout"] == expected_timeout
assert kwargs["app_profile_id"] == expected_profile
assert kwargs["table_name"] == table.table_name
assert kwargs["metadata"] is not None
assert kwargs["retry"] is None

@pytest.mark.parametrize("include_app_profile", [True, False])
@pytest.mark.asyncio
Expand Down Expand Up @@ -2231,6 +2234,7 @@ async def test_bulk_mutate_rows(self, mutation_arg):
)
assert kwargs["entries"] == [bulk_mutation._to_dict()]
assert kwargs["timeout"] == expected_attempt_timeout
assert kwargs["retry"] is None

@pytest.mark.asyncio
async def test_bulk_mutate_rows_multiple_entries(self):
Expand Down Expand Up @@ -2595,6 +2599,7 @@ async def test_check_and_mutate(self, gapic_result):
]
assert request["app_profile_id"] == app_profile
assert kwargs["timeout"] == operation_timeout
assert kwargs["retry"] is None

@pytest.mark.asyncio
async def test_check_and_mutate_bad_timeout(self):
Expand Down Expand Up @@ -2678,6 +2683,7 @@ async def test_check_and_mutate_predicate_object(self):
kwargs = mock_gapic.call_args[1]
assert kwargs["request"]["predicate_filter"] == predicate_dict
assert mock_predicate._to_dict.call_count == 1
assert kwargs["retry"] is None

@pytest.mark.asyncio
async def test_check_and_mutate_mutations_parsing(self):
Expand Down Expand Up @@ -2781,6 +2787,7 @@ async def test_read_modify_write_call_rule_args(self, call_rules, expected_rules
assert mock_gapic.call_count == 1
found_kwargs = mock_gapic.call_args_list[0][1]
assert found_kwargs["request"]["rules"] == expected_rules
assert found_kwargs["retry"] is None

@pytest.mark.parametrize("rules", [[], None])
@pytest.mark.asyncio
Expand Down
Loading