diff --git a/CHANGELOG.md b/CHANGELOG.md index dbe59c44..9a65baa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,21 @@ [1]: https://pypi.org/project/google-cloud-automl/#history +## 0.9.0 + +11-18-2019 09:49 PST + +### Implementation Changes +- Change proto imports (via synth). ([#9817](https://github.com/googleapis/google-cloud-python/pull/9817)) +- Pass params passed to `tables_client` to underlying client. ([#9794](https://github.com/googleapis/google-cloud-python/pull/9794)) + +### New Features +- Add support for `feature_importance` to `TablesClient`. ([#9816](https://github.com/googleapis/google-cloud-python/pull/9816)) + +### Documentation +- Fix typo in code example for AutoML Tables. ([#9806](https://github.com/googleapis/google-cloud-python/pull/9806)) +- Update docs templates (via synth). ([#9797](https://github.com/googleapis/google-cloud-python/pull/9797)) + ## 0.8.0 11-13-2019 13:44 PST diff --git a/docs/_static/custom.css b/docs/_static/custom.css index 9a6f9f8d..0abaf229 100644 --- a/docs/_static/custom.css +++ b/docs/_static/custom.css @@ -1,4 +1,4 @@ div#python2-eol { border-color: red; border-width: medium; -} \ No newline at end of file +} \ No newline at end of file diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html index de457b2c..228529ef 100644 --- a/docs/_templates/layout.html +++ b/docs/_templates/layout.html @@ -1,3 +1,4 @@ + {% extends "!layout.html" %} {%- block content %} {%- if theme_fixed_sidebar|lower == 'true' %} diff --git a/docs/conf.py b/docs/conf.py index be6b89f7..9ac18387 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -164,7 +164,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] +# html_static_path = [] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied @@ -344,7 +344,7 @@ "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), "google.api_core": ("https://googleapis.dev/python/google-api-core/latest", None), "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("https://requests.readthedocs.org/en/latest", None), + "requests": ("https://requests.kennethreitz.org/en/master/", None), "fastavro": ("https://fastavro.readthedocs.io/en/stable/", None), "pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None), } diff --git a/google/cloud/automl_v1/proto/operations.proto b/google/cloud/automl_v1/proto/operations.proto index e89fad17..dfe20eb4 100644 --- a/google/cloud/automl_v1/proto/operations.proto +++ b/google/cloud/automl_v1/proto/operations.proto @@ -19,11 +19,6 @@ package google.cloud.automl.v1; import "google/cloud/automl/v1/dataset.proto"; import "google/cloud/automl/v1/io.proto"; -import "google/cloud/automl/v1/model.proto"; -import "google/cloud/automl/v1/model_evaluation.proto"; -import "google/cloud/automl/v1/prediction_service.proto"; -import "google/cloud/automl/v1/service.proto"; -import "google/protobuf/empty.proto"; import "google/protobuf/timestamp.proto"; import "google/rpc/status.proto"; import "google/api/annotations.proto"; diff --git a/google/cloud/automl_v1/proto/operations_pb2.py b/google/cloud/automl_v1/proto/operations_pb2.py index fab52cdc..0dc1e0e2 100644 --- a/google/cloud/automl_v1/proto/operations_pb2.py +++ b/google/cloud/automl_v1/proto/operations_pb2.py @@ -21,19 +21,6 @@ from google.cloud.automl_v1.proto import ( io_pb2 as google_dot_cloud_dot_automl__v1_dot_proto_dot_io__pb2, ) -from google.cloud.automl_v1.proto import ( - model_pb2 as google_dot_cloud_dot_automl__v1_dot_proto_dot_model__pb2, -) -from google.cloud.automl_v1.proto import ( - model_evaluation_pb2 as google_dot_cloud_dot_automl__v1_dot_proto_dot_model__evaluation__pb2, -) -from google.cloud.automl_v1.proto import ( - prediction_service_pb2 as google_dot_cloud_dot_automl__v1_dot_proto_dot_prediction__service__pb2, -) -from google.cloud.automl_v1.proto import ( - service_pb2 as google_dot_cloud_dot_automl__v1_dot_proto_dot_service__pb2, -) -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 from google.rpc import status_pb2 as google_dot_rpc_dot_status__pb2 from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 @@ -47,16 +34,11 @@ "\n\032com.google.cloud.automl.v1P\001Z/v1/{name=projects/*/locations/*/datasets/*/annotationSpecs/*}\x12\x93\x01\n\x0b\x43reateModel\x12*.google.cloud.automl.v1.CreateModelRequest\x1a\x1d.google.longrunning.Operation"9\x82\xd3\xe4\x93\x02\x33"*/v1/{parent=projects/*/locations/*}/models:\x05model\x12\x86\x01\n\x08GetModel\x12\'.google.cloud.automl.v1.GetModelRequest\x1a\x1d.google.cloud.automl.v1.Model"2\x82\xd3\xe4\x93\x02,\x12*/v1/{name=projects/*/locations/*/models/*}\x12\x97\x01\n\nListModels\x12).google.cloud.automl.v1.ListModelsRequest\x1a*.google.cloud.automl.v1.ListModelsResponse"2\x82\xd3\xe4\x93\x02,\x12*/v1/{parent=projects/*/locations/*}/models\x12\x8c\x01\n\x0b\x44\x65leteModel\x12*.google.cloud.automl.v1.DeleteModelRequest\x1a\x1d.google.longrunning.Operation"2\x82\xd3\xe4\x93\x02,**/v1/{name=projects/*/locations/*/models/*}\x12\x99\x01\n\x0bUpdateModel\x12*.google.cloud.automl.v1.UpdateModelRequest\x1a\x1d.google.cloud.automl.v1.Model"?\x82\xd3\xe4\x93\x02\x39\x32\x30/v1/{model.name=projects/*/locations/*/models/*}:\x05model\x12\x96\x01\n\x0b\x44\x65ployModel\x12*.google.cloud.automl.v1.DeployModelRequest\x1a\x1d.google.longrunning.Operation"<\x82\xd3\xe4\x93\x02\x36"1/v1/{name=projects/*/locations/*/models/*}:deploy:\x01*\x12\x9c\x01\n\rUndeployModel\x12,.google.cloud.automl.v1.UndeployModelRequest\x1a\x1d.google.longrunning.Operation">\x82\xd3\xe4\x93\x02\x38"3/v1/{name=projects/*/locations/*/models/*}:undeploy:\x01*\x12\x96\x01\n\x0b\x45xportModel\x12*.google.cloud.automl.v1.ExportModelRequest\x1a\x1d.google.longrunning.Operation"<\x82\xd3\xe4\x93\x02\x36"1/v1/{name=projects/*/locations/*/models/*}:export:\x01*\x12\xb7\x01\n\x12GetModelEvaluation\x12\x31.google.cloud.automl.v1.GetModelEvaluationRequest\x1a\'.google.cloud.automl.v1.ModelEvaluation"E\x82\xd3\xe4\x93\x02?\x12=/v1/{name=projects/*/locations/*/models/*/modelEvaluations/*}\x12\xc8\x01\n\x14ListModelEvaluations\x12\x33.google.cloud.automl.v1.ListModelEvaluationsRequest\x1a\x34.google.cloud.automl.v1.ListModelEvaluationsResponse"E\x82\xd3\xe4\x93\x02?\x12=/v1/{parent=projects/*/locations/*/models/*}/modelEvaluations\x1aI\xca\x41\x15\x61utoml.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xb7\x01\n\x1a\x63om.google.cloud.automl.v1B\x0b\x41utoMlProtoP\x01Z/v1/{name=projects/*/locations/*/datasets/*/annotationSpecs/*}\x12\x93\x01\n\x0b\x43reateModel\x12*.google.cloud.automl.v1.CreateModelRequest\x1a\x1d.google.longrunning.Operation"9\x82\xd3\xe4\x93\x02\x33"*/v1/{parent=projects/*/locations/*}/models:\x05model\x12\x86\x01\n\x08GetModel\x12\'.google.cloud.automl.v1.GetModelRequest\x1a\x1d.google.cloud.automl.v1.Model"2\x82\xd3\xe4\x93\x02,\x12*/v1/{name=projects/*/locations/*/models/*}\x12\x97\x01\n\nListModels\x12).google.cloud.automl.v1.ListModelsRequest\x1a*.google.cloud.automl.v1.ListModelsResponse"2\x82\xd3\xe4\x93\x02,\x12*/v1/{parent=projects/*/locations/*}/models\x12\x8c\x01\n\x0b\x44\x65leteModel\x12*.google.cloud.automl.v1.DeleteModelRequest\x1a\x1d.google.longrunning.Operation"2\x82\xd3\xe4\x93\x02,**/v1/{name=projects/*/locations/*/models/*}\x12\x99\x01\n\x0bUpdateModel\x12*.google.cloud.automl.v1.UpdateModelRequest\x1a\x1d.google.cloud.automl.v1.Model"?\x82\xd3\xe4\x93\x02\x39\x32\x30/v1/{model.name=projects/*/locations/*/models/*}:\x05model\x12\x96\x01\n\x0b\x44\x65ployModel\x12*.google.cloud.automl.v1.DeployModelRequest\x1a\x1d.google.longrunning.Operation"<\x82\xd3\xe4\x93\x02\x36"1/v1/{name=projects/*/locations/*/models/*}:deploy:\x01*\x12\x9c\x01\n\rUndeployModel\x12,.google.cloud.automl.v1.UndeployModelRequest\x1a\x1d.google.longrunning.Operation">\x82\xd3\xe4\x93\x02\x38"3/v1/{name=projects/*/locations/*/models/*}:undeploy:\x01*\x12\x96\x01\n\x0b\x45xportModel\x12*.google.cloud.automl.v1.ExportModelRequest\x1a\x1d.google.longrunning.Operation"<\x82\xd3\xe4\x93\x02\x36"1/v1/{name=projects/*/locations/*/models/*}:export:\x01*\x12\xb7\x01\n\x12GetModelEvaluation\x12\x31.google.cloud.automl.v1.GetModelEvaluationRequest\x1a\'.google.cloud.automl.v1.ModelEvaluation"E\x82\xd3\xe4\x93\x02?\x12=/v1/{name=projects/*/locations/*/models/*/modelEvaluations/*}\x12\xc8\x01\n\x14ListModelEvaluations\x12\x33.google.cloud.automl.v1.ListModelEvaluationsRequest\x1a\x34.google.cloud.automl.v1.ListModelEvaluationsResponse"E\x82\xd3\xe4\x93\x02?\x12=/v1/{parent=projects/*/locations/*/models/*}/modelEvaluations\x1aI\xca\x41\x15\x61utoml.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xb7\x01\n\x1a\x63om.google.cloud.automl.v1B\x0b\x41utoMlProtoP\x01Z>> from google.oauth2 import service_account >>> >>> client = automl_v1beta1.TablesClient( - ... credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json') + ... credentials=service_account.Credentials.from_service_account_file('~/.gcp/account.json'), ... project='my-project', region='us-central1') ... @@ -2596,6 +2596,7 @@ def predict( model=None, model_name=None, model_display_name=None, + feature_importance=False, project=None, region=None, **kwargs @@ -2642,6 +2643,9 @@ def predict( The `model` instance you want to predict with . This must be supplied if `model_display_name` or `model_name` are not supplied. + feature_importance (bool): + True if enable feature importance explainability. The default is + False. Returns: A :class:`~google.cloud.automl_v1beta1.types.PredictResponse` @@ -2683,7 +2687,11 @@ def predict( request = {"row": {"values": values}} - return self.prediction_client.predict(model.name, request, **kwargs) + params = None + if feature_importance: + params = {"feature_importance": "true"} + + return self.prediction_client.predict(model.name, request, params, **kwargs) def batch_predict( self, diff --git a/setup.py b/setup.py index ce859547..eeabb7d6 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ name = "google-cloud-automl" description = "Cloud AutoML API client library" -version = "0.8.0" +version = "0.9.0" release_status = "Development Status :: 3 - Alpha" dependencies = [ "google-api-core[grpc] >= 1.14.0, < 2.0.0dev", diff --git a/synth.metadata b/synth.metadata index 92266b1b..885dba20 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,5 +1,5 @@ { - "updateTime": "2019-11-13T22:56:51.489853Z", + "updateTime": "2019-11-16T13:13:10.249431Z", "sources": [ { "generator": { @@ -12,8 +12,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "218164b3deba1075979c9dca5f71461379e42dd1", - "internalRef": "280279014" + "sha": "c89394342a9ef70acaf73a6959e04b943fbc817b", + "internalRef": "280761373" } }, { diff --git a/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py b/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py index 516a4b76..3f2b6d3d 100644 --- a/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py +++ b/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py @@ -1117,7 +1117,7 @@ def test_predict_from_array(self): client = self.tables_client({"get_model.return_value": model}, {}) client.predict(["1"], model_name="my_model") client.prediction_client.predict.assert_called_with( - "my_model", {"row": {"values": [{"string_value": "1"}]}} + "my_model", {"row": {"values": [{"string_value": "1"}]}}, None ) def test_predict_from_dict(self): @@ -1134,6 +1134,26 @@ def test_predict_from_dict(self): client.prediction_client.predict.assert_called_with( "my_model", {"row": {"values": [{"string_value": "1"}, {"string_value": "2"}]}}, + None, + ) + + def test_predict_from_dict_with_feature_importance(self): + data_type = mock.Mock(type_code=data_types_pb2.CATEGORY) + column_spec_a = mock.Mock(display_name="a", data_type=data_type) + column_spec_b = mock.Mock(display_name="b", data_type=data_type) + model_metadata = mock.Mock( + input_feature_column_specs=[column_spec_a, column_spec_b] + ) + model = mock.Mock() + model.configure_mock(tables_model_metadata=model_metadata, name="my_model") + client = self.tables_client({"get_model.return_value": model}, {}) + client.predict( + {"a": "1", "b": "2"}, model_name="my_model", feature_importance=True + ) + client.prediction_client.predict.assert_called_with( + "my_model", + {"row": {"values": [{"string_value": "1"}, {"string_value": "2"}]}}, + {"feature_importance": "true"}, ) def test_predict_from_dict_missing(self): @@ -1148,7 +1168,9 @@ def test_predict_from_dict_missing(self): client = self.tables_client({"get_model.return_value": model}, {}) client.predict({"a": "1"}, model_name="my_model") client.prediction_client.predict.assert_called_with( - "my_model", {"row": {"values": [{"string_value": "1"}, {"null_value": 0}]}} + "my_model", + {"row": {"values": [{"string_value": "1"}, {"null_value": 0}]}}, + None, ) def test_predict_all_types(self): @@ -1210,6 +1232,7 @@ def test_predict_all_types(self): ] } }, + None, ) def test_predict_from_array_missing(self):