Skip to content

Commit ff4755c

Browse files
authored
Create/list model docstrings (googleapis#10)
1 parent 89510df commit ff4755c

File tree

1 file changed

+95
-7
lines changed
  • automl/google/cloud/automl_v1beta1/helper

1 file changed

+95
-7
lines changed

automl/google/cloud/automl_v1beta1/helper/tables.py

Lines changed: 95 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -591,10 +591,10 @@ def update_column_spec(self, dataset=None, dataset_display_name=None,
591591
If you have initialized the client with a value for `region` it
592592
will be used if this parameter is not supplied.
593593
column_spec_name (Optional[string]):
594-
The name AutoML-assigned name for the column you want to
594+
The name AutoML-assigned name for the column you want to
595595
update.
596596
column_spec_display_name (Optional[string]):
597-
The human-readable name of the column you want to update. If
597+
The human-readable name of the column you want to update. If
598598
this is supplied in place of `column_spec_name`, you also
599599
need to provide either a way to lookup the source dataset
600600
(using one of the `dataset*` kwargs), or the `table_spec_name`
@@ -607,19 +607,19 @@ def update_column_spec(self, dataset=None, dataset_display_name=None,
607607
If no `table_spec_name` was provided, we use this index to
608608
determine which table to update column specs on.
609609
dataset_display_name (Optional[string]):
610-
The human-readable name given to the dataset you want to update
610+
The human-readable name given to the dataset you want to update
611611
specs on. If no `table_spec_name` is supplied, this will
612612
be used together with `table_spec_index` to infer the name of
613613
table to update specs on. This must be supplied if `table_spec_name`,
614614
`dataset` or `dataset_name` are not supplied.
615615
dataset_name (Optional[string]):
616-
The AutoML-assigned name given to the dataset you want to update
616+
The AutoML-assigned name given to the dataset you want to update
617617
specs one. If no `table_spec_name` is supplied, this will
618618
be used together with `table_spec_index` to infer the name of
619619
table to update specs on. This must be supplied if `table_spec_name`,
620620
`dataset` or `dataset_display_name` are not supplied.
621621
dataset (Optional[Dataset]):
622-
The `Dataset` instance you want to update
622+
The `Dataset` instance you want to update
623623
specs on. If no `table_spec_name` is supplied, this will
624624
be used together with `table_spec_index` to infer the name of
625625
table to update specs on. This must be supplied if `table_spec_name`,
@@ -699,7 +699,7 @@ def set_target_column(self, dataset=None, dataset_display_name=None,
699699
If you have initialized the client with a value for `region` it
700700
will be used if this parameter is not supplied.
701701
column_spec_name (Optional[string]):
702-
The name AutoML-assigned name for the column you want to
702+
The name AutoML-assigned name for the column you want to
703703
set as the target column.
704704
column_spec_display_name (Optional[string]):
705705
The human-readable name of the column you want to set as the
@@ -802,7 +802,7 @@ def set_weight_column(self, dataset=None, dataset_display_name=None,
802802
If you have initialized the client with a value for `region` it
803803
will be used if this parameter is not supplied.
804804
column_spec_name (Optional[string]):
805-
The name AutoML-assigned name for the column you want to
805+
The name AutoML-assigned name for the column you want to
806806
set as the weight column.
807807
column_spec_display_name (Optional[string]):
808808
The human-readable name of the column you want to set as the
@@ -879,6 +879,44 @@ def set_weight_column(self, dataset=None, dataset_display_name=None,
879879
return self.client.update_dataset(request)
880880

881881
def list_models(self, project=None, region=None):
882+
"""List all models in a particular project and region.
883+
884+
Example:
885+
>>> from google.cloud import automl_v1beta1
886+
>>>
887+
>>> client = automl_v1beta1.tables.ClientHelper(
888+
... client=automl_v1beta1.AutoMlClient(),
889+
... project='my-project', region='us-central1')
890+
>>>
891+
>>> ms = client.list_models()
892+
>>>
893+
>>> for m in ms:
894+
... # do something
895+
... pass
896+
897+
Args:
898+
project (Optional[string]):
899+
If you have initialized the client with a value for `project`
900+
it will be used if this parameter is not supplied. Keep in
901+
mind, the service account this client was initialized with must
902+
have access to this project.
903+
region (Optional[string]):
904+
If you have initialized the client with a value for `region` it
905+
will be used if this parameter is not supplied.
906+
907+
Returns:
908+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
909+
An iterable of :class:`~google.cloud.automl_v1beta1.types.Model`
910+
instances. You can also iterate over the pages of the response
911+
using its `pages` property.
912+
913+
Raises:
914+
google.api_core.exceptions.GoogleAPICallError: If the request
915+
failed for any reason.
916+
google.api_core.exceptions.RetryError: If the request failed due
917+
to a retryable error and retry attempts failed.
918+
ValueError: If required parameters are missing.
919+
"""
882920
return self.client.list_models(
883921
self.__location_path(project=project, region=region)
884922
)
@@ -887,6 +925,55 @@ def create_model(self, model_display_name, dataset=None,
887925
dataset_display_name=None, dataset_name=None,
888926
train_budget_milli_node_hours=None, project=None,
889927
region=None):
928+
"""Create a model. This will train your model on the given dataset.
929+
930+
Example:
931+
>>> from google.cloud import automl_v1beta1
932+
>>>
933+
>>> client = automl_v1beta1.tables.ClientHelper(
934+
... client=automl_v1beta1.AutoMlClient(),
935+
... project='my-project', region='us-central1')
936+
>>>
937+
>>> d = client.create_model('my_model', dataset_display_name='my_dataset')
938+
939+
Args:
940+
project (Optional[string]):
941+
If you have initialized the client with a value for `project`
942+
it will be used if this parameter is not supplied. Keep in
943+
mind, the service account this client was initialized with must
944+
have access to this project.
945+
region (Optional[string]):
946+
If you have initialized the client with a value for `region` it
947+
will be used if this parameter is not supplied.
948+
model_display_name (string):
949+
a human-readable name to refer to this model by.
950+
train_budget_milli_node_hours (int):
951+
The amount of time (in thousandths of an hour) to spend
952+
training. This value must be between 1,000 and 72,000 inclusive
953+
(between 1 and 72 hours).
954+
dataset_display_name (Optional[string]):
955+
The human-readable name given to the dataset you want to train
956+
your model on. This must be supplied if `dataset` or
957+
`dataset_name` are not supplied.
958+
dataset_name (Optional[string]):
959+
The AutoML-assigned name given to the dataset you want to train
960+
your model on. This must be supplied if `dataset_display_name`
961+
or `dataset` are not supplied.
962+
dataset (Optional[Dataset]):
963+
The `Dataset` instance you want to train your model on. This
964+
must be supplied if `dataset_display_name` or `dataset_name`
965+
are not supplied.
966+
967+
Returns:
968+
A :class:`~google.cloud.automl_v1beta1.types.Dataset` instance.
969+
970+
Raises:
971+
google.api_core.exceptions.GoogleAPICallError: If the request
972+
failed for any reason.
973+
google.api_core.exceptions.RetryError: If the request failed due
974+
to a retryable error and retry attempts failed.
975+
ValueError: If required parameters are missing.
976+
"""
890977
if train_budget_milli_node_hours is None:
891978
raise ValueError('\'train_budget_milli_node_hours\' must be a '
892979
'value between 1,000 and 72,000 inclusive')
@@ -930,6 +1017,7 @@ def get_model(self, project=None, region=None,
9301017
return next(m for m in self.list_models(project, region)
9311018
if m.name == model_name
9321019
or m.display_name == model_display_name)
1020+
9331021
#TODO(jonathanskim): allow deployment from just model ID
9341022
def deploy_model(self, model=None, model_name=None,
9351023
model_display_name=None, project=None, region=None):

0 commit comments

Comments
 (0)