Skip to content

Commit 330bcde

Browse files
committed
fix(automl): fix TypeError when passing a client_info to automl TablesClient
1 parent 80f5295 commit 330bcde

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

automl/google/cloud/automl_v1beta1/tables/tables_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,18 @@ def __init__(
104104
else:
105105
client_info_.user_agent = user_agent
106106
client_info_.gapic_version = version
107+
kwargs["client_info"] = client_info_
107108

108109
if client is None:
109110
self.auto_ml_client = gapic.auto_ml_client.AutoMlClient(
110-
credentials=credentials, client_info=client_info_, **kwargs
111+
credentials=credentials, **kwargs
111112
)
112113
else:
113114
self.auto_ml_client = client
114115

115116
if prediction_client is None:
116117
self.prediction_client = gapic.prediction_service_client.PredictionServiceClient(
117-
credentials=credentials, client_info=client_info_, **kwargs
118+
credentials=credentials, **kwargs
118119
)
119120
else:
120121
self.prediction_client = prediction_client

automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,3 +1424,14 @@ def test_prediction_client_credentials(self):
14241424
_, prediction_client_kwargs = MockPredictionClient.call_args
14251425
assert "credentials" in prediction_client_kwargs
14261426
assert prediction_client_kwargs["credentials"] == credentials_mock
1427+
1428+
def test_prediction_client_client_info(self):
1429+
client_info_mock = mock.Mock()
1430+
patch_prediction_client = mock.patch(
1431+
"google.cloud.automl_v1beta1.gapic.prediction_service_client.PredictionServiceClient"
1432+
)
1433+
with patch_prediction_client as MockPredictionClient:
1434+
client = automl_v1beta1.TablesClient(client_info=client_info_mock)
1435+
_, prediction_client_kwargs = MockPredictionClient.call_args
1436+
assert "client_info" in prediction_client_kwargs
1437+
assert prediction_client_kwargs["client_info"] == client_info_mock

0 commit comments

Comments
 (0)