Skip to content

Commit

Permalink
Merge branch 'experimental_v3' into expose_retries
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Oct 27, 2023
2 parents 1615530 + 94bfe66 commit 83450a9
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 6 deletions.
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 @@ -80,6 +80,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 @@ -143,6 +143,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 @@ -917,6 +917,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 @@ -1190,6 +1191,7 @@ async def check_and_mutate_row(
},
metadata=metadata,
timeout=operation_timeout,
retry=None,
)
return result.predicate_matched

Expand Down Expand Up @@ -1243,6 +1245,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 @@ -100,9 +100,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 @@ -1887,6 +1888,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 @@ -1908,11 +1910,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 @@ -2234,6 +2237,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 @@ -2598,6 +2602,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 @@ -2681,6 +2686,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 @@ -2784,6 +2790,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

0 comments on commit 83450a9

Please sign in to comment.