Skip to content

Commit 89510df

Browse files
authored
Write docstrings for target & weight column updates (googleapis#9)
1 parent 34b225b commit 89510df

File tree

1 file changed

+142
-0
lines changed
  • automl/google/cloud/automl_v1beta1/helper

1 file changed

+142
-0
lines changed

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

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,77 @@ def set_target_column(self, dataset=None, dataset_display_name=None,
676676
dataset_name=None, table_spec_name=None, table_spec_index=0,
677677
column_spec_name=None, column_spec_display_name=None,
678678
project=None, region=None):
679+
"""Sets the target column for a given table.
680+
681+
Example:
682+
>>> from google.cloud import automl_v1beta1
683+
>>>
684+
>>> client = automl_v1beta1.tables.ClientHelper(
685+
... client=automl_v1beta1.AutoMlClient(),
686+
... project='my-project', region='us-central1')
687+
...
688+
>>> client.set_target_column(dataset_display_name='my_dataset',
689+
... column_spec_display_name='Income')
690+
>>>
691+
692+
Args:
693+
project (Optional[string]):
694+
If you have initialized the client with a value for `project`
695+
it will be used if this parameter is not supplied. Keep in
696+
mind, the service account this client was initialized with must
697+
have access to this project.
698+
region (Optional[string]):
699+
If you have initialized the client with a value for `region` it
700+
will be used if this parameter is not supplied.
701+
column_spec_name (Optional[string]):
702+
The name AutoML-assigned name for the column you want to
703+
set as the target column.
704+
column_spec_display_name (Optional[string]):
705+
The human-readable name of the column you want to set as the
706+
target column. If this is supplied in place of
707+
`column_spec_name`, you also need to provide either a way to
708+
lookup the source dataset (using one of the `dataset*` kwargs),
709+
or the `table_spec_name` of the table this column belongs to.
710+
table_spec_name (Optional[string]):
711+
The AutoML-assigned name for the table whose target column you
712+
want to set . If not supplied, the client can determine this
713+
name from a source `Dataset` object.
714+
table_spec_index (Optional[int]):
715+
If no `table_spec_name` or `column_spec_name` was provided, we
716+
use this index to determine which table to set the target
717+
column on.
718+
dataset_display_name (Optional[string]):
719+
The human-readable name given to the dataset you want to update
720+
the target column of. If no `table_spec_name` is supplied, this
721+
will be used together with `table_spec_index` to infer the name
722+
of table to update the target column of. This must be supplied
723+
if `table_spec_name`, `dataset` or `dataset_name` are not
724+
supplied.
725+
dataset_name (Optional[string]):
726+
The AutoML-assigned name given to the dataset you want to
727+
update the target column of. If no `table_spec_name` is
728+
supplied, this will be used together with `table_spec_index` to
729+
infer the name of table to update the target column of. This
730+
must be supplied if `table_spec_name`, `dataset` or
731+
`dataset_display_name` are not supplied.
732+
dataset (Optional[Dataset]):
733+
The `Dataset` instance you want to update the target column of.
734+
If no `table_spec_name` is supplied, this will be used together
735+
with `table_spec_index` to infer the name of table to update
736+
the target column of. This must be supplied if
737+
`table_spec_name`, `dataset_name` or `dataset_display_name` are
738+
not supplied.
739+
740+
Returns:
741+
A :class:`~google.cloud.automl_v1beta1.types.Dataset` instance.
742+
743+
Raises:
744+
google.api_core.exceptions.GoogleAPICallError: If the request
745+
failed for any reason.
746+
google.api_core.exceptions.RetryError: If the request failed due
747+
to a retryable error and retry attempts failed.
748+
ValueError: If required parameters are missing.
749+
"""
679750
column_spec_name = self.__column_spec_name_from_args(
680751
dataset=dataset,
681752
dataset_display_name=dataset_display_name,
@@ -708,6 +779,77 @@ def set_weight_column(self, dataset=None, dataset_display_name=None,
708779
dataset_name=None, table_spec_name=None, table_spec_index=0,
709780
column_spec_name=None, column_spec_display_name=None,
710781
project=None, region=None):
782+
"""Sets the weight column for a given table.
783+
784+
Example:
785+
>>> from google.cloud import automl_v1beta1
786+
>>>
787+
>>> client = automl_v1beta1.tables.ClientHelper(
788+
... client=automl_v1beta1.AutoMlClient(),
789+
... project='my-project', region='us-central1')
790+
...
791+
>>> client.set_weight_column(dataset_display_name='my_dataset',
792+
... column_spec_display_name='Income')
793+
>>>
794+
795+
Args:
796+
project (Optional[string]):
797+
If you have initialized the client with a value for `project`
798+
it will be used if this parameter is not supplied. Keep in
799+
mind, the service account this client was initialized with must
800+
have access to this project.
801+
region (Optional[string]):
802+
If you have initialized the client with a value for `region` it
803+
will be used if this parameter is not supplied.
804+
column_spec_name (Optional[string]):
805+
The name AutoML-assigned name for the column you want to
806+
set as the weight column.
807+
column_spec_display_name (Optional[string]):
808+
The human-readable name of the column you want to set as the
809+
weight column. If this is supplied in place of
810+
`column_spec_name`, you also need to provide either a way to
811+
lookup the source dataset (using one of the `dataset*` kwargs),
812+
or the `table_spec_name` of the table this column belongs to.
813+
table_spec_name (Optional[string]):
814+
The AutoML-assigned name for the table whose weight column you
815+
want to set . If not supplied, the client can determine this
816+
name from a source `Dataset` object.
817+
table_spec_index (Optional[int]):
818+
If no `table_spec_name` or `column_spec_name` was provided, we
819+
use this index to determine which table to set the weight
820+
column on.
821+
dataset_display_name (Optional[string]):
822+
The human-readable name given to the dataset you want to update
823+
the weight column of. If no `table_spec_name` is supplied, this
824+
will be used together with `table_spec_index` to infer the name
825+
of table to update the weight column of. This must be supplied
826+
if `table_spec_name`, `dataset` or `dataset_name` are not
827+
supplied.
828+
dataset_name (Optional[string]):
829+
The AutoML-assigned name given to the dataset you want to
830+
update the weight column of. If no `table_spec_name` is
831+
supplied, this will be used together with `table_spec_index` to
832+
infer the name of table to update the weight column of. This
833+
must be supplied if `table_spec_name`, `dataset` or
834+
`dataset_display_name` are not supplied.
835+
dataset (Optional[Dataset]):
836+
The `Dataset` instance you want to update the weight column of.
837+
If no `table_spec_name` is supplied, this will be used together
838+
with `table_spec_index` to infer the name of table to update
839+
the weight column of. This must be supplied if
840+
`table_spec_name`, `dataset_name` or `dataset_display_name` are
841+
not supplied.
842+
843+
Returns:
844+
A :class:`~google.cloud.automl_v1beta1.types.Dataset` instance.
845+
846+
Raises:
847+
google.api_core.exceptions.GoogleAPICallError: If the request
848+
failed for any reason.
849+
google.api_core.exceptions.RetryError: If the request failed due
850+
to a retryable error and retry attempts failed.
851+
ValueError: If required parameters are missing.
852+
"""
711853
column_spec_name = self.__column_spec_name_from_args(
712854
dataset=dataset,
713855
dataset_display_name=dataset_display_name,

0 commit comments

Comments
 (0)