Content-Length: 368397 | pFad | http://github.com/googleapis/google-cloud-python/pull/9058/files

FD AutoML Tables: Log when LROs are kicked off. by lwander · Pull Request #9058 · googleapis/google-cloud-python · GitHub
Skip to content

AutoML Tables: Log when LROs are kicked off. #9058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 49 additions & 8 deletions automl/google/cloud/automl_v1beta1/tables/tables_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
"""A tables helper for the google.cloud.automl_v1beta1 AutoML API"""

import pkg_resources
import logging

from google.api_core.gapic_v1 import client_info
from google.api_core import exceptions
from google.cloud.automl_v1beta1 import gapic
from google.cloud.automl_v1beta1.proto import data_types_pb2

_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution("google-cloud-automl").version
_LOGGER = logging.getLogger(__name__)


class TablesClient(object):
Expand Down Expand Up @@ -290,6 +292,29 @@ def __model_name_from_args(
)
return model_name

def __log_operation_info(self, message, op):
name = "UNKNOWN"
try:
if (
op is not None
and op.operation is not None
and op.operation.name is not None
):
name = op.operation.name
except AttributeError:
pass
_LOGGER.info(
(
"Operation '{}' is running in the background. The returned "
"Operation '{}' can be used to query or block on the status "
"of this operation. Ending your python session will _not_ "
"cancel this operation. Read the documentation here:\n\n"
"\thttps://googleapis.dev/python/google-api-core/latest/operation.html\n\n"
"for more information on the Operation class."
).format(message, name)
)
return op

def __column_spec_name_from_args(
self,
dataset=None,
Expand Down Expand Up @@ -598,7 +623,9 @@ def delete_dataset(
except exceptions.NotFound:
return None

return self.auto_ml_client.delete_dataset(dataset_name, **kwargs)
op = self.auto_ml_client.delete_dataset(dataset_name, **kwargs)
self.__log_operation_info("Delete dataset", op)
return op

def import_data(
self,
Expand Down Expand Up @@ -694,7 +721,9 @@ def import_data(
"One of 'gcs_input_uris', or " "'bigquery_input_uri' must be set."
)

return self.auto_ml_client.import_data(dataset_name, request, **kwargs)
op = self.auto_ml_client.import_data(dataset_name, request, **kwargs)
self.__log_operation_info("Data import", op)
return op

def export_data(
self,
Expand Down Expand Up @@ -787,7 +816,9 @@ def export_data(
"One of 'gcs_output_uri_prefix', or 'bigquery_output_uri' must be set."
)

return self.auto_ml_client.export_data(dataset_name, request, **kwargs)
op = self.auto_ml_client.export_data(dataset_name, request, **kwargs)
self.__log_operation_info("Export data", op)
return op

def get_table_spec(self, table_spec_name, project=None, region=None, **kwargs):
"""Gets a single table spec in a particular project and region.
Expand Down Expand Up @@ -2134,9 +2165,11 @@ def create_model(
"tables_model_metadata": model_metadata,
}

return self.auto_ml_client.create_model(
op = self.auto_ml_client.create_model(
self.__location_path(project=project, region=region), request, **kwargs
)
self.__log_operation_info("Model creation", op)
return op

def delete_model(
self,
Expand Down Expand Up @@ -2210,7 +2243,9 @@ def delete_model(
except exceptions.NotFound:
return None

return self.auto_ml_client.delete_model(model_name, **kwargs)
op = self.auto_ml_client.delete_model(model_name, **kwargs)
self.__log_operation_info("Delete model", op)
return op

def get_model_evaluation(
self, model_evaluation_name, project=None, region=None, **kwargs
Expand Down Expand Up @@ -2400,7 +2435,9 @@ def deploy_model(
**kwargs
)

return self.auto_ml_client.deploy_model(model_name, **kwargs)
op = self.auto_ml_client.deploy_model(model_name, **kwargs)
self.__log_operation_info("Deploy model", op)
return op

def undeploy_model(
self,
Expand Down Expand Up @@ -2469,7 +2506,9 @@ def undeploy_model(
**kwargs
)

return self.auto_ml_client.undeploy_model(model_name, **kwargs)
op = self.auto_ml_client.undeploy_model(model_name, **kwargs)
self.__log_operation_info("Undeploy model", op)
return op

## TODO(lwander): support pandas DataFrame as input type
def predict(
Expand Down Expand Up @@ -2677,6 +2716,8 @@ def batch_predict(
"One of 'gcs_output_uri_prefix'/'bigquery_output_uri' must be set"
)

return self.prediction_client.batch_predict(
op = self.prediction_client.batch_predict(
model_name, input_request, output_request, **kwargs
)
self.__log_operation_info("Batch predict", op)
return op








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/googleapis/google-cloud-python/pull/9058/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy