AutoMlClient(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=None,
)
AutoML Server API.
The resource names are assigned by the server. The server never reuses names that it has created after the resources with those names are deleted.
An ID of a resource is the last element of the item's resource name. For
projects/{project_id}/locations/{location_id}/datasets/{dataset_id}
,
then the id for the item is {dataset_id}
.
Currently the only supported location_id
is "us-central1".
On any input that is documented to expect a string parameter in snake_case or kebab-case, either of those cases is accepted.
Methods
AutoMlClient
AutoMlClient(
transport=None,
channel=None,
credentials=None,
client_config=None,
client_info=None,
client_options=None,
)
Constructor.
Name | Description |
channel |
grpc.Channel
DEPRECATED. A |
credentials |
google.auth.credentials.Credentials
The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to |
client_config |
dict
DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used. |
client_info |
google.api_core.gapic_v1.client_info.ClientInfo
The client info used to send a user-agent string along with API requests. If |
client_options |
Union[dict, google.api_core.client_options.ClientOptions]
Client options used to set user options on the client. API Endpoint should be set through client_options. |
create_dataset
create_dataset(parent, dataset, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Creates a dataset.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
parent = client.location_path('[PROJECT]', '[LOCATION]')
TODO: Initialize
dataset
:dataset = {}
response = client.create_dataset(parent, dataset)
def callback(operation_future): ... # Handle result. ... result = operation_future.result()
response.add_done_callback(callback)
Handle metadata.
metadata = response.metadata()
Name | Description |
parent |
str
The resource name of the project to create the dataset for. |
dataset |
Union[dict, Dataset]
The dataset to create. If a dict is provided, it must be of the same form as the protobuf message Dataset |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
create_model
create_model(parent, model, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Creates a model. Returns a Model in the response
field when it
completes. When you create a model, several model evaluations are
created for it: a global evaluation, and one evaluation for each
annotation spec.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
parent = client.location_path('[PROJECT]', '[LOCATION]')
TODO: Initialize
model
:model = {}
response = client.create_model(parent, model)
def callback(operation_future): ... # Handle result. ... result = operation_future.result()
response.add_done_callback(callback)
Handle metadata.
metadata = response.metadata()
Name | Description |
parent |
str
Resource name of the parent project where the model is being created. |
model |
Union[dict, Model]
The model to create. If a dict is provided, it must be of the same form as the protobuf message Model |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
dataset_path
dataset_path(project, location, dataset)
Return a fully-qualified dataset string.
delete_dataset
delete_dataset(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Deletes a dataset and all of its contents. Returns empty response in the
response
field when it completes, and delete_details
in the
metadata
field.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
name = client.dataset_path('[PROJECT]', '[LOCATION]', '[DATASET]')
response = client.delete_dataset(name)
def callback(operation_future): ... # Handle result. ... result = operation_future.result()
response.add_done_callback(callback)
Handle metadata.
metadata = response.metadata()
Name | Description |
name |
str
The resource name of the dataset to delete. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
delete_model
delete_model(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Deletes a model. Returns google.protobuf.Empty
in the response
field when it completes, and delete_details
in the metadata
field.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
name = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')
response = client.delete_model(name)
def callback(operation_future): ... # Handle result. ... result = operation_future.result()
response.add_done_callback(callback)
Handle metadata.
metadata = response.metadata()
Name | Description |
name |
str
Resource name of the model being deleted. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
export_data
export_data(name, output_config, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Exports dataset's data to the provided output location. Returns an empty
response in the response
field when it completes.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
name = client.dataset_path('[PROJECT]', '[LOCATION]', '[DATASET]')
TODO: Initialize
output_config
:output_config = {}
response = client.export_data(name, output_config)
def callback(operation_future): ... # Handle result. ... result = operation_future.result()
response.add_done_callback(callback)
Handle metadata.
metadata = response.metadata()
Name | Description |
name |
str
Required. The resource name of the dataset. |
output_config |
Union[dict, OutputConfig]
Required. The desired output location. If a dict is provided, it must be of the same form as the protobuf message OutputConfig |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
from_service_account_file
from_service_account_file(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Name | Description |
filename |
str
The path to the service account private key json file. |
Type | Description |
AutoMlClient | The constructed client. |
from_service_account_json
from_service_account_json(filename, *args, **kwargs)
Creates an instance of this client using the provided credentials file.
Name | Description |
filename |
str
The path to the service account private key json file. |
Type | Description |
AutoMlClient | The constructed client. |
get_dataset
get_dataset(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Gets a dataset.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
name = client.dataset_path('[PROJECT]', '[LOCATION]', '[DATASET]')
response = client.get_dataset(name)
Name | Description |
name |
str
The resource name of the dataset to retrieve. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
get_model
get_model(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Gets a model.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
name = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')
response = client.get_model(name)
Name | Description |
name |
str
Resource name of the model. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
get_model_evaluation
get_model_evaluation(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Gets a model evaluation.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
name = client.model_evaluation_path('[PROJECT]', '[LOCATION]', '[MODEL]', '[MODEL_EVALUATION]')
response = client.get_model_evaluation(name)
Name | Description |
name |
str
Resource name for the model evaluation. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
import_data
import_data(name, input_config, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Imports data into a dataset.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
name = client.dataset_path('[PROJECT]', '[LOCATION]', '[DATASET]')
TODO: Initialize
input_config
:input_config = {}
response = client.import_data(name, input_config)
def callback(operation_future): ... # Handle result. ... result = operation_future.result()
response.add_done_callback(callback)
Handle metadata.
metadata = response.metadata()
Name | Description |
name |
str
Required. Dataset name. Dataset must already exist. All imported annotations and examples will be added. |
input_config |
Union[dict, InputConfig]
Required. The desired input location and its domain specific semantics, if any. If a dict is provided, it must be of the same form as the protobuf message InputConfig |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
list_datasets
list_datasets(parent, filter_=None, page_size=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Lists datasets in a project.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
parent = client.location_path('[PROJECT]', '[LOCATION]')
Iterate over all results
for element in client.list_datasets(parent): ... # process element ... pass
Alternatively:
Iterate over results one page at a time
for page in client.list_datasets(parent).pages: ... for element in page: ... # process element ... pass
Name | Description |
parent |
str
The resource name of the project from which to list datasets. |
filter_ |
str
An expression for filtering the results of the request. - |
page_size |
int
The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
list_model_evaluations
list_model_evaluations(parent, filter_, page_size=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Lists model evaluations.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
parent = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')
TODO: Initialize
filter_
:filter_ = ''
Iterate over all results
for element in client.list_model_evaluations(parent, filter_): ... # process element ... pass
Alternatively:
Iterate over results one page at a time
for page in client.list_model_evaluations(parent, filter_).pages: ... for element in page: ... # process element ... pass
Name | Description |
parent |
str
Resource name of the model to list the model evaluations for. If modelId is set as "-", this will list model evaluations from across all models of the parent location. |
filter_ |
str
An expression for filtering the results of the request. - |
page_size |
int
The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
list_models
list_models(parent, filter_=None, page_size=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Lists models.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
parent = client.location_path('[PROJECT]', '[LOCATION]')
Iterate over all results
for element in client.list_models(parent): ... # process element ... pass
Alternatively:
Iterate over results one page at a time
for page in client.list_models(parent).pages: ... for element in page: ... # process element ... pass
Name | Description |
parent |
str
Resource name of the project, from which to list the models. |
filter_ |
str
An expression for filtering the results of the request. - |
page_size |
int
The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page. |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
location_path
location_path(project, location)
Return a fully-qualified location string.
model_evaluation_path
model_evaluation_path(project, location, model, model_evaluation)
Return a fully-qualified model_evaluation string.
model_path
model_path(project, location, model)
Return a fully-qualified model string.
update_dataset
update_dataset(dataset, update_mask, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Updates a dataset.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
TODO: Initialize
dataset
:dataset = {}
TODO: Initialize
update_mask
:update_mask = {}
response = client.update_dataset(dataset, update_mask)
Name | Description |
dataset |
Union[dict, Dataset]
The dataset which replaces the resource on the server. If a dict is provided, it must be of the same form as the protobuf message Dataset |
update_mask |
Union[dict, FieldMask]
Required. The update mask applies to the resource. If a dict is provided, it must be of the same form as the protobuf message FieldMask |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |
update_model
update_model(model, update_mask, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)
Updates a model.
.. rubric:: Example
from google.cloud import automl_v1
client = automl_v1.AutoMlClient()
TODO: Initialize
model
:model = {}
TODO: Initialize
update_mask
:update_mask = {}
response = client.update_model(model, update_mask)
Name | Description |
model |
Union[dict, Model]
The model which replaces the resource on the server. If a dict is provided, it must be of the same form as the protobuf message Model |
update_mask |
Union[dict, FieldMask]
Required. The update mask applies to the resource. If a dict is provided, it must be of the same form as the protobuf message FieldMask |
retry |
Optional[google.api_core.retry.Retry]
A retry object used to retry requests. If |
timeout |
Optional[float]
The amount of time, in seconds, to wait for the request to complete. Note that if |
metadata |
Optional[Sequence[Tuple[str, str]]]
Additional metadata that is provided to the method. |
Type | Description |
google.api_core.exceptions.GoogleAPICallError | If the request failed for any reason. |
google.api_core.exceptions.RetryError | If the request failed due to a retryable error and retry attempts failed. |
ValueError | If the parameters are invalid. |