From ff95db3eb9191951c4988ec2c33b42d02d216a7a Mon Sep 17 00:00:00 2001 From: shunghsiyu Date: Tue, 29 Oct 2019 03:20:27 +0900 Subject: [PATCH 1/2] fix(automl): pass credentials to underlying clients in TableClient (#9491) In automl_v1beta1.TablesClient.__init__(), the credentials are not given to AutoMlClient and PredictionServiceClient, causing inconsistency between the credentials that was passed and the credentials that was actually used for API calls. This commit ensures that credentials are passed, and add two unittests to catch the behavior. Fixes #9490 --- .../automl_v1beta1/tables/tables_client.py | 4 ++-- .../v1beta1/test_tables_client_v1beta1.py | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/google/cloud/automl_v1beta1/tables/tables_client.py b/google/cloud/automl_v1beta1/tables/tables_client.py index 16633936..7ecd1e6f 100644 --- a/google/cloud/automl_v1beta1/tables/tables_client.py +++ b/google/cloud/automl_v1beta1/tables/tables_client.py @@ -107,14 +107,14 @@ def __init__( if client is None: self.auto_ml_client = gapic.auto_ml_client.AutoMlClient( - client_info=client_info_, **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( - client_info=client_info_, **kwargs + credentials=credentials, client_info=client_info_, **kwargs ) else: self.prediction_client = prediction_client diff --git a/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py b/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py index 199df81c..516a4b76 100644 --- a/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py +++ b/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py @@ -1379,3 +1379,25 @@ def test_batch_predict_no_model(self): ) client.auto_ml_client.list_models.assert_not_called() client.prediction_client.batch_predict.assert_not_called() + + def test_auto_ml_client_credentials(self): + credentials_mock = mock.Mock() + patch_auto_ml_client = mock.patch( + "google.cloud.automl_v1beta1.gapic.auto_ml_client.AutoMlClient" + ) + with patch_auto_ml_client as MockAutoMlClient: + client = automl_v1beta1.TablesClient(credentials=credentials_mock) + _, auto_ml_client_kwargs = MockAutoMlClient.call_args + assert "credentials" in auto_ml_client_kwargs + assert auto_ml_client_kwargs["credentials"] == credentials_mock + + def test_prediction_client_credentials(self): + credentials_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(credentials=credentials_mock) + _, prediction_client_kwargs = MockPredictionClient.call_args + assert "credentials" in prediction_client_kwargs + assert prediction_client_kwargs["credentials"] == credentials_mock From a3373dcb4de07d3b9fe68aa8886fdcf1c86b91f4 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Wed, 30 Oct 2019 15:40:57 -0700 Subject: [PATCH 2/2] chore(automl): release 0.7.1 (#9566) --- CHANGELOG.md | 8 ++++++++ setup.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59b105e4..2534c944 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://pypi.org/project/google-cloud-automl/#history +## 0.7.1 + +10-29-2019 13:45 PDT + + +### Implementation Changes +- Pass credentials to underlying clients in TableClient ([#9491](https://github.com/googleapis/google-cloud-python/pull/9491)) + ## 0.7.0 10-04-2019 15:37 PDT diff --git a/setup.py b/setup.py index 6554c687..a810e86e 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ name = "google-cloud-automl" description = "Cloud AutoML API client library" -version = "0.7.0" +version = "0.7.1" release_status = "Development Status :: 3 - Alpha" dependencies = [ "google-api-core[grpc] >= 1.14.0, < 2.0.0dev",