From 48b7a5ef419c453f071f88ab0d3e180099c451f2 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Fri, 22 Nov 2024 13:37:13 -0800 Subject: [PATCH 1/4] chore: use default for unset app_profile_id --- google/cloud/bigtable/data/_async/client.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/google/cloud/bigtable/data/_async/client.py b/google/cloud/bigtable/data/_async/client.py index d560d7e1e..a4390bf74 100644 --- a/google/cloud/bigtable/data/_async/client.py +++ b/google/cloud/bigtable/data/_async/client.py @@ -472,6 +472,7 @@ def get_table(self, instance_id: str, table_id: str, *args, **kwargs) -> TableAs table_id: The ID of the table. table_id is combined with the instance_id and the client's project to fully specify the table app_profile_id: The app profile to associate with requests. + If not set, will use "default". https://cloud.google.com/bigtable/docs/app-profiles default_read_rows_operation_timeout: The default timeout for read rows operations, in seconds. If not set, defaults to 600 seconds (10 minutes) @@ -542,6 +543,7 @@ async def execute_query( detected automatically (i.e. the value can be None, an empty list or an empty dict). app_profile_id: The app profile to associate with requests. + If not set, will use "default". https://cloud.google.com/bigtable/docs/app-profiles operation_timeout: the time budget for the entire operation, in seconds. Failed requests will be retried within the budget. @@ -571,6 +573,8 @@ async def execute_query( pb_params = _format_execute_query_params(parameters, parameter_types) instance_name = self._gapic_client.instance_path(self.project, instance_id) + if app_profile_id is None: + app_profile_id = "default" request_body = { "instance_name": instance_name, @@ -662,6 +666,7 @@ def __init__( table_id: The ID of the table. table_id is combined with the instance_id and the client's project to fully specify the table app_profile_id: The app profile to associate with requests. + If not set, will use "default". https://cloud.google.com/bigtable/docs/app-profiles default_read_rows_operation_timeout: The default timeout for read rows operations, in seconds. If not set, defaults to 600 seconds (10 minutes) @@ -713,7 +718,9 @@ def __init__( self.table_name = self.client._gapic_client.table_path( self.client.project, instance_id, table_id ) - self.app_profile_id = app_profile_id + self.app_profile_id = ( + app_profile_id if app_profile_id is not None else "default" + ) self.default_operation_timeout = default_operation_timeout self.default_attempt_timeout = default_attempt_timeout From ad2a035becb1f901e3cdac5cdf1afb30f3c62ebe Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Fri, 22 Nov 2024 13:37:33 -0800 Subject: [PATCH 2/4] updated tests --- tests/unit/data/_async/test_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/data/_async/test_client.py b/tests/unit/data/_async/test_client.py index c24fa3d98..57b3c9666 100644 --- a/tests/unit/data/_async/test_client.py +++ b/tests/unit/data/_async/test_client.py @@ -1069,7 +1069,7 @@ async def test_table_ctor_defaults(self): await CrossSync.yield_to_event_loop() assert table.table_id == expected_table_id assert table.instance_id == expected_instance_id - assert table.app_profile_id is None + assert table.app_profile_id == "default" assert table.client is client assert table.default_operation_timeout == 60 assert table.default_read_rows_operation_timeout == 600 @@ -1290,7 +1290,7 @@ async def test_call_metadata(self, include_app_profile, fn_name, fn_args, gapic_ if include_app_profile: assert "app_profile_id=profile" in routing_str else: - assert "app_profile_id=" not in routing_str + assert "app_profile_id=default" in routing_str @CrossSync.convert_class( @@ -2938,7 +2938,7 @@ async def test_read_modify_write_call_defaults(self): kwargs["table_name"] == f"projects/{project}/instances/{instance}/tables/{table_id}" ) - assert kwargs["app_profile_id"] is None + assert kwargs["app_profile_id"] == "default" assert kwargs["row_key"] == row_key.encode() assert kwargs["timeout"] > 1 From 7e6dda4a679f8d788036388ba23207fdb50c212a Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Fri, 22 Nov 2024 14:16:07 -0800 Subject: [PATCH 3/4] use empty string instead of "default" --- google/cloud/bigtable/data/_async/client.py | 10 +++++----- tests/unit/data/_async/test_client.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/google/cloud/bigtable/data/_async/client.py b/google/cloud/bigtable/data/_async/client.py index a4390bf74..4ed83564a 100644 --- a/google/cloud/bigtable/data/_async/client.py +++ b/google/cloud/bigtable/data/_async/client.py @@ -472,7 +472,7 @@ def get_table(self, instance_id: str, table_id: str, *args, **kwargs) -> TableAs table_id: The ID of the table. table_id is combined with the instance_id and the client's project to fully specify the table app_profile_id: The app profile to associate with requests. - If not set, will use "default". + If not set, will use empty string. https://cloud.google.com/bigtable/docs/app-profiles default_read_rows_operation_timeout: The default timeout for read rows operations, in seconds. If not set, defaults to 600 seconds (10 minutes) @@ -543,7 +543,7 @@ async def execute_query( detected automatically (i.e. the value can be None, an empty list or an empty dict). app_profile_id: The app profile to associate with requests. - If not set, will use "default". + If not set, will use empty string. https://cloud.google.com/bigtable/docs/app-profiles operation_timeout: the time budget for the entire operation, in seconds. Failed requests will be retried within the budget. @@ -574,7 +574,7 @@ async def execute_query( instance_name = self._gapic_client.instance_path(self.project, instance_id) if app_profile_id is None: - app_profile_id = "default" + app_profile_id = "" request_body = { "instance_name": instance_name, @@ -666,7 +666,7 @@ def __init__( table_id: The ID of the table. table_id is combined with the instance_id and the client's project to fully specify the table app_profile_id: The app profile to associate with requests. - If not set, will use "default". + If not set, will use empty string. https://cloud.google.com/bigtable/docs/app-profiles default_read_rows_operation_timeout: The default timeout for read rows operations, in seconds. If not set, defaults to 600 seconds (10 minutes) @@ -719,7 +719,7 @@ def __init__( self.client.project, instance_id, table_id ) self.app_profile_id = ( - app_profile_id if app_profile_id is not None else "default" + app_profile_id if app_profile_id is not None else "" ) self.default_operation_timeout = default_operation_timeout diff --git a/tests/unit/data/_async/test_client.py b/tests/unit/data/_async/test_client.py index 57b3c9666..2575db8da 100644 --- a/tests/unit/data/_async/test_client.py +++ b/tests/unit/data/_async/test_client.py @@ -1069,7 +1069,7 @@ async def test_table_ctor_defaults(self): await CrossSync.yield_to_event_loop() assert table.table_id == expected_table_id assert table.instance_id == expected_instance_id - assert table.app_profile_id == "default" + assert table.app_profile_id == "" assert table.client is client assert table.default_operation_timeout == 60 assert table.default_read_rows_operation_timeout == 600 @@ -1290,7 +1290,7 @@ async def test_call_metadata(self, include_app_profile, fn_name, fn_args, gapic_ if include_app_profile: assert "app_profile_id=profile" in routing_str else: - assert "app_profile_id=default" in routing_str + assert "app_profile_id=" in routing_str @CrossSync.convert_class( @@ -2938,7 +2938,7 @@ async def test_read_modify_write_call_defaults(self): kwargs["table_name"] == f"projects/{project}/instances/{instance}/tables/{table_id}" ) - assert kwargs["app_profile_id"] == "default" + assert kwargs["app_profile_id"] == "" assert kwargs["row_key"] == row_key.encode() assert kwargs["timeout"] > 1 From 50e7c4084a19eec05154eb583601eef448799691 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 22 Nov 2024 22:18:51 +0000 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- google/cloud/bigtable/data/_async/client.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/google/cloud/bigtable/data/_async/client.py b/google/cloud/bigtable/data/_async/client.py index 4ed83564a..9e50ce337 100644 --- a/google/cloud/bigtable/data/_async/client.py +++ b/google/cloud/bigtable/data/_async/client.py @@ -718,9 +718,7 @@ def __init__( self.table_name = self.client._gapic_client.table_path( self.client.project, instance_id, table_id ) - self.app_profile_id = ( - app_profile_id if app_profile_id is not None else "" - ) + self.app_profile_id = app_profile_id if app_profile_id is not None else "" self.default_operation_timeout = default_operation_timeout self.default_attempt_timeout = default_attempt_timeout