Skip to content

Commit

Permalink
Fix client_info bug, update docstrings. (#6404)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpebot authored and tseaver committed Nov 6, 2018
1 parent 4b51f93 commit 42046d3
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 99 deletions.
115 changes: 52 additions & 63 deletions automl/google/cloud/automl_v1beta1/gapic/auto_ml_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ class AutoMlClient(object):
"""
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.
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}``.
``projects/{project_id}/locations/{location_id}/datasets/{dataset_id}``,
then the id for the item is ``{dataset_id}``.
"""

SERVICE_ADDRESS = 'automl.googleapis.com:443'
Expand Down Expand Up @@ -199,9 +199,10 @@ def __init__(self,
)

if client_info is None:
client_info = (
google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO)
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
gapic_version=_GAPIC_LIBRARY_VERSION, )
else:
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
self._client_info = client_info

# Parse out the default settings for retry and timeout for each RPC
Expand Down Expand Up @@ -234,14 +235,15 @@ def create_dataset(self,
>>>
>>> parent = client.location_path('[PROJECT]', '[LOCATION]')
>>>
>>> # TODO: Initialize ``dataset``:
>>> # TODO: Initialize `dataset`:
>>> dataset = {}
>>>
>>> response = client.create_dataset(parent, dataset)
Args:
parent (str): The resource name of the project to create the dataset for.
dataset (Union[dict, ~google.cloud.automl_v1beta1.types.Dataset]): The dataset to create.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.automl_v1beta1.types.Dataset`
retry (Optional[google.api_core.retry.Retry]): A retry object used
Expand Down Expand Up @@ -359,7 +361,7 @@ def list_datasets(self,
>>> # Alternatively:
>>>
>>> # Iterate over results one page at a time
>>> for page in client.list_datasets(parent, options=CallOptions(page_token=INITIAL_PAGE)):
>>> for page in client.list_datasets(parent).pages:
... for element in page:
... # process element
... pass
Expand All @@ -368,13 +370,12 @@ def list_datasets(self,
parent (str): The resource name of the project from which to list datasets.
filter_ (str): An expression for filtering the results of the request.
* ``dataset_metadata`` - for existence of the case.
- ``dataset_metadata`` - for existence of the case.
An example of using the filter is:
* ``translation_dataset_metadata:*`` --> The dataset has
::
translation_dataset_metadata.
- ``translation_dataset_metadata:*`` --> The dataset has
translation\_dataset\_metadata.
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
Expand Down Expand Up @@ -438,10 +439,8 @@ def delete_dataset(self,
timeout=google.api_core.gapic_v1.method.DEFAULT,
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
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.
Example:
Expand Down Expand Up @@ -511,8 +510,7 @@ def import_data(self,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None):
"""
Imports data into a dataset.
Returns an empty response in the
Imports data into a dataset. Returns an empty response in the
``response`` field when it completes.
Example:
Expand All @@ -522,7 +520,7 @@ def import_data(self,
>>>
>>> name = client.dataset_path('[PROJECT]', '[LOCATION]', '[DATASET]')
>>>
>>> # TODO: Initialize ``input_config``:
>>> # TODO: Initialize `input_config`:
>>> input_config = {}
>>>
>>> response = client.import_data(name, input_config)
Expand All @@ -540,6 +538,7 @@ def import_data(self,
name (str): Required. Dataset name. Dataset must already exist. All imported
annotations and examples will be added.
input_config (Union[dict, ~google.cloud.automl_v1beta1.types.InputConfig]): Required. The desired input location.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.automl_v1beta1.types.InputConfig`
retry (Optional[google.api_core.retry.Retry]): A retry object used
Expand Down Expand Up @@ -591,9 +590,8 @@ def export_data(self,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None):
"""
Exports dataset's data to a Google Cloud Storage bucket.
Returns an empty response in the
``response`` field when it completes.
Exports dataset's data to a Google Cloud Storage bucket. Returns an
empty response in the ``response`` field when it completes.
Example:
>>> from google.cloud import automl_v1beta1
Expand All @@ -602,7 +600,7 @@ def export_data(self,
>>>
>>> name = client.dataset_path('[PROJECT]', '[LOCATION]', '[DATASET]')
>>>
>>> # TODO: Initialize ``output_config``:
>>> # TODO: Initialize `output_config`:
>>> output_config = {}
>>>
>>> response = client.export_data(name, output_config)
Expand All @@ -619,6 +617,7 @@ def export_data(self,
Args:
name (str): Required. The resource name of the dataset.
output_config (Union[dict, ~google.cloud.automl_v1beta1.types.OutputConfig]): Required. The desired output location.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.automl_v1beta1.types.OutputConfig`
retry (Optional[google.api_core.retry.Retry]): A retry object used
Expand Down Expand Up @@ -670,11 +669,10 @@ def create_model(self,
timeout=google.api_core.gapic_v1.method.DEFAULT,
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.
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.
Example:
>>> from google.cloud import automl_v1beta1
Expand All @@ -683,7 +681,7 @@ def create_model(self,
>>>
>>> parent = client.location_path('[PROJECT]', '[LOCATION]')
>>>
>>> # TODO: Initialize ``model``:
>>> # TODO: Initialize `model`:
>>> model = {}
>>>
>>> response = client.create_model(parent, model)
Expand All @@ -700,6 +698,7 @@ def create_model(self,
Args:
parent (str): Resource name of the parent project where the model is being created.
model (Union[dict, ~google.cloud.automl_v1beta1.types.Model]): The model to create.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.automl_v1beta1.types.Model`
retry (Optional[google.api_core.retry.Retry]): A retry object used
Expand Down Expand Up @@ -823,7 +822,7 @@ def list_models(self,
>>> # Alternatively:
>>>
>>> # Iterate over results one page at a time
>>> for page in client.list_models(parent, options=CallOptions(page_token=INITIAL_PAGE)):
>>> for page in client.list_models(parent).pages:
... for element in page:
... # process element
... pass
Expand All @@ -832,17 +831,15 @@ def list_models(self,
parent (str): Resource name of the project, from which to list the models.
filter_ (str): An expression for filtering the results of the request.
* ``model_metadata`` - for existence of the case.
* ``dataset_id`` - for = or !=.
- ``model_metadata`` - for existence of the case.
- ``dataset_id`` - for = or !=.
Some examples of using the filter are:
* ``image_classification_model_metadata:*`` --> The model has
::
image_classification_model_metadata.
* ``dataset_id=5`` --> The model was created from a sibling dataset with
::
ID 5.
- ``image_classification_model_metadata:*`` --> The model has
image\_classification\_model\_metadata.
- ``dataset_id=5`` --> The model was created from a sibling dataset
with ID 5.
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
Expand Down Expand Up @@ -905,13 +902,10 @@ def delete_model(self,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None):
"""
Deletes a model.
If a model is already deployed, this only deletes the model in AutoML BE,
and does not change the status of the deployed model in the production
environment.
Returns ``google.protobuf.Empty`` in the
``response`` field when it completes,
and ``delete_details`` in the
Deletes a model. If a model is already deployed, this only deletes the
model in AutoML BE, and does not change the status of the deployed model
in the production environment. Returns ``google.protobuf.Empty`` in the
``response`` field when it completes, and ``delete_details`` in the
``metadata`` field.
Example:
Expand Down Expand Up @@ -980,9 +974,8 @@ def deploy_model(self,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None):
"""
Deploys model.
Returns a ``DeployModelResponse`` in the
``response`` field when it completes.
Deploys model. Returns a ``DeployModelResponse`` in the ``response``
field when it completes.
Example:
>>> from google.cloud import automl_v1beta1
Expand Down Expand Up @@ -1035,8 +1028,7 @@ def undeploy_model(self,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None):
"""
Undeploys model.
Returns an ``UndeployModelResponse`` in the
Undeploys model. Returns an ``UndeployModelResponse`` in the
``response`` field when it completes.
Example:
Expand Down Expand Up @@ -1164,29 +1156,26 @@ def list_model_evaluations(self,
>>> # Alternatively:
>>>
>>> # Iterate over results one page at a time
>>> for page in client.list_model_evaluations(parent, options=CallOptions(page_token=INITIAL_PAGE)):
>>> for page in client.list_model_evaluations(parent).pages:
... for element in page:
... # process element
... pass
Args:
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
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.
* ``annotation_spec_id`` - for =, != or existence. See example below for
::
the last.
- ``annotation_spec_id`` - for =, != or existence. See example below
for the last.
Some examples of using the filter are:
* ``annotation_spec_id!=4`` --> The model evaluation was done for
::
annotation spec with ID different than 4.
* ``NOT annotation_spec_id:*`` --> The model evaluation was done for
::
aggregate of all annotation specs.
- ``annotation_spec_id!=4`` --> The model evaluation was done for
annotation spec with ID different than 4.
- ``NOT annotation_spec_id:*`` --> The model evaluation was done for
aggregate of all annotation specs.
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ def __init__(self,
)

if client_info is None:
client_info = (
google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO)
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
gapic_version=_GAPIC_LIBRARY_VERSION, )
else:
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
self._client_info = client_info

# Parse out the default settings for retry and timeout for each RPC
Expand Down Expand Up @@ -183,7 +184,7 @@ def predict(self,
>>>
>>> name = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]')
>>>
>>> # TODO: Initialize ``payload``:
>>> # TODO: Initialize `payload`:
>>> payload = {}
>>>
>>> response = client.predict(name, payload)
Expand All @@ -193,19 +194,17 @@ def predict(self,
payload (Union[dict, ~google.cloud.automl_v1beta1.types.ExamplePayload]): Required.
Payload to perform a prediction on. The payload must match the
problem type that the model was trained to solve.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.automl_v1beta1.types.ExamplePayload`
params (dict[str -> str]): Additional domain-specific parameters, any string must be up to 25000
characters long.
* For Image Classification:
- For Image Classification:
``score_threshold`` - (float) A value from 0.0 to 1.0. When the model
makes predictions for an
image, it will only produce results that have at least this confidence
score threshold. The default is 0.5.
makes predictions for an image, it will only produce results that
have at least this confidence score threshold. The default is 0.5.
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will not
be retried.
Expand Down
Loading

0 comments on commit 42046d3

Please sign in to comment.