From 330bcdedb0fa22a71053ebb2cc108afbf55b7b19 Mon Sep 17 00:00:00 2001 From: Victor Mota Date: Mon, 9 Dec 2019 19:36:01 +0000 Subject: [PATCH 1/3] fix(automl): fix TypeError when passing a client_info to automl TablesClient --- .../cloud/automl_v1beta1/tables/tables_client.py | 5 +++-- .../unit/gapic/v1beta1/test_tables_client_v1beta1.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/automl/google/cloud/automl_v1beta1/tables/tables_client.py b/automl/google/cloud/automl_v1beta1/tables/tables_client.py index 668e1e55cbe5..85c708fe1dfd 100644 --- a/automl/google/cloud/automl_v1beta1/tables/tables_client.py +++ b/automl/google/cloud/automl_v1beta1/tables/tables_client.py @@ -104,17 +104,18 @@ def __init__( else: client_info_.user_agent = user_agent client_info_.gapic_version = version + kwargs["client_info"] = client_info_ if client is None: self.auto_ml_client = gapic.auto_ml_client.AutoMlClient( - credentials=credentials, client_info=client_info_, **kwargs + credentials=credentials, **kwargs ) else: self.auto_ml_client = client if prediction_client is None: self.prediction_client = gapic.prediction_service_client.PredictionServiceClient( - credentials=credentials, client_info=client_info_, **kwargs + credentials=credentials, **kwargs ) else: self.prediction_client = prediction_client diff --git a/automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py b/automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py index 3f2b6d3de2bd..c4e66c9ebb99 100644 --- a/automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py +++ b/automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py @@ -1424,3 +1424,14 @@ def test_prediction_client_credentials(self): _, prediction_client_kwargs = MockPredictionClient.call_args assert "credentials" in prediction_client_kwargs assert prediction_client_kwargs["credentials"] == credentials_mock + + def test_prediction_client_client_info(self): + client_info_mock = mock.Mock() + patch_prediction_client = mock.patch( + "google.cloud.automl_v1beta1.gapic.prediction_service_client.PredictionServiceClient" + ) + with patch_prediction_client as MockPredictionClient: + client = automl_v1beta1.TablesClient(client_info=client_info_mock) + _, prediction_client_kwargs = MockPredictionClient.call_args + assert "client_info" in prediction_client_kwargs + assert prediction_client_kwargs["client_info"] == client_info_mock From 6eb6fc7bcc0a27ff39728962c4b77d4ad8e70f3c Mon Sep 17 00:00:00 2001 From: Victor Mota Date: Thu, 12 Dec 2019 23:14:14 +0000 Subject: [PATCH 2/3] fix(automl): delete client_info from kwargs instead and pass named parameter. --- automl/google/cloud/automl_v1beta1/tables/tables_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/automl/google/cloud/automl_v1beta1/tables/tables_client.py b/automl/google/cloud/automl_v1beta1/tables/tables_client.py index 85c708fe1dfd..eb382c3ee35e 100644 --- a/automl/google/cloud/automl_v1beta1/tables/tables_client.py +++ b/automl/google/cloud/automl_v1beta1/tables/tables_client.py @@ -104,18 +104,18 @@ def __init__( else: client_info_.user_agent = user_agent client_info_.gapic_version = version - kwargs["client_info"] = client_info_ + kwargs.pop("client_info", None) if client is None: self.auto_ml_client = gapic.auto_ml_client.AutoMlClient( - credentials=credentials, **kwargs + credentials=credentials, client_info=client_info_, **kwargs ) else: self.auto_ml_client = client if prediction_client is None: self.prediction_client = gapic.prediction_service_client.PredictionServiceClient( - credentials=credentials, **kwargs + credentials=credentials, client_info=client_info_, **kwargs ) else: self.prediction_client = prediction_client From 402857ff5cffe9da3c800c73ab4c2c5fe85eb306 Mon Sep 17 00:00:00 2001 From: Victor Mota Date: Tue, 17 Dec 2019 02:37:34 +0000 Subject: [PATCH 3/3] fix format --- automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py b/automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py index c4e66c9ebb99..ce513083d19c 100644 --- a/automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py +++ b/automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py @@ -1424,7 +1424,7 @@ def test_prediction_client_credentials(self): _, prediction_client_kwargs = MockPredictionClient.call_args assert "credentials" in prediction_client_kwargs assert prediction_client_kwargs["credentials"] == credentials_mock - + def test_prediction_client_client_info(self): client_info_mock = mock.Mock() patch_prediction_client = mock.patch(