diff --git a/docs/aiplatform_v1/services.rst b/docs/aiplatform_v1/services.rst index eda56f8acc..6350367a62 100644 --- a/docs/aiplatform_v1/services.rst +++ b/docs/aiplatform_v1/services.rst @@ -13,3 +13,4 @@ Services for Google Cloud Aiplatform v1 API pipeline_service prediction_service specialist_pool_service + vizier_service diff --git a/docs/aiplatform_v1/vizier_service.rst b/docs/aiplatform_v1/vizier_service.rst new file mode 100644 index 0000000000..efdbafe3c8 --- /dev/null +++ b/docs/aiplatform_v1/vizier_service.rst @@ -0,0 +1,10 @@ +VizierService +------------------------------- + +.. automodule:: google.cloud.aiplatform_v1.services.vizier_service + :members: + :inherited-members: + +.. automodule:: google.cloud.aiplatform_v1.services.vizier_service.pagers + :members: + :inherited-members: diff --git a/google/cloud/aiplatform_v1/__init__.py b/google/cloud/aiplatform_v1/__init__.py index 5db78af72b..01b734f72d 100644 --- a/google/cloud/aiplatform_v1/__init__.py +++ b/google/cloud/aiplatform_v1/__init__.py @@ -34,6 +34,8 @@ from .services.prediction_service import PredictionServiceAsyncClient from .services.specialist_pool_service import SpecialistPoolServiceClient from .services.specialist_pool_service import SpecialistPoolServiceAsyncClient +from .services.vizier_service import VizierServiceClient +from .services.vizier_service import VizierServiceAsyncClient from .types.accelerator_type import AcceleratorType from .types.annotation import Annotation @@ -279,6 +281,28 @@ from .types.training_pipeline import TrainingPipeline from .types.user_action_reference import UserActionReference from .types.value import Value +from .types.vizier_service import AddTrialMeasurementRequest +from .types.vizier_service import CheckTrialEarlyStoppingStateMetatdata +from .types.vizier_service import CheckTrialEarlyStoppingStateRequest +from .types.vizier_service import CheckTrialEarlyStoppingStateResponse +from .types.vizier_service import CompleteTrialRequest +from .types.vizier_service import CreateStudyRequest +from .types.vizier_service import CreateTrialRequest +from .types.vizier_service import DeleteStudyRequest +from .types.vizier_service import DeleteTrialRequest +from .types.vizier_service import GetStudyRequest +from .types.vizier_service import GetTrialRequest +from .types.vizier_service import ListOptimalTrialsRequest +from .types.vizier_service import ListOptimalTrialsResponse +from .types.vizier_service import ListStudiesRequest +from .types.vizier_service import ListStudiesResponse +from .types.vizier_service import ListTrialsRequest +from .types.vizier_service import ListTrialsResponse +from .types.vizier_service import LookupStudyRequest +from .types.vizier_service import StopTrialRequest +from .types.vizier_service import SuggestTrialsMetadata +from .types.vizier_service import SuggestTrialsRequest +from .types.vizier_service import SuggestTrialsResponse __all__ = ( "DatasetServiceAsyncClient", @@ -291,8 +315,10 @@ "PipelineServiceAsyncClient", "PredictionServiceAsyncClient", "SpecialistPoolServiceAsyncClient", + "VizierServiceAsyncClient", "AcceleratorType", "ActiveLearningConfig", + "AddTrialMeasurementRequest", "Annotation", "AnnotationSpec", "Artifact", @@ -312,6 +338,10 @@ "CancelHyperparameterTuningJobRequest", "CancelPipelineJobRequest", "CancelTrainingPipelineRequest", + "CheckTrialEarlyStoppingStateMetatdata", + "CheckTrialEarlyStoppingStateRequest", + "CheckTrialEarlyStoppingStateResponse", + "CompleteTrialRequest", "CompletionStats", "ContainerRegistryDestination", "ContainerSpec", @@ -332,7 +362,9 @@ "CreatePipelineJobRequest", "CreateSpecialistPoolOperationMetadata", "CreateSpecialistPoolRequest", + "CreateStudyRequest", "CreateTrainingPipelineRequest", + "CreateTrialRequest", "CustomJob", "CustomJobSpec", "DataItem", @@ -353,7 +385,9 @@ "DeleteOperationMetadata", "DeletePipelineJobRequest", "DeleteSpecialistPoolRequest", + "DeleteStudyRequest", "DeleteTrainingPipelineRequest", + "DeleteTrialRequest", "DeployIndexOperationMetadata", "DeployIndexRequest", "DeployIndexResponse", @@ -408,7 +442,9 @@ "GetModelRequest", "GetPipelineJobRequest", "GetSpecialistPoolRequest", + "GetStudyRequest", "GetTrainingPipelineRequest", + "GetTrialRequest", "HyperparameterTuningJob", "ImportDataConfig", "ImportDataOperationMetadata", @@ -451,12 +487,19 @@ "ListModelEvaluationsResponse", "ListModelsRequest", "ListModelsResponse", + "ListOptimalTrialsRequest", + "ListOptimalTrialsResponse", "ListPipelineJobsRequest", "ListPipelineJobsResponse", "ListSpecialistPoolsRequest", "ListSpecialistPoolsResponse", + "ListStudiesRequest", + "ListStudiesResponse", "ListTrainingPipelinesRequest", "ListTrainingPipelinesResponse", + "ListTrialsRequest", + "ListTrialsResponse", + "LookupStudyRequest", "MachineSpec", "ManualBatchTuningParameters", "Measurement", @@ -507,8 +550,12 @@ "SmoothGradConfig", "SpecialistPool", "SpecialistPoolServiceClient", + "StopTrialRequest", "Study", "StudySpec", + "SuggestTrialsMetadata", + "SuggestTrialsRequest", + "SuggestTrialsResponse", "ThresholdConfig", "TimestampSplit", "TrainingConfig", @@ -535,6 +582,7 @@ "UploadModelResponse", "UserActionReference", "Value", + "VizierServiceClient", "WorkerPoolSpec", "XraiAttribution", ) diff --git a/google/cloud/aiplatform_v1/gapic_metadata.json b/google/cloud/aiplatform_v1/gapic_metadata.json index 489687b15b..f7636e752d 100644 --- a/google/cloud/aiplatform_v1/gapic_metadata.json +++ b/google/cloud/aiplatform_v1/gapic_metadata.json @@ -1014,6 +1014,170 @@ } } } + }, + "VizierService": { + "clients": { + "grpc": { + "libraryClient": "VizierServiceClient", + "rpcs": { + "AddTrialMeasurement": { + "methods": [ + "add_trial_measurement" + ] + }, + "CheckTrialEarlyStoppingState": { + "methods": [ + "check_trial_early_stopping_state" + ] + }, + "CompleteTrial": { + "methods": [ + "complete_trial" + ] + }, + "CreateStudy": { + "methods": [ + "create_study" + ] + }, + "CreateTrial": { + "methods": [ + "create_trial" + ] + }, + "DeleteStudy": { + "methods": [ + "delete_study" + ] + }, + "DeleteTrial": { + "methods": [ + "delete_trial" + ] + }, + "GetStudy": { + "methods": [ + "get_study" + ] + }, + "GetTrial": { + "methods": [ + "get_trial" + ] + }, + "ListOptimalTrials": { + "methods": [ + "list_optimal_trials" + ] + }, + "ListStudies": { + "methods": [ + "list_studies" + ] + }, + "ListTrials": { + "methods": [ + "list_trials" + ] + }, + "LookupStudy": { + "methods": [ + "lookup_study" + ] + }, + "StopTrial": { + "methods": [ + "stop_trial" + ] + }, + "SuggestTrials": { + "methods": [ + "suggest_trials" + ] + } + } + }, + "grpc-async": { + "libraryClient": "VizierServiceAsyncClient", + "rpcs": { + "AddTrialMeasurement": { + "methods": [ + "add_trial_measurement" + ] + }, + "CheckTrialEarlyStoppingState": { + "methods": [ + "check_trial_early_stopping_state" + ] + }, + "CompleteTrial": { + "methods": [ + "complete_trial" + ] + }, + "CreateStudy": { + "methods": [ + "create_study" + ] + }, + "CreateTrial": { + "methods": [ + "create_trial" + ] + }, + "DeleteStudy": { + "methods": [ + "delete_study" + ] + }, + "DeleteTrial": { + "methods": [ + "delete_trial" + ] + }, + "GetStudy": { + "methods": [ + "get_study" + ] + }, + "GetTrial": { + "methods": [ + "get_trial" + ] + }, + "ListOptimalTrials": { + "methods": [ + "list_optimal_trials" + ] + }, + "ListStudies": { + "methods": [ + "list_studies" + ] + }, + "ListTrials": { + "methods": [ + "list_trials" + ] + }, + "LookupStudy": { + "methods": [ + "lookup_study" + ] + }, + "StopTrial": { + "methods": [ + "stop_trial" + ] + }, + "SuggestTrials": { + "methods": [ + "suggest_trials" + ] + } + } + } + } } } } diff --git a/google/cloud/aiplatform_v1/services/dataset_service/client.py b/google/cloud/aiplatform_v1/services/dataset_service/client.py index 1fc223b8a8..6c6f120e5e 100644 --- a/google/cloud/aiplatform_v1/services/dataset_service/client.py +++ b/google/cloud/aiplatform_v1/services/dataset_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -428,7 +428,7 @@ def __init__( def create_dataset( self, - request: dataset_service.CreateDatasetRequest = None, + request: Union[dataset_service.CreateDatasetRequest, dict] = None, *, parent: str = None, dataset: gca_dataset.Dataset = None, @@ -439,7 +439,7 @@ def create_dataset( r"""Creates a Dataset. Args: - request (google.cloud.aiplatform_v1.types.CreateDatasetRequest): + request (Union[google.cloud.aiplatform_v1.types.CreateDatasetRequest, dict]): The request object. Request message for [DatasetService.CreateDataset][google.cloud.aiplatform.v1.DatasetService.CreateDataset]. parent (str): @@ -519,7 +519,7 @@ def create_dataset( def get_dataset( self, - request: dataset_service.GetDatasetRequest = None, + request: Union[dataset_service.GetDatasetRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -529,7 +529,7 @@ def get_dataset( r"""Gets a Dataset. Args: - request (google.cloud.aiplatform_v1.types.GetDatasetRequest): + request (Union[google.cloud.aiplatform_v1.types.GetDatasetRequest, dict]): The request object. Request message for [DatasetService.GetDataset][google.cloud.aiplatform.v1.DatasetService.GetDataset]. name (str): @@ -590,7 +590,7 @@ def get_dataset( def update_dataset( self, - request: dataset_service.UpdateDatasetRequest = None, + request: Union[dataset_service.UpdateDatasetRequest, dict] = None, *, dataset: gca_dataset.Dataset = None, update_mask: field_mask_pb2.FieldMask = None, @@ -601,7 +601,7 @@ def update_dataset( r"""Updates a Dataset. Args: - request (google.cloud.aiplatform_v1.types.UpdateDatasetRequest): + request (Union[google.cloud.aiplatform_v1.types.UpdateDatasetRequest, dict]): The request object. Request message for [DatasetService.UpdateDataset][google.cloud.aiplatform.v1.DatasetService.UpdateDataset]. dataset (google.cloud.aiplatform_v1.types.Dataset): @@ -679,7 +679,7 @@ def update_dataset( def list_datasets( self, - request: dataset_service.ListDatasetsRequest = None, + request: Union[dataset_service.ListDatasetsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -689,7 +689,7 @@ def list_datasets( r"""Lists Datasets in a Location. Args: - request (google.cloud.aiplatform_v1.types.ListDatasetsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListDatasetsRequest, dict]): The request object. Request message for [DatasetService.ListDatasets][google.cloud.aiplatform.v1.DatasetService.ListDatasets]. parent (str): @@ -759,7 +759,7 @@ def list_datasets( def delete_dataset( self, - request: dataset_service.DeleteDatasetRequest = None, + request: Union[dataset_service.DeleteDatasetRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -769,7 +769,7 @@ def delete_dataset( r"""Deletes a Dataset. Args: - request (google.cloud.aiplatform_v1.types.DeleteDatasetRequest): + request (Union[google.cloud.aiplatform_v1.types.DeleteDatasetRequest, dict]): The request object. Request message for [DatasetService.DeleteDataset][google.cloud.aiplatform.v1.DatasetService.DeleteDataset]. name (str): @@ -852,7 +852,7 @@ def delete_dataset( def import_data( self, - request: dataset_service.ImportDataRequest = None, + request: Union[dataset_service.ImportDataRequest, dict] = None, *, name: str = None, import_configs: Sequence[dataset.ImportDataConfig] = None, @@ -863,7 +863,7 @@ def import_data( r"""Imports data into a Dataset. Args: - request (google.cloud.aiplatform_v1.types.ImportDataRequest): + request (Union[google.cloud.aiplatform_v1.types.ImportDataRequest, dict]): The request object. Request message for [DatasetService.ImportData][google.cloud.aiplatform.v1.DatasetService.ImportData]. name (str): @@ -946,7 +946,7 @@ def import_data( def export_data( self, - request: dataset_service.ExportDataRequest = None, + request: Union[dataset_service.ExportDataRequest, dict] = None, *, name: str = None, export_config: dataset.ExportDataConfig = None, @@ -957,7 +957,7 @@ def export_data( r"""Exports data from a Dataset. Args: - request (google.cloud.aiplatform_v1.types.ExportDataRequest): + request (Union[google.cloud.aiplatform_v1.types.ExportDataRequest, dict]): The request object. Request message for [DatasetService.ExportData][google.cloud.aiplatform.v1.DatasetService.ExportData]. name (str): @@ -1039,7 +1039,7 @@ def export_data( def list_data_items( self, - request: dataset_service.ListDataItemsRequest = None, + request: Union[dataset_service.ListDataItemsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1049,7 +1049,7 @@ def list_data_items( r"""Lists DataItems in a Dataset. Args: - request (google.cloud.aiplatform_v1.types.ListDataItemsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListDataItemsRequest, dict]): The request object. Request message for [DatasetService.ListDataItems][google.cloud.aiplatform.v1.DatasetService.ListDataItems]. parent (str): @@ -1120,7 +1120,7 @@ def list_data_items( def get_annotation_spec( self, - request: dataset_service.GetAnnotationSpecRequest = None, + request: Union[dataset_service.GetAnnotationSpecRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1130,7 +1130,7 @@ def get_annotation_spec( r"""Gets an AnnotationSpec. Args: - request (google.cloud.aiplatform_v1.types.GetAnnotationSpecRequest): + request (Union[google.cloud.aiplatform_v1.types.GetAnnotationSpecRequest, dict]): The request object. Request message for [DatasetService.GetAnnotationSpec][google.cloud.aiplatform.v1.DatasetService.GetAnnotationSpec]. name (str): @@ -1192,7 +1192,7 @@ def get_annotation_spec( def list_annotations( self, - request: dataset_service.ListAnnotationsRequest = None, + request: Union[dataset_service.ListAnnotationsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1202,7 +1202,7 @@ def list_annotations( r"""Lists Annotations belongs to a dataitem Args: - request (google.cloud.aiplatform_v1.types.ListAnnotationsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListAnnotationsRequest, dict]): The request object. Request message for [DatasetService.ListAnnotations][google.cloud.aiplatform.v1.DatasetService.ListAnnotations]. parent (str): diff --git a/google/cloud/aiplatform_v1/services/dataset_service/transports/base.py b/google/cloud/aiplatform_v1/services/dataset_service/transports/base.py index 79f6b98533..48d8e95496 100644 --- a/google/cloud/aiplatform_v1/services/dataset_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/dataset_service/transports/base.py @@ -122,7 +122,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc.py index 155f701203..76c7b6a957 100644 --- a/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc.py @@ -86,16 +86,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc_asyncio.py index 233aa502dc..24f2d51923 100644 --- a/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc_asyncio.py @@ -133,16 +133,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/endpoint_service/client.py b/google/cloud/aiplatform_v1/services/endpoint_service/client.py index 968ff67ca5..09032cb157 100644 --- a/google/cloud/aiplatform_v1/services/endpoint_service/client.py +++ b/google/cloud/aiplatform_v1/services/endpoint_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -397,7 +397,7 @@ def __init__( def create_endpoint( self, - request: endpoint_service.CreateEndpointRequest = None, + request: Union[endpoint_service.CreateEndpointRequest, dict] = None, *, parent: str = None, endpoint: gca_endpoint.Endpoint = None, @@ -408,7 +408,7 @@ def create_endpoint( r"""Creates an Endpoint. Args: - request (google.cloud.aiplatform_v1.types.CreateEndpointRequest): + request (Union[google.cloud.aiplatform_v1.types.CreateEndpointRequest, dict]): The request object. Request message for [EndpointService.CreateEndpoint][google.cloud.aiplatform.v1.EndpointService.CreateEndpoint]. parent (str): @@ -487,7 +487,7 @@ def create_endpoint( def get_endpoint( self, - request: endpoint_service.GetEndpointRequest = None, + request: Union[endpoint_service.GetEndpointRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -497,7 +497,7 @@ def get_endpoint( r"""Gets an Endpoint. Args: - request (google.cloud.aiplatform_v1.types.GetEndpointRequest): + request (Union[google.cloud.aiplatform_v1.types.GetEndpointRequest, dict]): The request object. Request message for [EndpointService.GetEndpoint][google.cloud.aiplatform.v1.EndpointService.GetEndpoint] name (str): @@ -559,7 +559,7 @@ def get_endpoint( def list_endpoints( self, - request: endpoint_service.ListEndpointsRequest = None, + request: Union[endpoint_service.ListEndpointsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -569,7 +569,7 @@ def list_endpoints( r"""Lists Endpoints in a Location. Args: - request (google.cloud.aiplatform_v1.types.ListEndpointsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListEndpointsRequest, dict]): The request object. Request message for [EndpointService.ListEndpoints][google.cloud.aiplatform.v1.EndpointService.ListEndpoints]. parent (str): @@ -640,7 +640,7 @@ def list_endpoints( def update_endpoint( self, - request: endpoint_service.UpdateEndpointRequest = None, + request: Union[endpoint_service.UpdateEndpointRequest, dict] = None, *, endpoint: gca_endpoint.Endpoint = None, update_mask: field_mask_pb2.FieldMask = None, @@ -651,7 +651,7 @@ def update_endpoint( r"""Updates an Endpoint. Args: - request (google.cloud.aiplatform_v1.types.UpdateEndpointRequest): + request (Union[google.cloud.aiplatform_v1.types.UpdateEndpointRequest, dict]): The request object. Request message for [EndpointService.UpdateEndpoint][google.cloud.aiplatform.v1.EndpointService.UpdateEndpoint]. endpoint (google.cloud.aiplatform_v1.types.Endpoint): @@ -724,7 +724,7 @@ def update_endpoint( def delete_endpoint( self, - request: endpoint_service.DeleteEndpointRequest = None, + request: Union[endpoint_service.DeleteEndpointRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -734,7 +734,7 @@ def delete_endpoint( r"""Deletes an Endpoint. Args: - request (google.cloud.aiplatform_v1.types.DeleteEndpointRequest): + request (Union[google.cloud.aiplatform_v1.types.DeleteEndpointRequest, dict]): The request object. Request message for [EndpointService.DeleteEndpoint][google.cloud.aiplatform.v1.EndpointService.DeleteEndpoint]. name (str): @@ -817,7 +817,7 @@ def delete_endpoint( def deploy_model( self, - request: endpoint_service.DeployModelRequest = None, + request: Union[endpoint_service.DeployModelRequest, dict] = None, *, endpoint: str = None, deployed_model: gca_endpoint.DeployedModel = None, @@ -832,7 +832,7 @@ def deploy_model( DeployedModel within it. Args: - request (google.cloud.aiplatform_v1.types.DeployModelRequest): + request (Union[google.cloud.aiplatform_v1.types.DeployModelRequest, dict]): The request object. Request message for [EndpointService.DeployModel][google.cloud.aiplatform.v1.EndpointService.DeployModel]. endpoint (str): @@ -941,7 +941,7 @@ def deploy_model( def undeploy_model( self, - request: endpoint_service.UndeployModelRequest = None, + request: Union[endpoint_service.UndeployModelRequest, dict] = None, *, endpoint: str = None, deployed_model_id: str = None, @@ -957,7 +957,7 @@ def undeploy_model( using. Args: - request (google.cloud.aiplatform_v1.types.UndeployModelRequest): + request (Union[google.cloud.aiplatform_v1.types.UndeployModelRequest, dict]): The request object. Request message for [EndpointService.UndeployModel][google.cloud.aiplatform.v1.EndpointService.UndeployModel]. endpoint (str): diff --git a/google/cloud/aiplatform_v1/services/endpoint_service/transports/base.py b/google/cloud/aiplatform_v1/services/endpoint_service/transports/base.py index 60dca00a1c..4df58632d3 100644 --- a/google/cloud/aiplatform_v1/services/endpoint_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/endpoint_service/transports/base.py @@ -121,7 +121,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc.py index 3aefc88059..ecd2afb84e 100644 --- a/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc.py @@ -84,16 +84,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc_asyncio.py index a729248254..873478d235 100644 --- a/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc_asyncio.py @@ -131,16 +131,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/index_endpoint_service/client.py b/google/cloud/aiplatform_v1/services/index_endpoint_service/client.py index ecb6a082af..d897700af7 100644 --- a/google/cloud/aiplatform_v1/services/index_endpoint_service/client.py +++ b/google/cloud/aiplatform_v1/services/index_endpoint_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -378,7 +378,7 @@ def __init__( def create_index_endpoint( self, - request: index_endpoint_service.CreateIndexEndpointRequest = None, + request: Union[index_endpoint_service.CreateIndexEndpointRequest, dict] = None, *, parent: str = None, index_endpoint: gca_index_endpoint.IndexEndpoint = None, @@ -389,7 +389,7 @@ def create_index_endpoint( r"""Creates an IndexEndpoint. Args: - request (google.cloud.aiplatform_v1.types.CreateIndexEndpointRequest): + request (Union[google.cloud.aiplatform_v1.types.CreateIndexEndpointRequest, dict]): The request object. Request message for [IndexEndpointService.CreateIndexEndpoint][google.cloud.aiplatform.v1.IndexEndpointService.CreateIndexEndpoint]. parent (str): @@ -470,7 +470,7 @@ def create_index_endpoint( def get_index_endpoint( self, - request: index_endpoint_service.GetIndexEndpointRequest = None, + request: Union[index_endpoint_service.GetIndexEndpointRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -480,7 +480,7 @@ def get_index_endpoint( r"""Gets an IndexEndpoint. Args: - request (google.cloud.aiplatform_v1.types.GetIndexEndpointRequest): + request (Union[google.cloud.aiplatform_v1.types.GetIndexEndpointRequest, dict]): The request object. Request message for [IndexEndpointService.GetIndexEndpoint][google.cloud.aiplatform.v1.IndexEndpointService.GetIndexEndpoint] name (str): @@ -543,7 +543,7 @@ def get_index_endpoint( def list_index_endpoints( self, - request: index_endpoint_service.ListIndexEndpointsRequest = None, + request: Union[index_endpoint_service.ListIndexEndpointsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -553,7 +553,7 @@ def list_index_endpoints( r"""Lists IndexEndpoints in a Location. Args: - request (google.cloud.aiplatform_v1.types.ListIndexEndpointsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListIndexEndpointsRequest, dict]): The request object. Request message for [IndexEndpointService.ListIndexEndpoints][google.cloud.aiplatform.v1.IndexEndpointService.ListIndexEndpoints]. parent (str): @@ -624,7 +624,7 @@ def list_index_endpoints( def update_index_endpoint( self, - request: index_endpoint_service.UpdateIndexEndpointRequest = None, + request: Union[index_endpoint_service.UpdateIndexEndpointRequest, dict] = None, *, index_endpoint: gca_index_endpoint.IndexEndpoint = None, update_mask: field_mask_pb2.FieldMask = None, @@ -635,7 +635,7 @@ def update_index_endpoint( r"""Updates an IndexEndpoint. Args: - request (google.cloud.aiplatform_v1.types.UpdateIndexEndpointRequest): + request (Union[google.cloud.aiplatform_v1.types.UpdateIndexEndpointRequest, dict]): The request object. Request message for [IndexEndpointService.UpdateIndexEndpoint][google.cloud.aiplatform.v1.IndexEndpointService.UpdateIndexEndpoint]. index_endpoint (google.cloud.aiplatform_v1.types.IndexEndpoint): @@ -708,7 +708,7 @@ def update_index_endpoint( def delete_index_endpoint( self, - request: index_endpoint_service.DeleteIndexEndpointRequest = None, + request: Union[index_endpoint_service.DeleteIndexEndpointRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -718,7 +718,7 @@ def delete_index_endpoint( r"""Deletes an IndexEndpoint. Args: - request (google.cloud.aiplatform_v1.types.DeleteIndexEndpointRequest): + request (Union[google.cloud.aiplatform_v1.types.DeleteIndexEndpointRequest, dict]): The request object. Request message for [IndexEndpointService.DeleteIndexEndpoint][google.cloud.aiplatform.v1.IndexEndpointService.DeleteIndexEndpoint]. name (str): @@ -801,7 +801,7 @@ def delete_index_endpoint( def deploy_index( self, - request: index_endpoint_service.DeployIndexRequest = None, + request: Union[index_endpoint_service.DeployIndexRequest, dict] = None, *, index_endpoint: str = None, deployed_index: gca_index_endpoint.DeployedIndex = None, @@ -814,7 +814,7 @@ def deploy_index( Only non-empty Indexes can be deployed. Args: - request (google.cloud.aiplatform_v1.types.DeployIndexRequest): + request (Union[google.cloud.aiplatform_v1.types.DeployIndexRequest, dict]): The request object. Request message for [IndexEndpointService.DeployIndex][google.cloud.aiplatform.v1.IndexEndpointService.DeployIndex]. index_endpoint (str): @@ -899,7 +899,7 @@ def deploy_index( def undeploy_index( self, - request: index_endpoint_service.UndeployIndexRequest = None, + request: Union[index_endpoint_service.UndeployIndexRequest, dict] = None, *, index_endpoint: str = None, deployed_index_id: str = None, @@ -912,7 +912,7 @@ def undeploy_index( using. Args: - request (google.cloud.aiplatform_v1.types.UndeployIndexRequest): + request (Union[google.cloud.aiplatform_v1.types.UndeployIndexRequest, dict]): The request object. Request message for [IndexEndpointService.UndeployIndex][google.cloud.aiplatform.v1.IndexEndpointService.UndeployIndex]. index_endpoint (str): diff --git a/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/base.py b/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/base.py index ba40af14ee..247eeef411 100644 --- a/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/base.py @@ -121,7 +121,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/grpc.py index 49da439d41..4a77ff2dd6 100644 --- a/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/grpc.py @@ -84,16 +84,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/grpc_asyncio.py index 02bbb7d17b..0db7ec6ef8 100644 --- a/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/index_endpoint_service/transports/grpc_asyncio.py @@ -131,16 +131,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/index_service/client.py b/google/cloud/aiplatform_v1/services/index_service/client.py index 6f895a2da6..81c4fdca9e 100644 --- a/google/cloud/aiplatform_v1/services/index_service/client.py +++ b/google/cloud/aiplatform_v1/services/index_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -378,7 +378,7 @@ def __init__( def create_index( self, - request: index_service.CreateIndexRequest = None, + request: Union[index_service.CreateIndexRequest, dict] = None, *, parent: str = None, index: gca_index.Index = None, @@ -389,7 +389,7 @@ def create_index( r"""Creates an Index. Args: - request (google.cloud.aiplatform_v1.types.CreateIndexRequest): + request (Union[google.cloud.aiplatform_v1.types.CreateIndexRequest, dict]): The request object. Request message for [IndexService.CreateIndex][google.cloud.aiplatform.v1.IndexService.CreateIndex]. parent (str): @@ -469,7 +469,7 @@ def create_index( def get_index( self, - request: index_service.GetIndexRequest = None, + request: Union[index_service.GetIndexRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -479,7 +479,7 @@ def get_index( r"""Gets an Index. Args: - request (google.cloud.aiplatform_v1.types.GetIndexRequest): + request (Union[google.cloud.aiplatform_v1.types.GetIndexRequest, dict]): The request object. Request message for [IndexService.GetIndex][google.cloud.aiplatform.v1.IndexService.GetIndex] name (str): @@ -542,7 +542,7 @@ def get_index( def list_indexes( self, - request: index_service.ListIndexesRequest = None, + request: Union[index_service.ListIndexesRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -552,7 +552,7 @@ def list_indexes( r"""Lists Indexes in a Location. Args: - request (google.cloud.aiplatform_v1.types.ListIndexesRequest): + request (Union[google.cloud.aiplatform_v1.types.ListIndexesRequest, dict]): The request object. Request message for [IndexService.ListIndexes][google.cloud.aiplatform.v1.IndexService.ListIndexes]. parent (str): @@ -623,7 +623,7 @@ def list_indexes( def update_index( self, - request: index_service.UpdateIndexRequest = None, + request: Union[index_service.UpdateIndexRequest, dict] = None, *, index: gca_index.Index = None, update_mask: field_mask_pb2.FieldMask = None, @@ -634,7 +634,7 @@ def update_index( r"""Updates an Index. Args: - request (google.cloud.aiplatform_v1.types.UpdateIndexRequest): + request (Union[google.cloud.aiplatform_v1.types.UpdateIndexRequest, dict]): The request object. Request message for [IndexService.UpdateIndex][google.cloud.aiplatform.v1.IndexService.UpdateIndex]. index (google.cloud.aiplatform_v1.types.Index): @@ -718,7 +718,7 @@ def update_index( def delete_index( self, - request: index_service.DeleteIndexRequest = None, + request: Union[index_service.DeleteIndexRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -730,7 +730,7 @@ def delete_index( had been undeployed. Args: - request (google.cloud.aiplatform_v1.types.DeleteIndexRequest): + request (Union[google.cloud.aiplatform_v1.types.DeleteIndexRequest, dict]): The request object. Request message for [IndexService.DeleteIndex][google.cloud.aiplatform.v1.IndexService.DeleteIndex]. name (str): diff --git a/google/cloud/aiplatform_v1/services/index_service/transports/base.py b/google/cloud/aiplatform_v1/services/index_service/transports/base.py index d39c5cd1d0..117e6748cd 100644 --- a/google/cloud/aiplatform_v1/services/index_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/index_service/transports/base.py @@ -120,7 +120,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1/services/index_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/index_service/transports/grpc.py index 2f0d9ceea1..699b2648aa 100644 --- a/google/cloud/aiplatform_v1/services/index_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/index_service/transports/grpc.py @@ -84,16 +84,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/index_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/index_service/transports/grpc_asyncio.py index e773c0dd5b..a0a25d7f37 100644 --- a/google/cloud/aiplatform_v1/services/index_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/index_service/transports/grpc_asyncio.py @@ -131,16 +131,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/job_service/client.py b/google/cloud/aiplatform_v1/services/job_service/client.py index 8ed1d18282..cbeb4495b5 100644 --- a/google/cloud/aiplatform_v1/services/job_service/client.py +++ b/google/cloud/aiplatform_v1/services/job_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -542,7 +542,7 @@ def __init__( def create_custom_job( self, - request: job_service.CreateCustomJobRequest = None, + request: Union[job_service.CreateCustomJobRequest, dict] = None, *, parent: str = None, custom_job: gca_custom_job.CustomJob = None, @@ -554,7 +554,7 @@ def create_custom_job( will be attempted to be run. Args: - request (google.cloud.aiplatform_v1.types.CreateCustomJobRequest): + request (Union[google.cloud.aiplatform_v1.types.CreateCustomJobRequest, dict]): The request object. Request message for [JobService.CreateCustomJob][google.cloud.aiplatform.v1.JobService.CreateCustomJob]. parent (str): @@ -629,7 +629,7 @@ def create_custom_job( def get_custom_job( self, - request: job_service.GetCustomJobRequest = None, + request: Union[job_service.GetCustomJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -639,7 +639,7 @@ def get_custom_job( r"""Gets a CustomJob. Args: - request (google.cloud.aiplatform_v1.types.GetCustomJobRequest): + request (Union[google.cloud.aiplatform_v1.types.GetCustomJobRequest, dict]): The request object. Request message for [JobService.GetCustomJob][google.cloud.aiplatform.v1.JobService.GetCustomJob]. name (str): @@ -706,7 +706,7 @@ def get_custom_job( def list_custom_jobs( self, - request: job_service.ListCustomJobsRequest = None, + request: Union[job_service.ListCustomJobsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -716,7 +716,7 @@ def list_custom_jobs( r"""Lists CustomJobs in a Location. Args: - request (google.cloud.aiplatform_v1.types.ListCustomJobsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListCustomJobsRequest, dict]): The request object. Request message for [JobService.ListCustomJobs][google.cloud.aiplatform.v1.JobService.ListCustomJobs]. parent (str): @@ -787,7 +787,7 @@ def list_custom_jobs( def delete_custom_job( self, - request: job_service.DeleteCustomJobRequest = None, + request: Union[job_service.DeleteCustomJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -797,7 +797,7 @@ def delete_custom_job( r"""Deletes a CustomJob. Args: - request (google.cloud.aiplatform_v1.types.DeleteCustomJobRequest): + request (Union[google.cloud.aiplatform_v1.types.DeleteCustomJobRequest, dict]): The request object. Request message for [JobService.DeleteCustomJob][google.cloud.aiplatform.v1.JobService.DeleteCustomJob]. name (str): @@ -880,7 +880,7 @@ def delete_custom_job( def cancel_custom_job( self, - request: job_service.CancelCustomJobRequest = None, + request: Union[job_service.CancelCustomJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -902,7 +902,7 @@ def cancel_custom_job( set to ``CANCELLED``. Args: - request (google.cloud.aiplatform_v1.types.CancelCustomJobRequest): + request (Union[google.cloud.aiplatform_v1.types.CancelCustomJobRequest, dict]): The request object. Request message for [JobService.CancelCustomJob][google.cloud.aiplatform.v1.JobService.CancelCustomJob]. name (str): @@ -956,7 +956,7 @@ def cancel_custom_job( def create_data_labeling_job( self, - request: job_service.CreateDataLabelingJobRequest = None, + request: Union[job_service.CreateDataLabelingJobRequest, dict] = None, *, parent: str = None, data_labeling_job: gca_data_labeling_job.DataLabelingJob = None, @@ -967,7 +967,7 @@ def create_data_labeling_job( r"""Creates a DataLabelingJob. Args: - request (google.cloud.aiplatform_v1.types.CreateDataLabelingJobRequest): + request (Union[google.cloud.aiplatform_v1.types.CreateDataLabelingJobRequest, dict]): The request object. Request message for [JobService.CreateDataLabelingJob][google.cloud.aiplatform.v1.JobService.CreateDataLabelingJob]. parent (str): @@ -1038,7 +1038,7 @@ def create_data_labeling_job( def get_data_labeling_job( self, - request: job_service.GetDataLabelingJobRequest = None, + request: Union[job_service.GetDataLabelingJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1048,7 +1048,7 @@ def get_data_labeling_job( r"""Gets a DataLabelingJob. Args: - request (google.cloud.aiplatform_v1.types.GetDataLabelingJobRequest): + request (Union[google.cloud.aiplatform_v1.types.GetDataLabelingJobRequest, dict]): The request object. Request message for [JobService.GetDataLabelingJob][google.cloud.aiplatform.v1.JobService.GetDataLabelingJob]. name (str): @@ -1110,7 +1110,7 @@ def get_data_labeling_job( def list_data_labeling_jobs( self, - request: job_service.ListDataLabelingJobsRequest = None, + request: Union[job_service.ListDataLabelingJobsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1120,7 +1120,7 @@ def list_data_labeling_jobs( r"""Lists DataLabelingJobs in a Location. Args: - request (google.cloud.aiplatform_v1.types.ListDataLabelingJobsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListDataLabelingJobsRequest, dict]): The request object. Request message for [JobService.ListDataLabelingJobs][google.cloud.aiplatform.v1.JobService.ListDataLabelingJobs]. parent (str): @@ -1190,7 +1190,7 @@ def list_data_labeling_jobs( def delete_data_labeling_job( self, - request: job_service.DeleteDataLabelingJobRequest = None, + request: Union[job_service.DeleteDataLabelingJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1200,7 +1200,7 @@ def delete_data_labeling_job( r"""Deletes a DataLabelingJob. Args: - request (google.cloud.aiplatform_v1.types.DeleteDataLabelingJobRequest): + request (Union[google.cloud.aiplatform_v1.types.DeleteDataLabelingJobRequest, dict]): The request object. Request message for [JobService.DeleteDataLabelingJob][google.cloud.aiplatform.v1.JobService.DeleteDataLabelingJob]. name (str): @@ -1283,7 +1283,7 @@ def delete_data_labeling_job( def cancel_data_labeling_job( self, - request: job_service.CancelDataLabelingJobRequest = None, + request: Union[job_service.CancelDataLabelingJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1294,7 +1294,7 @@ def cancel_data_labeling_job( not guaranteed. Args: - request (google.cloud.aiplatform_v1.types.CancelDataLabelingJobRequest): + request (Union[google.cloud.aiplatform_v1.types.CancelDataLabelingJobRequest, dict]): The request object. Request message for [JobService.CancelDataLabelingJob][google.cloud.aiplatform.v1.JobService.CancelDataLabelingJob]. name (str): @@ -1348,7 +1348,7 @@ def cancel_data_labeling_job( def create_hyperparameter_tuning_job( self, - request: job_service.CreateHyperparameterTuningJobRequest = None, + request: Union[job_service.CreateHyperparameterTuningJobRequest, dict] = None, *, parent: str = None, hyperparameter_tuning_job: gca_hyperparameter_tuning_job.HyperparameterTuningJob = None, @@ -1359,7 +1359,7 @@ def create_hyperparameter_tuning_job( r"""Creates a HyperparameterTuningJob Args: - request (google.cloud.aiplatform_v1.types.CreateHyperparameterTuningJobRequest): + request (Union[google.cloud.aiplatform_v1.types.CreateHyperparameterTuningJobRequest, dict]): The request object. Request message for [JobService.CreateHyperparameterTuningJob][google.cloud.aiplatform.v1.JobService.CreateHyperparameterTuningJob]. parent (str): @@ -1434,7 +1434,7 @@ def create_hyperparameter_tuning_job( def get_hyperparameter_tuning_job( self, - request: job_service.GetHyperparameterTuningJobRequest = None, + request: Union[job_service.GetHyperparameterTuningJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1444,7 +1444,7 @@ def get_hyperparameter_tuning_job( r"""Gets a HyperparameterTuningJob Args: - request (google.cloud.aiplatform_v1.types.GetHyperparameterTuningJobRequest): + request (Union[google.cloud.aiplatform_v1.types.GetHyperparameterTuningJobRequest, dict]): The request object. Request message for [JobService.GetHyperparameterTuningJob][google.cloud.aiplatform.v1.JobService.GetHyperparameterTuningJob]. name (str): @@ -1510,7 +1510,7 @@ def get_hyperparameter_tuning_job( def list_hyperparameter_tuning_jobs( self, - request: job_service.ListHyperparameterTuningJobsRequest = None, + request: Union[job_service.ListHyperparameterTuningJobsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1520,7 +1520,7 @@ def list_hyperparameter_tuning_jobs( r"""Lists HyperparameterTuningJobs in a Location. Args: - request (google.cloud.aiplatform_v1.types.ListHyperparameterTuningJobsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListHyperparameterTuningJobsRequest, dict]): The request object. Request message for [JobService.ListHyperparameterTuningJobs][google.cloud.aiplatform.v1.JobService.ListHyperparameterTuningJobs]. parent (str): @@ -1593,7 +1593,7 @@ def list_hyperparameter_tuning_jobs( def delete_hyperparameter_tuning_job( self, - request: job_service.DeleteHyperparameterTuningJobRequest = None, + request: Union[job_service.DeleteHyperparameterTuningJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1603,7 +1603,7 @@ def delete_hyperparameter_tuning_job( r"""Deletes a HyperparameterTuningJob. Args: - request (google.cloud.aiplatform_v1.types.DeleteHyperparameterTuningJobRequest): + request (Union[google.cloud.aiplatform_v1.types.DeleteHyperparameterTuningJobRequest, dict]): The request object. Request message for [JobService.DeleteHyperparameterTuningJob][google.cloud.aiplatform.v1.JobService.DeleteHyperparameterTuningJob]. name (str): @@ -1688,7 +1688,7 @@ def delete_hyperparameter_tuning_job( def cancel_hyperparameter_tuning_job( self, - request: job_service.CancelHyperparameterTuningJobRequest = None, + request: Union[job_service.CancelHyperparameterTuningJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1711,7 +1711,7 @@ def cancel_hyperparameter_tuning_job( is set to ``CANCELLED``. Args: - request (google.cloud.aiplatform_v1.types.CancelHyperparameterTuningJobRequest): + request (Union[google.cloud.aiplatform_v1.types.CancelHyperparameterTuningJobRequest, dict]): The request object. Request message for [JobService.CancelHyperparameterTuningJob][google.cloud.aiplatform.v1.JobService.CancelHyperparameterTuningJob]. name (str): @@ -1768,7 +1768,7 @@ def cancel_hyperparameter_tuning_job( def create_batch_prediction_job( self, - request: job_service.CreateBatchPredictionJobRequest = None, + request: Union[job_service.CreateBatchPredictionJobRequest, dict] = None, *, parent: str = None, batch_prediction_job: gca_batch_prediction_job.BatchPredictionJob = None, @@ -1780,7 +1780,7 @@ def create_batch_prediction_job( once created will right away be attempted to start. Args: - request (google.cloud.aiplatform_v1.types.CreateBatchPredictionJobRequest): + request (Union[google.cloud.aiplatform_v1.types.CreateBatchPredictionJobRequest, dict]): The request object. Request message for [JobService.CreateBatchPredictionJob][google.cloud.aiplatform.v1.JobService.CreateBatchPredictionJob]. parent (str): @@ -1857,7 +1857,7 @@ def create_batch_prediction_job( def get_batch_prediction_job( self, - request: job_service.GetBatchPredictionJobRequest = None, + request: Union[job_service.GetBatchPredictionJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1867,7 +1867,7 @@ def get_batch_prediction_job( r"""Gets a BatchPredictionJob Args: - request (google.cloud.aiplatform_v1.types.GetBatchPredictionJobRequest): + request (Union[google.cloud.aiplatform_v1.types.GetBatchPredictionJobRequest, dict]): The request object. Request message for [JobService.GetBatchPredictionJob][google.cloud.aiplatform.v1.JobService.GetBatchPredictionJob]. name (str): @@ -1933,7 +1933,7 @@ def get_batch_prediction_job( def list_batch_prediction_jobs( self, - request: job_service.ListBatchPredictionJobsRequest = None, + request: Union[job_service.ListBatchPredictionJobsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1943,7 +1943,7 @@ def list_batch_prediction_jobs( r"""Lists BatchPredictionJobs in a Location. Args: - request (google.cloud.aiplatform_v1.types.ListBatchPredictionJobsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListBatchPredictionJobsRequest, dict]): The request object. Request message for [JobService.ListBatchPredictionJobs][google.cloud.aiplatform.v1.JobService.ListBatchPredictionJobs]. parent (str): @@ -2016,7 +2016,7 @@ def list_batch_prediction_jobs( def delete_batch_prediction_job( self, - request: job_service.DeleteBatchPredictionJobRequest = None, + request: Union[job_service.DeleteBatchPredictionJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2027,7 +2027,7 @@ def delete_batch_prediction_job( jobs that already finished. Args: - request (google.cloud.aiplatform_v1.types.DeleteBatchPredictionJobRequest): + request (Union[google.cloud.aiplatform_v1.types.DeleteBatchPredictionJobRequest, dict]): The request object. Request message for [JobService.DeleteBatchPredictionJob][google.cloud.aiplatform.v1.JobService.DeleteBatchPredictionJob]. name (str): @@ -2112,7 +2112,7 @@ def delete_batch_prediction_job( def cancel_batch_prediction_job( self, - request: job_service.CancelBatchPredictionJobRequest = None, + request: Union[job_service.CancelBatchPredictionJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2133,7 +2133,7 @@ def cancel_batch_prediction_job( are not deleted. Args: - request (google.cloud.aiplatform_v1.types.CancelBatchPredictionJobRequest): + request (Union[google.cloud.aiplatform_v1.types.CancelBatchPredictionJobRequest, dict]): The request object. Request message for [JobService.CancelBatchPredictionJob][google.cloud.aiplatform.v1.JobService.CancelBatchPredictionJob]. name (str): @@ -2190,7 +2190,9 @@ def cancel_batch_prediction_job( def create_model_deployment_monitoring_job( self, - request: job_service.CreateModelDeploymentMonitoringJobRequest = None, + request: Union[ + job_service.CreateModelDeploymentMonitoringJobRequest, dict + ] = None, *, parent: str = None, model_deployment_monitoring_job: gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob = None, @@ -2202,7 +2204,7 @@ def create_model_deployment_monitoring_job( periodically on a configured interval. Args: - request (google.cloud.aiplatform_v1.types.CreateModelDeploymentMonitoringJobRequest): + request (Union[google.cloud.aiplatform_v1.types.CreateModelDeploymentMonitoringJobRequest, dict]): The request object. Request message for [JobService.CreateModelDeploymentMonitoringJob][google.cloud.aiplatform.v1.JobService.CreateModelDeploymentMonitoringJob]. parent (str): @@ -2282,7 +2284,9 @@ def create_model_deployment_monitoring_job( def search_model_deployment_monitoring_stats_anomalies( self, - request: job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest = None, + request: Union[ + job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest, dict + ] = None, *, model_deployment_monitoring_job: str = None, deployed_model_id: str = None, @@ -2294,7 +2298,7 @@ def search_model_deployment_monitoring_stats_anomalies( a given time window. Args: - request (google.cloud.aiplatform_v1.types.SearchModelDeploymentMonitoringStatsAnomaliesRequest): + request (Union[google.cloud.aiplatform_v1.types.SearchModelDeploymentMonitoringStatsAnomaliesRequest, dict]): The request object. Request message for [JobService.SearchModelDeploymentMonitoringStatsAnomalies][google.cloud.aiplatform.v1.JobService.SearchModelDeploymentMonitoringStatsAnomalies]. model_deployment_monitoring_job (str): @@ -2389,7 +2393,7 @@ def search_model_deployment_monitoring_stats_anomalies( def get_model_deployment_monitoring_job( self, - request: job_service.GetModelDeploymentMonitoringJobRequest = None, + request: Union[job_service.GetModelDeploymentMonitoringJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2399,7 +2403,7 @@ def get_model_deployment_monitoring_job( r"""Gets a ModelDeploymentMonitoringJob. Args: - request (google.cloud.aiplatform_v1.types.GetModelDeploymentMonitoringJobRequest): + request (Union[google.cloud.aiplatform_v1.types.GetModelDeploymentMonitoringJobRequest, dict]): The request object. Request message for [JobService.GetModelDeploymentMonitoringJob][google.cloud.aiplatform.v1.JobService.GetModelDeploymentMonitoringJob]. name (str): @@ -2466,7 +2470,9 @@ def get_model_deployment_monitoring_job( def list_model_deployment_monitoring_jobs( self, - request: job_service.ListModelDeploymentMonitoringJobsRequest = None, + request: Union[ + job_service.ListModelDeploymentMonitoringJobsRequest, dict + ] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2476,7 +2482,7 @@ def list_model_deployment_monitoring_jobs( r"""Lists ModelDeploymentMonitoringJobs in a Location. Args: - request (google.cloud.aiplatform_v1.types.ListModelDeploymentMonitoringJobsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListModelDeploymentMonitoringJobsRequest, dict]): The request object. Request message for [JobService.ListModelDeploymentMonitoringJobs][google.cloud.aiplatform.v1.JobService.ListModelDeploymentMonitoringJobs]. parent (str): @@ -2551,7 +2557,9 @@ def list_model_deployment_monitoring_jobs( def update_model_deployment_monitoring_job( self, - request: job_service.UpdateModelDeploymentMonitoringJobRequest = None, + request: Union[ + job_service.UpdateModelDeploymentMonitoringJobRequest, dict + ] = None, *, model_deployment_monitoring_job: gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob = None, update_mask: field_mask_pb2.FieldMask = None, @@ -2562,7 +2570,7 @@ def update_model_deployment_monitoring_job( r"""Updates a ModelDeploymentMonitoringJob. Args: - request (google.cloud.aiplatform_v1.types.UpdateModelDeploymentMonitoringJobRequest): + request (Union[google.cloud.aiplatform_v1.types.UpdateModelDeploymentMonitoringJobRequest, dict]): The request object. Request message for [JobService.UpdateModelDeploymentMonitoringJob][google.cloud.aiplatform.v1.JobService.UpdateModelDeploymentMonitoringJob]. model_deployment_monitoring_job (google.cloud.aiplatform_v1.types.ModelDeploymentMonitoringJob): @@ -2683,7 +2691,9 @@ def update_model_deployment_monitoring_job( def delete_model_deployment_monitoring_job( self, - request: job_service.DeleteModelDeploymentMonitoringJobRequest = None, + request: Union[ + job_service.DeleteModelDeploymentMonitoringJobRequest, dict + ] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2693,7 +2703,7 @@ def delete_model_deployment_monitoring_job( r"""Deletes a ModelDeploymentMonitoringJob. Args: - request (google.cloud.aiplatform_v1.types.DeleteModelDeploymentMonitoringJobRequest): + request (Union[google.cloud.aiplatform_v1.types.DeleteModelDeploymentMonitoringJobRequest, dict]): The request object. Request message for [JobService.DeleteModelDeploymentMonitoringJob][google.cloud.aiplatform.v1.JobService.DeleteModelDeploymentMonitoringJob]. name (str): @@ -2780,7 +2790,9 @@ def delete_model_deployment_monitoring_job( def pause_model_deployment_monitoring_job( self, - request: job_service.PauseModelDeploymentMonitoringJobRequest = None, + request: Union[ + job_service.PauseModelDeploymentMonitoringJobRequest, dict + ] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2793,7 +2805,7 @@ def pause_model_deployment_monitoring_job( to 'PAUSED'. Args: - request (google.cloud.aiplatform_v1.types.PauseModelDeploymentMonitoringJobRequest): + request (Union[google.cloud.aiplatform_v1.types.PauseModelDeploymentMonitoringJobRequest, dict]): The request object. Request message for [JobService.PauseModelDeploymentMonitoringJob][google.cloud.aiplatform.v1.JobService.PauseModelDeploymentMonitoringJob]. name (str): @@ -2852,7 +2864,9 @@ def pause_model_deployment_monitoring_job( def resume_model_deployment_monitoring_job( self, - request: job_service.ResumeModelDeploymentMonitoringJobRequest = None, + request: Union[ + job_service.ResumeModelDeploymentMonitoringJobRequest, dict + ] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2864,7 +2878,7 @@ def resume_model_deployment_monitoring_job( ModelDeploymentMonitoringJob can't be resumed. Args: - request (google.cloud.aiplatform_v1.types.ResumeModelDeploymentMonitoringJobRequest): + request (Union[google.cloud.aiplatform_v1.types.ResumeModelDeploymentMonitoringJobRequest, dict]): The request object. Request message for [JobService.ResumeModelDeploymentMonitoringJob][google.cloud.aiplatform.v1.JobService.ResumeModelDeploymentMonitoringJob]. name (str): diff --git a/google/cloud/aiplatform_v1/services/job_service/transports/base.py b/google/cloud/aiplatform_v1/services/job_service/transports/base.py index 91f7323f57..c4b12a9eec 100644 --- a/google/cloud/aiplatform_v1/services/job_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/job_service/transports/base.py @@ -136,7 +136,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1/services/job_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/job_service/transports/grpc.py index 93a0df4aae..aaf317d016 100644 --- a/google/cloud/aiplatform_v1/services/job_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/job_service/transports/grpc.py @@ -99,16 +99,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/job_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/job_service/transports/grpc_asyncio.py index 602fb4acf0..7ea1c5cb8e 100644 --- a/google/cloud/aiplatform_v1/services/job_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/job_service/transports/grpc_asyncio.py @@ -146,16 +146,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/migration_service/client.py b/google/cloud/aiplatform_v1/services/migration_service/client.py index 77a2aff04d..2329c18ad5 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/client.py +++ b/google/cloud/aiplatform_v1/services/migration_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -452,7 +452,7 @@ def __init__( def search_migratable_resources( self, - request: migration_service.SearchMigratableResourcesRequest = None, + request: Union[migration_service.SearchMigratableResourcesRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -465,7 +465,7 @@ def search_migratable_resources( given location. Args: - request (google.cloud.aiplatform_v1.types.SearchMigratableResourcesRequest): + request (Union[google.cloud.aiplatform_v1.types.SearchMigratableResourcesRequest, dict]): The request object. Request message for [MigrationService.SearchMigratableResources][google.cloud.aiplatform.v1.MigrationService.SearchMigratableResources]. parent (str): @@ -540,7 +540,7 @@ def search_migratable_resources( def batch_migrate_resources( self, - request: migration_service.BatchMigrateResourcesRequest = None, + request: Union[migration_service.BatchMigrateResourcesRequest, dict] = None, *, parent: str = None, migrate_resource_requests: Sequence[ @@ -555,7 +555,7 @@ def batch_migrate_resources( to Vertex AI. Args: - request (google.cloud.aiplatform_v1.types.BatchMigrateResourcesRequest): + request (Union[google.cloud.aiplatform_v1.types.BatchMigrateResourcesRequest, dict]): The request object. Request message for [MigrationService.BatchMigrateResources][google.cloud.aiplatform.v1.MigrationService.BatchMigrateResources]. parent (str): diff --git a/google/cloud/aiplatform_v1/services/migration_service/transports/base.py b/google/cloud/aiplatform_v1/services/migration_service/transports/base.py index 24daacbec2..0d230064b7 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/migration_service/transports/base.py @@ -119,7 +119,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1/services/migration_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/migration_service/transports/grpc.py index 5b6192b89a..c968a68cd0 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/migration_service/transports/grpc.py @@ -83,16 +83,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/migration_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/migration_service/transports/grpc_asyncio.py index f5a9ac6b4f..5417a14791 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/migration_service/transports/grpc_asyncio.py @@ -130,16 +130,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/model_service/client.py b/google/cloud/aiplatform_v1/services/model_service/client.py index ac25f2b845..f3527efea0 100644 --- a/google/cloud/aiplatform_v1/services/model_service/client.py +++ b/google/cloud/aiplatform_v1/services/model_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -438,7 +438,7 @@ def __init__( def upload_model( self, - request: model_service.UploadModelRequest = None, + request: Union[model_service.UploadModelRequest, dict] = None, *, parent: str = None, model: gca_model.Model = None, @@ -449,7 +449,7 @@ def upload_model( r"""Uploads a Model artifact into Vertex AI. Args: - request (google.cloud.aiplatform_v1.types.UploadModelRequest): + request (Union[google.cloud.aiplatform_v1.types.UploadModelRequest, dict]): The request object. Request message for [ModelService.UploadModel][google.cloud.aiplatform.v1.ModelService.UploadModel]. parent (str): @@ -531,7 +531,7 @@ def upload_model( def get_model( self, - request: model_service.GetModelRequest = None, + request: Union[model_service.GetModelRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -541,7 +541,7 @@ def get_model( r"""Gets a Model. Args: - request (google.cloud.aiplatform_v1.types.GetModelRequest): + request (Union[google.cloud.aiplatform_v1.types.GetModelRequest, dict]): The request object. Request message for [ModelService.GetModel][google.cloud.aiplatform.v1.ModelService.GetModel]. name (str): @@ -600,7 +600,7 @@ def get_model( def list_models( self, - request: model_service.ListModelsRequest = None, + request: Union[model_service.ListModelsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -610,7 +610,7 @@ def list_models( r"""Lists Models in a Location. Args: - request (google.cloud.aiplatform_v1.types.ListModelsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListModelsRequest, dict]): The request object. Request message for [ModelService.ListModels][google.cloud.aiplatform.v1.ModelService.ListModels]. parent (str): @@ -681,7 +681,7 @@ def list_models( def update_model( self, - request: model_service.UpdateModelRequest = None, + request: Union[model_service.UpdateModelRequest, dict] = None, *, model: gca_model.Model = None, update_mask: field_mask_pb2.FieldMask = None, @@ -692,7 +692,7 @@ def update_model( r"""Updates a Model. Args: - request (google.cloud.aiplatform_v1.types.UpdateModelRequest): + request (Union[google.cloud.aiplatform_v1.types.UpdateModelRequest, dict]): The request object. Request message for [ModelService.UpdateModel][google.cloud.aiplatform.v1.ModelService.UpdateModel]. model (google.cloud.aiplatform_v1.types.Model): @@ -763,7 +763,7 @@ def update_model( def delete_model( self, - request: model_service.DeleteModelRequest = None, + request: Union[model_service.DeleteModelRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -775,7 +775,7 @@ def delete_model( DeployedModels created from it. Args: - request (google.cloud.aiplatform_v1.types.DeleteModelRequest): + request (Union[google.cloud.aiplatform_v1.types.DeleteModelRequest, dict]): The request object. Request message for [ModelService.DeleteModel][google.cloud.aiplatform.v1.ModelService.DeleteModel]. name (str): @@ -858,7 +858,7 @@ def delete_model( def export_model( self, - request: model_service.ExportModelRequest = None, + request: Union[model_service.ExportModelRequest, dict] = None, *, name: str = None, output_config: model_service.ExportModelRequest.OutputConfig = None, @@ -872,7 +872,7 @@ def export_model( format][google.cloud.aiplatform.v1.Model.supported_export_formats]. Args: - request (google.cloud.aiplatform_v1.types.ExportModelRequest): + request (Union[google.cloud.aiplatform_v1.types.ExportModelRequest, dict]): The request object. Request message for [ModelService.ExportModel][google.cloud.aiplatform.v1.ModelService.ExportModel]. name (str): @@ -956,7 +956,7 @@ def export_model( def get_model_evaluation( self, - request: model_service.GetModelEvaluationRequest = None, + request: Union[model_service.GetModelEvaluationRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -966,7 +966,7 @@ def get_model_evaluation( r"""Gets a ModelEvaluation. Args: - request (google.cloud.aiplatform_v1.types.GetModelEvaluationRequest): + request (Union[google.cloud.aiplatform_v1.types.GetModelEvaluationRequest, dict]): The request object. Request message for [ModelService.GetModelEvaluation][google.cloud.aiplatform.v1.ModelService.GetModelEvaluation]. name (str): @@ -1030,7 +1030,7 @@ def get_model_evaluation( def list_model_evaluations( self, - request: model_service.ListModelEvaluationsRequest = None, + request: Union[model_service.ListModelEvaluationsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1040,7 +1040,7 @@ def list_model_evaluations( r"""Lists ModelEvaluations in a Model. Args: - request (google.cloud.aiplatform_v1.types.ListModelEvaluationsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListModelEvaluationsRequest, dict]): The request object. Request message for [ModelService.ListModelEvaluations][google.cloud.aiplatform.v1.ModelService.ListModelEvaluations]. parent (str): @@ -1111,7 +1111,7 @@ def list_model_evaluations( def get_model_evaluation_slice( self, - request: model_service.GetModelEvaluationSliceRequest = None, + request: Union[model_service.GetModelEvaluationSliceRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1121,7 +1121,7 @@ def get_model_evaluation_slice( r"""Gets a ModelEvaluationSlice. Args: - request (google.cloud.aiplatform_v1.types.GetModelEvaluationSliceRequest): + request (Union[google.cloud.aiplatform_v1.types.GetModelEvaluationSliceRequest, dict]): The request object. Request message for [ModelService.GetModelEvaluationSlice][google.cloud.aiplatform.v1.ModelService.GetModelEvaluationSlice]. name (str): @@ -1187,7 +1187,7 @@ def get_model_evaluation_slice( def list_model_evaluation_slices( self, - request: model_service.ListModelEvaluationSlicesRequest = None, + request: Union[model_service.ListModelEvaluationSlicesRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1197,7 +1197,7 @@ def list_model_evaluation_slices( r"""Lists ModelEvaluationSlices in a ModelEvaluation. Args: - request (google.cloud.aiplatform_v1.types.ListModelEvaluationSlicesRequest): + request (Union[google.cloud.aiplatform_v1.types.ListModelEvaluationSlicesRequest, dict]): The request object. Request message for [ModelService.ListModelEvaluationSlices][google.cloud.aiplatform.v1.ModelService.ListModelEvaluationSlices]. parent (str): diff --git a/google/cloud/aiplatform_v1/services/model_service/transports/base.py b/google/cloud/aiplatform_v1/services/model_service/transports/base.py index e17cbfc8e9..f69d881354 100644 --- a/google/cloud/aiplatform_v1/services/model_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/model_service/transports/base.py @@ -123,7 +123,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1/services/model_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/model_service/transports/grpc.py index 0dc6c9b4fb..6fd5a35c07 100644 --- a/google/cloud/aiplatform_v1/services/model_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/model_service/transports/grpc.py @@ -86,16 +86,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/model_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/model_service/transports/grpc_asyncio.py index f07d6cb76f..35ed67dd70 100644 --- a/google/cloud/aiplatform_v1/services/model_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/model_service/transports/grpc_asyncio.py @@ -133,16 +133,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/pipeline_service/client.py b/google/cloud/aiplatform_v1/services/pipeline_service/client.py index ec3fd4ccf8..5ece3f87bc 100644 --- a/google/cloud/aiplatform_v1/services/pipeline_service/client.py +++ b/google/cloud/aiplatform_v1/services/pipeline_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -514,7 +514,7 @@ def __init__( def create_training_pipeline( self, - request: pipeline_service.CreateTrainingPipelineRequest = None, + request: Union[pipeline_service.CreateTrainingPipelineRequest, dict] = None, *, parent: str = None, training_pipeline: gca_training_pipeline.TrainingPipeline = None, @@ -526,7 +526,7 @@ def create_training_pipeline( TrainingPipeline right away will be attempted to be run. Args: - request (google.cloud.aiplatform_v1.types.CreateTrainingPipelineRequest): + request (Union[google.cloud.aiplatform_v1.types.CreateTrainingPipelineRequest, dict]): The request object. Request message for [PipelineService.CreateTrainingPipeline][google.cloud.aiplatform.v1.PipelineService.CreateTrainingPipeline]. parent (str): @@ -601,7 +601,7 @@ def create_training_pipeline( def get_training_pipeline( self, - request: pipeline_service.GetTrainingPipelineRequest = None, + request: Union[pipeline_service.GetTrainingPipelineRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -611,7 +611,7 @@ def get_training_pipeline( r"""Gets a TrainingPipeline. Args: - request (google.cloud.aiplatform_v1.types.GetTrainingPipelineRequest): + request (Union[google.cloud.aiplatform_v1.types.GetTrainingPipelineRequest, dict]): The request object. Request message for [PipelineService.GetTrainingPipeline][google.cloud.aiplatform.v1.PipelineService.GetTrainingPipeline]. name (str): @@ -677,7 +677,7 @@ def get_training_pipeline( def list_training_pipelines( self, - request: pipeline_service.ListTrainingPipelinesRequest = None, + request: Union[pipeline_service.ListTrainingPipelinesRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -687,7 +687,7 @@ def list_training_pipelines( r"""Lists TrainingPipelines in a Location. Args: - request (google.cloud.aiplatform_v1.types.ListTrainingPipelinesRequest): + request (Union[google.cloud.aiplatform_v1.types.ListTrainingPipelinesRequest, dict]): The request object. Request message for [PipelineService.ListTrainingPipelines][google.cloud.aiplatform.v1.PipelineService.ListTrainingPipelines]. parent (str): @@ -758,7 +758,7 @@ def list_training_pipelines( def delete_training_pipeline( self, - request: pipeline_service.DeleteTrainingPipelineRequest = None, + request: Union[pipeline_service.DeleteTrainingPipelineRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -768,7 +768,7 @@ def delete_training_pipeline( r"""Deletes a TrainingPipeline. Args: - request (google.cloud.aiplatform_v1.types.DeleteTrainingPipelineRequest): + request (Union[google.cloud.aiplatform_v1.types.DeleteTrainingPipelineRequest, dict]): The request object. Request message for [PipelineService.DeleteTrainingPipeline][google.cloud.aiplatform.v1.PipelineService.DeleteTrainingPipeline]. name (str): @@ -851,7 +851,7 @@ def delete_training_pipeline( def cancel_training_pipeline( self, - request: pipeline_service.CancelTrainingPipelineRequest = None, + request: Union[pipeline_service.CancelTrainingPipelineRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -873,7 +873,7 @@ def cancel_training_pipeline( is set to ``CANCELLED``. Args: - request (google.cloud.aiplatform_v1.types.CancelTrainingPipelineRequest): + request (Union[google.cloud.aiplatform_v1.types.CancelTrainingPipelineRequest, dict]): The request object. Request message for [PipelineService.CancelTrainingPipeline][google.cloud.aiplatform.v1.PipelineService.CancelTrainingPipeline]. name (str): @@ -928,7 +928,7 @@ def cancel_training_pipeline( def create_pipeline_job( self, - request: pipeline_service.CreatePipelineJobRequest = None, + request: Union[pipeline_service.CreatePipelineJobRequest, dict] = None, *, parent: str = None, pipeline_job: gca_pipeline_job.PipelineJob = None, @@ -941,7 +941,7 @@ def create_pipeline_job( immediately when created. Args: - request (google.cloud.aiplatform_v1.types.CreatePipelineJobRequest): + request (Union[google.cloud.aiplatform_v1.types.CreatePipelineJobRequest, dict]): The request object. Request message for [PipelineService.CreatePipelineJob][google.cloud.aiplatform.v1.PipelineService.CreatePipelineJob]. parent (str): @@ -1023,7 +1023,7 @@ def create_pipeline_job( def get_pipeline_job( self, - request: pipeline_service.GetPipelineJobRequest = None, + request: Union[pipeline_service.GetPipelineJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1033,7 +1033,7 @@ def get_pipeline_job( r"""Gets a PipelineJob. Args: - request (google.cloud.aiplatform_v1.types.GetPipelineJobRequest): + request (Union[google.cloud.aiplatform_v1.types.GetPipelineJobRequest, dict]): The request object. Request message for [PipelineService.GetPipelineJob][google.cloud.aiplatform.v1.PipelineService.GetPipelineJob]. name (str): @@ -1094,7 +1094,7 @@ def get_pipeline_job( def list_pipeline_jobs( self, - request: pipeline_service.ListPipelineJobsRequest = None, + request: Union[pipeline_service.ListPipelineJobsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1104,7 +1104,7 @@ def list_pipeline_jobs( r"""Lists PipelineJobs in a Location. Args: - request (google.cloud.aiplatform_v1.types.ListPipelineJobsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListPipelineJobsRequest, dict]): The request object. Request message for [PipelineService.ListPipelineJobs][google.cloud.aiplatform.v1.PipelineService.ListPipelineJobs]. parent (str): @@ -1175,7 +1175,7 @@ def list_pipeline_jobs( def delete_pipeline_job( self, - request: pipeline_service.DeletePipelineJobRequest = None, + request: Union[pipeline_service.DeletePipelineJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1185,7 +1185,7 @@ def delete_pipeline_job( r"""Deletes a PipelineJob. Args: - request (google.cloud.aiplatform_v1.types.DeletePipelineJobRequest): + request (Union[google.cloud.aiplatform_v1.types.DeletePipelineJobRequest, dict]): The request object. Request message for [PipelineService.DeletePipelineJob][google.cloud.aiplatform.v1.PipelineService.DeletePipelineJob]. name (str): @@ -1268,7 +1268,7 @@ def delete_pipeline_job( def cancel_pipeline_job( self, - request: pipeline_service.CancelPipelineJobRequest = None, + request: Union[pipeline_service.CancelPipelineJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1290,7 +1290,7 @@ def cancel_pipeline_job( is set to ``CANCELLED``. Args: - request (google.cloud.aiplatform_v1.types.CancelPipelineJobRequest): + request (Union[google.cloud.aiplatform_v1.types.CancelPipelineJobRequest, dict]): The request object. Request message for [PipelineService.CancelPipelineJob][google.cloud.aiplatform.v1.PipelineService.CancelPipelineJob]. name (str): diff --git a/google/cloud/aiplatform_v1/services/pipeline_service/transports/base.py b/google/cloud/aiplatform_v1/services/pipeline_service/transports/base.py index 509e484654..1f04fcd8b2 100644 --- a/google/cloud/aiplatform_v1/services/pipeline_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/pipeline_service/transports/base.py @@ -124,7 +124,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc.py index 71adcdd6ca..6c52131ce9 100644 --- a/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc.py @@ -90,16 +90,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc_asyncio.py index a7712b19dd..743617cb0d 100644 --- a/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc_asyncio.py @@ -137,16 +137,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/prediction_service/client.py b/google/cloud/aiplatform_v1/services/prediction_service/client.py index ca81d27a36..3ba6f50029 100644 --- a/google/cloud/aiplatform_v1/services/prediction_service/client.py +++ b/google/cloud/aiplatform_v1/services/prediction_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -357,7 +357,7 @@ def __init__( def predict( self, - request: prediction_service.PredictRequest = None, + request: Union[prediction_service.PredictRequest, dict] = None, *, endpoint: str = None, instances: Sequence[struct_pb2.Value] = None, @@ -369,7 +369,7 @@ def predict( r"""Perform an online prediction. Args: - request (google.cloud.aiplatform_v1.types.PredictRequest): + request (Union[google.cloud.aiplatform_v1.types.PredictRequest, dict]): The request object. Request message for [PredictionService.Predict][google.cloud.aiplatform.v1.PredictionService.Predict]. endpoint (str): @@ -462,7 +462,7 @@ def predict( def raw_predict( self, - request: prediction_service.RawPredictRequest = None, + request: Union[prediction_service.RawPredictRequest, dict] = None, *, endpoint: str = None, http_body: httpbody_pb2.HttpBody = None, @@ -474,7 +474,7 @@ def raw_predict( payload. Args: - request (google.cloud.aiplatform_v1.types.RawPredictRequest): + request (Union[google.cloud.aiplatform_v1.types.RawPredictRequest, dict]): The request object. Request message for [PredictionService.RawPredict][google.cloud.aiplatform.v1.PredictionService.RawPredict]. endpoint (str): @@ -607,7 +607,7 @@ def raw_predict( def explain( self, - request: prediction_service.ExplainRequest = None, + request: Union[prediction_service.ExplainRequest, dict] = None, *, endpoint: str = None, instances: Sequence[struct_pb2.Value] = None, @@ -631,7 +631,7 @@ def explain( explanation_spec. Args: - request (google.cloud.aiplatform_v1.types.ExplainRequest): + request (Union[google.cloud.aiplatform_v1.types.ExplainRequest, dict]): The request object. Request message for [PredictionService.Explain][google.cloud.aiplatform.v1.PredictionService.Explain]. endpoint (str): diff --git a/google/cloud/aiplatform_v1/services/prediction_service/transports/base.py b/google/cloud/aiplatform_v1/services/prediction_service/transports/base.py index 5242b55bdf..04effa762f 100644 --- a/google/cloud/aiplatform_v1/services/prediction_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/prediction_service/transports/base.py @@ -118,7 +118,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc.py index d1e7b4896b..70364bdc19 100644 --- a/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc.py @@ -81,16 +81,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc_asyncio.py index 7e5bac844c..1739fc77df 100644 --- a/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc_asyncio.py @@ -128,16 +128,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/specialist_pool_service/client.py b/google/cloud/aiplatform_v1/services/specialist_pool_service/client.py index d1e3550b65..cc126d22b7 100644 --- a/google/cloud/aiplatform_v1/services/specialist_pool_service/client.py +++ b/google/cloud/aiplatform_v1/services/specialist_pool_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -367,7 +367,9 @@ def __init__( def create_specialist_pool( self, - request: specialist_pool_service.CreateSpecialistPoolRequest = None, + request: Union[ + specialist_pool_service.CreateSpecialistPoolRequest, dict + ] = None, *, parent: str = None, specialist_pool: gca_specialist_pool.SpecialistPool = None, @@ -378,7 +380,7 @@ def create_specialist_pool( r"""Creates a SpecialistPool. Args: - request (google.cloud.aiplatform_v1.types.CreateSpecialistPoolRequest): + request (Union[google.cloud.aiplatform_v1.types.CreateSpecialistPoolRequest, dict]): The request object. Request message for [SpecialistPoolService.CreateSpecialistPool][google.cloud.aiplatform.v1.SpecialistPoolService.CreateSpecialistPool]. parent (str): @@ -465,7 +467,7 @@ def create_specialist_pool( def get_specialist_pool( self, - request: specialist_pool_service.GetSpecialistPoolRequest = None, + request: Union[specialist_pool_service.GetSpecialistPoolRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -475,7 +477,7 @@ def get_specialist_pool( r"""Gets a SpecialistPool. Args: - request (google.cloud.aiplatform_v1.types.GetSpecialistPoolRequest): + request (Union[google.cloud.aiplatform_v1.types.GetSpecialistPoolRequest, dict]): The request object. Request message for [SpecialistPoolService.GetSpecialistPool][google.cloud.aiplatform.v1.SpecialistPoolService.GetSpecialistPool]. name (str): @@ -547,7 +549,7 @@ def get_specialist_pool( def list_specialist_pools( self, - request: specialist_pool_service.ListSpecialistPoolsRequest = None, + request: Union[specialist_pool_service.ListSpecialistPoolsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -557,7 +559,7 @@ def list_specialist_pools( r"""Lists SpecialistPools in a Location. Args: - request (google.cloud.aiplatform_v1.types.ListSpecialistPoolsRequest): + request (Union[google.cloud.aiplatform_v1.types.ListSpecialistPoolsRequest, dict]): The request object. Request message for [SpecialistPoolService.ListSpecialistPools][google.cloud.aiplatform.v1.SpecialistPoolService.ListSpecialistPools]. parent (str): @@ -628,7 +630,9 @@ def list_specialist_pools( def delete_specialist_pool( self, - request: specialist_pool_service.DeleteSpecialistPoolRequest = None, + request: Union[ + specialist_pool_service.DeleteSpecialistPoolRequest, dict + ] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -639,7 +643,7 @@ def delete_specialist_pool( in the pool. Args: - request (google.cloud.aiplatform_v1.types.DeleteSpecialistPoolRequest): + request (Union[google.cloud.aiplatform_v1.types.DeleteSpecialistPoolRequest, dict]): The request object. Request message for [SpecialistPoolService.DeleteSpecialistPool][google.cloud.aiplatform.v1.SpecialistPoolService.DeleteSpecialistPool]. name (str): @@ -722,7 +726,9 @@ def delete_specialist_pool( def update_specialist_pool( self, - request: specialist_pool_service.UpdateSpecialistPoolRequest = None, + request: Union[ + specialist_pool_service.UpdateSpecialistPoolRequest, dict + ] = None, *, specialist_pool: gca_specialist_pool.SpecialistPool = None, update_mask: field_mask_pb2.FieldMask = None, @@ -733,7 +739,7 @@ def update_specialist_pool( r"""Updates a SpecialistPool. Args: - request (google.cloud.aiplatform_v1.types.UpdateSpecialistPoolRequest): + request (Union[google.cloud.aiplatform_v1.types.UpdateSpecialistPoolRequest, dict]): The request object. Request message for [SpecialistPoolService.UpdateSpecialistPool][google.cloud.aiplatform.v1.SpecialistPoolService.UpdateSpecialistPool]. specialist_pool (google.cloud.aiplatform_v1.types.SpecialistPool): diff --git a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/base.py b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/base.py index 18624614ca..51ed89aee5 100644 --- a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/base.py @@ -120,7 +120,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc.py index a093b09eb5..986ef2c429 100644 --- a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc.py @@ -88,16 +88,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc_asyncio.py index 7fbab2dc5e..c09771976d 100644 --- a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc_asyncio.py @@ -135,16 +135,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1/services/vizier_service/__init__.py b/google/cloud/aiplatform_v1/services/vizier_service/__init__.py new file mode 100644 index 0000000000..5586edbbe2 --- /dev/null +++ b/google/cloud/aiplatform_v1/services/vizier_service/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from .client import VizierServiceClient +from .async_client import VizierServiceAsyncClient + +__all__ = ( + "VizierServiceClient", + "VizierServiceAsyncClient", +) diff --git a/google/cloud/aiplatform_v1/services/vizier_service/async_client.py b/google/cloud/aiplatform_v1/services/vizier_service/async_client.py new file mode 100644 index 0000000000..a78d1c4aa2 --- /dev/null +++ b/google/cloud/aiplatform_v1/services/vizier_service/async_client.py @@ -0,0 +1,1223 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +import functools +import re +from typing import Dict, Sequence, Tuple, Type, Union +import pkg_resources + +import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.aiplatform_v1.services.vizier_service import pagers +from google.cloud.aiplatform_v1.types import study +from google.cloud.aiplatform_v1.types import study as gca_study +from google.cloud.aiplatform_v1.types import vizier_service +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import VizierServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import VizierServiceGrpcAsyncIOTransport +from .client import VizierServiceClient + + +class VizierServiceAsyncClient: + """Vertex Vizier API. + Vizier service is a GCP service to solve blackbox optimization + problems, such as tuning machine learning hyperparameters and + searching over deep learning architectures. + """ + + _client: VizierServiceClient + + DEFAULT_ENDPOINT = VizierServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = VizierServiceClient.DEFAULT_MTLS_ENDPOINT + + custom_job_path = staticmethod(VizierServiceClient.custom_job_path) + parse_custom_job_path = staticmethod(VizierServiceClient.parse_custom_job_path) + study_path = staticmethod(VizierServiceClient.study_path) + parse_study_path = staticmethod(VizierServiceClient.parse_study_path) + trial_path = staticmethod(VizierServiceClient.trial_path) + parse_trial_path = staticmethod(VizierServiceClient.parse_trial_path) + common_billing_account_path = staticmethod( + VizierServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + VizierServiceClient.parse_common_billing_account_path + ) + common_folder_path = staticmethod(VizierServiceClient.common_folder_path) + parse_common_folder_path = staticmethod( + VizierServiceClient.parse_common_folder_path + ) + common_organization_path = staticmethod( + VizierServiceClient.common_organization_path + ) + parse_common_organization_path = staticmethod( + VizierServiceClient.parse_common_organization_path + ) + common_project_path = staticmethod(VizierServiceClient.common_project_path) + parse_common_project_path = staticmethod( + VizierServiceClient.parse_common_project_path + ) + common_location_path = staticmethod(VizierServiceClient.common_location_path) + parse_common_location_path = staticmethod( + VizierServiceClient.parse_common_location_path + ) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + VizierServiceAsyncClient: The constructed client. + """ + return VizierServiceClient.from_service_account_info.__func__(VizierServiceAsyncClient, info, *args, **kwargs) # type: ignore + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + VizierServiceAsyncClient: The constructed client. + """ + return VizierServiceClient.from_service_account_file.__func__(VizierServiceAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> VizierServiceTransport: + """Returns the transport used by the client instance. + + Returns: + VizierServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial( + type(VizierServiceClient).get_transport_class, type(VizierServiceClient) + ) + + def __init__( + self, + *, + credentials: ga_credentials.Credentials = None, + transport: Union[str, VizierServiceTransport] = "grpc_asyncio", + client_options: ClientOptions = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the vizier service client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.VizierServiceTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + """ + self._client = VizierServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + ) + + async def create_study( + self, + request: vizier_service.CreateStudyRequest = None, + *, + parent: str = None, + study: gca_study.Study = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gca_study.Study: + r"""Creates a Study. A resource name will be generated + after creation of the Study. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.CreateStudyRequest`): + The request object. Request message for + [VizierService.CreateStudy][google.cloud.aiplatform.v1.VizierService.CreateStudy]. + parent (:class:`str`): + Required. The resource name of the Location to create + the CustomJob in. Format: + ``projects/{project}/locations/{location}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + study (:class:`google.cloud.aiplatform_v1.types.Study`): + Required. The Study configuration + used to create the Study. + + This corresponds to the ``study`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Study: + A message representing a Study. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, study]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = vizier_service.CreateStudyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if study is not None: + request.study = study + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_study, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def get_study( + self, + request: vizier_service.GetStudyRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Study: + r"""Gets a Study by name. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.GetStudyRequest`): + The request object. Request message for + [VizierService.GetStudy][google.cloud.aiplatform.v1.VizierService.GetStudy]. + name (:class:`str`): + Required. The name of the Study resource. Format: + ``projects/{project}/locations/{location}/studies/{study}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Study: + A message representing a Study. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = vizier_service.GetStudyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_study, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_studies( + self, + request: vizier_service.ListStudiesRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListStudiesAsyncPager: + r"""Lists all the studies in a region for an associated + project. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.ListStudiesRequest`): + The request object. Request message for + [VizierService.ListStudies][google.cloud.aiplatform.v1.VizierService.ListStudies]. + parent (:class:`str`): + Required. The resource name of the Location to list the + Study from. Format: + ``projects/{project}/locations/{location}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.services.vizier_service.pagers.ListStudiesAsyncPager: + Response message for + [VizierService.ListStudies][google.cloud.aiplatform.v1.VizierService.ListStudies]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = vizier_service.ListStudiesRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_studies, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListStudiesAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_study( + self, + request: vizier_service.DeleteStudyRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a Study. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.DeleteStudyRequest`): + The request object. Request message for + [VizierService.DeleteStudy][google.cloud.aiplatform.v1.VizierService.DeleteStudy]. + name (:class:`str`): + Required. The name of the Study resource to be deleted. + Format: + ``projects/{project}/locations/{location}/studies/{study}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = vizier_service.DeleteStudyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_study, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + await rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + async def lookup_study( + self, + request: vizier_service.LookupStudyRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Study: + r"""Looks a study up using the user-defined display_name field + instead of the fully qualified resource name. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.LookupStudyRequest`): + The request object. Request message for + [VizierService.LookupStudy][google.cloud.aiplatform.v1.VizierService.LookupStudy]. + parent (:class:`str`): + Required. The resource name of the Location to get the + Study from. Format: + ``projects/{project}/locations/{location}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Study: + A message representing a Study. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = vizier_service.LookupStudyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.lookup_study, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def suggest_trials( + self, + request: vizier_service.SuggestTrialsRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Adds one or more Trials to a Study, with parameter values + suggested by Vertex Vizier. Returns a long-running operation + associated with the generation of Trial suggestions. When this + long-running operation succeeds, it will contain a + [SuggestTrialsResponse][google.cloud.ml.v1.SuggestTrialsResponse]. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.SuggestTrialsRequest`): + The request object. Request message for + [VizierService.SuggestTrials][google.cloud.aiplatform.v1.VizierService.SuggestTrials]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.aiplatform_v1.types.SuggestTrialsResponse` + Response message for + [VizierService.SuggestTrials][google.cloud.aiplatform.v1.VizierService.SuggestTrials]. + + """ + # Create or coerce a protobuf request object. + request = vizier_service.SuggestTrialsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.suggest_trials, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + vizier_service.SuggestTrialsResponse, + metadata_type=vizier_service.SuggestTrialsMetadata, + ) + + # Done; return the response. + return response + + async def create_trial( + self, + request: vizier_service.CreateTrialRequest = None, + *, + parent: str = None, + trial: study.Trial = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Trial: + r"""Adds a user provided Trial to a Study. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.CreateTrialRequest`): + The request object. Request message for + [VizierService.CreateTrial][google.cloud.aiplatform.v1.VizierService.CreateTrial]. + parent (:class:`str`): + Required. The resource name of the Study to create the + Trial in. Format: + ``projects/{project}/locations/{location}/studies/{study}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + trial (:class:`google.cloud.aiplatform_v1.types.Trial`): + Required. The Trial to create. + This corresponds to the ``trial`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Trial: + A message representing a Trial. A + Trial contains a unique set of + Parameters that has been or will be + evaluated, along with the objective + metrics got by running the Trial. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, trial]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = vizier_service.CreateTrialRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if trial is not None: + request.trial = trial + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_trial, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def get_trial( + self, + request: vizier_service.GetTrialRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Trial: + r"""Gets a Trial. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.GetTrialRequest`): + The request object. Request message for + [VizierService.GetTrial][google.cloud.aiplatform.v1.VizierService.GetTrial]. + name (:class:`str`): + Required. The name of the Trial resource. Format: + ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Trial: + A message representing a Trial. A + Trial contains a unique set of + Parameters that has been or will be + evaluated, along with the objective + metrics got by running the Trial. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = vizier_service.GetTrialRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_trial, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_trials( + self, + request: vizier_service.ListTrialsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListTrialsAsyncPager: + r"""Lists the Trials associated with a Study. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.ListTrialsRequest`): + The request object. Request message for + [VizierService.ListTrials][google.cloud.aiplatform.v1.VizierService.ListTrials]. + parent (:class:`str`): + Required. The resource name of the Study to list the + Trial from. Format: + ``projects/{project}/locations/{location}/studies/{study}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.services.vizier_service.pagers.ListTrialsAsyncPager: + Response message for + [VizierService.ListTrials][google.cloud.aiplatform.v1.VizierService.ListTrials]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = vizier_service.ListTrialsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_trials, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListTrialsAsyncPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + async def add_trial_measurement( + self, + request: vizier_service.AddTrialMeasurementRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Trial: + r"""Adds a measurement of the objective metrics to a + Trial. This measurement is assumed to have been taken + before the Trial is complete. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.AddTrialMeasurementRequest`): + The request object. Request message for + [VizierService.AddTrialMeasurement][google.cloud.aiplatform.v1.VizierService.AddTrialMeasurement]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Trial: + A message representing a Trial. A + Trial contains a unique set of + Parameters that has been or will be + evaluated, along with the objective + metrics got by running the Trial. + + """ + # Create or coerce a protobuf request object. + request = vizier_service.AddTrialMeasurementRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.add_trial_measurement, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("trial_name", request.trial_name),) + ), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def complete_trial( + self, + request: vizier_service.CompleteTrialRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Trial: + r"""Marks a Trial as complete. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.CompleteTrialRequest`): + The request object. Request message for + [VizierService.CompleteTrial][google.cloud.aiplatform.v1.VizierService.CompleteTrial]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Trial: + A message representing a Trial. A + Trial contains a unique set of + Parameters that has been or will be + evaluated, along with the objective + metrics got by running the Trial. + + """ + # Create or coerce a protobuf request object. + request = vizier_service.CompleteTrialRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.complete_trial, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def delete_trial( + self, + request: vizier_service.DeleteTrialRequest = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a Trial. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.DeleteTrialRequest`): + The request object. Request message for + [VizierService.DeleteTrial][google.cloud.aiplatform.v1.VizierService.DeleteTrial]. + name (:class:`str`): + Required. The Trial's name. Format: + ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = vizier_service.DeleteTrialRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_trial, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + await rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + async def check_trial_early_stopping_state( + self, + request: vizier_service.CheckTrialEarlyStoppingStateRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Checks whether a Trial should stop or not. Returns a + long-running operation. When the operation is successful, it + will contain a + [CheckTrialEarlyStoppingStateResponse][google.cloud.ml.v1.CheckTrialEarlyStoppingStateResponse]. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.CheckTrialEarlyStoppingStateRequest`): + The request object. Request message for + [VizierService.CheckTrialEarlyStoppingState][google.cloud.aiplatform.v1.VizierService.CheckTrialEarlyStoppingState]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.aiplatform_v1.types.CheckTrialEarlyStoppingStateResponse` + Response message for + [VizierService.CheckTrialEarlyStoppingState][google.cloud.aiplatform.v1.VizierService.CheckTrialEarlyStoppingState]. + + """ + # Create or coerce a protobuf request object. + request = vizier_service.CheckTrialEarlyStoppingStateRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.check_trial_early_stopping_state, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("trial_name", request.trial_name),) + ), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Wrap the response in an operation future. + response = operation_async.from_gapic( + response, + self._client._transport.operations_client, + vizier_service.CheckTrialEarlyStoppingStateResponse, + metadata_type=vizier_service.CheckTrialEarlyStoppingStateMetatdata, + ) + + # Done; return the response. + return response + + async def stop_trial( + self, + request: vizier_service.StopTrialRequest = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Trial: + r"""Stops a Trial. + + Args: + request (:class:`google.cloud.aiplatform_v1.types.StopTrialRequest`): + The request object. Request message for + [VizierService.StopTrial][google.cloud.aiplatform.v1.VizierService.StopTrial]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Trial: + A message representing a Trial. A + Trial contains a unique set of + Parameters that has been or will be + evaluated, along with the objective + metrics got by running the Trial. + + """ + # Create or coerce a protobuf request object. + request = vizier_service.StopTrialRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.stop_trial, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def list_optimal_trials( + self, + request: vizier_service.ListOptimalTrialsRequest = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> vizier_service.ListOptimalTrialsResponse: + r"""Lists the pareto-optimal Trials for multi-objective Study or the + optimal Trials for single-objective Study. The definition of + pareto-optimal can be checked in wiki page. + https://en.wikipedia.org/wiki/Pareto_efficiency + + Args: + request (:class:`google.cloud.aiplatform_v1.types.ListOptimalTrialsRequest`): + The request object. Request message for + [VizierService.ListOptimalTrials][google.cloud.aiplatform.v1.VizierService.ListOptimalTrials]. + parent (:class:`str`): + Required. The name of the Study that + the optimal Trial belongs to. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.ListOptimalTrialsResponse: + Response message for + [VizierService.ListOptimalTrials][google.cloud.aiplatform.v1.VizierService.ListOptimalTrials]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = vizier_service.ListOptimalTrialsRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_optimal_trials, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-aiplatform", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ("VizierServiceAsyncClient",) diff --git a/google/cloud/aiplatform_v1/services/vizier_service/client.py b/google/cloud/aiplatform_v1/services/vizier_service/client.py new file mode 100644 index 0000000000..a90ac36a70 --- /dev/null +++ b/google/cloud/aiplatform_v1/services/vizier_service/client.py @@ -0,0 +1,1445 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +from distutils import util +import os +import re +from typing import Dict, Optional, Sequence, Tuple, Type, Union +import pkg_resources + +from google.api_core import client_options as client_options_lib # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.aiplatform_v1.services.vizier_service import pagers +from google.cloud.aiplatform_v1.types import study +from google.cloud.aiplatform_v1.types import study as gca_study +from google.cloud.aiplatform_v1.types import vizier_service +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import VizierServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import VizierServiceGrpcTransport +from .transports.grpc_asyncio import VizierServiceGrpcAsyncIOTransport + + +class VizierServiceClientMeta(type): + """Metaclass for the VizierService client. + + This provides class-level methods for building and retrieving + support objects (e.g. transport) without polluting the client instance + objects. + """ + + _transport_registry = OrderedDict() # type: Dict[str, Type[VizierServiceTransport]] + _transport_registry["grpc"] = VizierServiceGrpcTransport + _transport_registry["grpc_asyncio"] = VizierServiceGrpcAsyncIOTransport + + def get_transport_class(cls, label: str = None,) -> Type[VizierServiceTransport]: + """Returns an appropriate transport class. + + Args: + label: The name of the desired transport. If none is + provided, then the first transport in the registry is used. + + Returns: + The transport class to use. + """ + # If a specific transport is requested, return that one. + if label: + return cls._transport_registry[label] + + # No transport is requested; return the default (that is, the first one + # in the dictionary). + return next(iter(cls._transport_registry.values())) + + +class VizierServiceClient(metaclass=VizierServiceClientMeta): + """Vertex Vizier API. + Vizier service is a GCP service to solve blackbox optimization + problems, such as tuning machine learning hyperparameters and + searching over deep learning architectures. + """ + + @staticmethod + def _get_default_mtls_endpoint(api_endpoint): + """Converts api endpoint to mTLS endpoint. + + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to + "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. + Args: + api_endpoint (Optional[str]): the api endpoint to convert. + Returns: + str: converted mTLS api endpoint. + """ + if not api_endpoint: + return api_endpoint + + mtls_endpoint_re = re.compile( + r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" + ) + + m = mtls_endpoint_re.match(api_endpoint) + name, mtls, sandbox, googledomain = m.groups() + if mtls or not googledomain: + return api_endpoint + + if sandbox: + return api_endpoint.replace( + "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" + ) + + return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") + + DEFAULT_ENDPOINT = "aiplatform.googleapis.com" + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore + DEFAULT_ENDPOINT + ) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + VizierServiceClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + VizierServiceClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file(filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> VizierServiceTransport: + """Returns the transport used by the client instance. + + Returns: + VizierServiceTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def custom_job_path(project: str, location: str, custom_job: str,) -> str: + """Returns a fully-qualified custom_job string.""" + return "projects/{project}/locations/{location}/customJobs/{custom_job}".format( + project=project, location=location, custom_job=custom_job, + ) + + @staticmethod + def parse_custom_job_path(path: str) -> Dict[str, str]: + """Parses a custom_job path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/customJobs/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def study_path(project: str, location: str, study: str,) -> str: + """Returns a fully-qualified study string.""" + return "projects/{project}/locations/{location}/studies/{study}".format( + project=project, location=location, study=study, + ) + + @staticmethod + def parse_study_path(path: str) -> Dict[str, str]: + """Parses a study path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/studies/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def trial_path(project: str, location: str, study: str, trial: str,) -> str: + """Returns a fully-qualified trial string.""" + return "projects/{project}/locations/{location}/studies/{study}/trials/{trial}".format( + project=project, location=location, study=study, trial=trial, + ) + + @staticmethod + def parse_trial_path(path: str) -> Dict[str, str]: + """Parses a trial path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/studies/(?P.+?)/trials/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def common_billing_account_path(billing_account: str,) -> str: + """Returns a fully-qualified billing_account string.""" + return "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str, str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str,) -> str: + """Returns a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder,) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str, str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str,) -> str: + """Returns a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization,) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str, str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str,) -> str: + """Returns a fully-qualified project string.""" + return "projects/{project}".format(project=project,) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str, str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_location_path(project: str, location: str,) -> str: + """Returns a fully-qualified location string.""" + return "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str, str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + + def __init__( + self, + *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, VizierServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the vizier service client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, VizierServiceTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be 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 ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + if isinstance(client_options, dict): + client_options = client_options_lib.from_dict(client_options) + if client_options is None: + client_options = client_options_lib.ClientOptions() + + # Create SSL credentials for mutual TLS if needed. + use_client_cert = bool( + util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + ) + + client_cert_source_func = None + is_mtls = False + if use_client_cert: + if client_options.client_cert_source: + is_mtls = True + client_cert_source_func = client_options.client_cert_source + else: + is_mtls = mtls.has_default_client_cert_source() + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + else: + use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_mtls_env == "never": + api_endpoint = self.DEFAULT_ENDPOINT + elif use_mtls_env == "always": + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + elif use_mtls_env == "auto": + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT + else: + raise MutualTLSChannelError( + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" + ) + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, VizierServiceTransport): + # transport is a VizierServiceTransport instance. + if credentials or client_options.credentials_file: + raise ValueError( + "When providing a transport instance, " + "provide its credentials directly." + ) + if client_options.scopes: + raise ValueError( + "When providing a transport instance, provide its scopes " + "directly." + ) + self._transport = transport + else: + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=api_endpoint, + scopes=client_options.scopes, + client_cert_source_for_mtls=client_cert_source_func, + quota_project_id=client_options.quota_project_id, + client_info=client_info, + always_use_jwt_access=( + Transport == type(self).get_transport_class("grpc") + or Transport == type(self).get_transport_class("grpc_asyncio") + ), + ) + + def create_study( + self, + request: Union[vizier_service.CreateStudyRequest, dict] = None, + *, + parent: str = None, + study: gca_study.Study = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gca_study.Study: + r"""Creates a Study. A resource name will be generated + after creation of the Study. + + Args: + request (Union[google.cloud.aiplatform_v1.types.CreateStudyRequest, dict]): + The request object. Request message for + [VizierService.CreateStudy][google.cloud.aiplatform.v1.VizierService.CreateStudy]. + parent (str): + Required. The resource name of the Location to create + the CustomJob in. Format: + ``projects/{project}/locations/{location}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + study (google.cloud.aiplatform_v1.types.Study): + Required. The Study configuration + used to create the Study. + + This corresponds to the ``study`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Study: + A message representing a Study. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, study]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.CreateStudyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.CreateStudyRequest): + request = vizier_service.CreateStudyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if study is not None: + request.study = study + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_study] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def get_study( + self, + request: Union[vizier_service.GetStudyRequest, dict] = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Study: + r"""Gets a Study by name. + + Args: + request (Union[google.cloud.aiplatform_v1.types.GetStudyRequest, dict]): + The request object. Request message for + [VizierService.GetStudy][google.cloud.aiplatform.v1.VizierService.GetStudy]. + name (str): + Required. The name of the Study resource. Format: + ``projects/{project}/locations/{location}/studies/{study}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Study: + A message representing a Study. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.GetStudyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.GetStudyRequest): + request = vizier_service.GetStudyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_study] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_studies( + self, + request: Union[vizier_service.ListStudiesRequest, dict] = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListStudiesPager: + r"""Lists all the studies in a region for an associated + project. + + Args: + request (Union[google.cloud.aiplatform_v1.types.ListStudiesRequest, dict]): + The request object. Request message for + [VizierService.ListStudies][google.cloud.aiplatform.v1.VizierService.ListStudies]. + parent (str): + Required. The resource name of the Location to list the + Study from. Format: + ``projects/{project}/locations/{location}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.services.vizier_service.pagers.ListStudiesPager: + Response message for + [VizierService.ListStudies][google.cloud.aiplatform.v1.VizierService.ListStudies]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.ListStudiesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.ListStudiesRequest): + request = vizier_service.ListStudiesRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_studies] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListStudiesPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_study( + self, + request: Union[vizier_service.DeleteStudyRequest, dict] = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a Study. + + Args: + request (Union[google.cloud.aiplatform_v1.types.DeleteStudyRequest, dict]): + The request object. Request message for + [VizierService.DeleteStudy][google.cloud.aiplatform.v1.VizierService.DeleteStudy]. + name (str): + Required. The name of the Study resource to be deleted. + Format: + ``projects/{project}/locations/{location}/studies/{study}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.DeleteStudyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.DeleteStudyRequest): + request = vizier_service.DeleteStudyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_study] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + def lookup_study( + self, + request: Union[vizier_service.LookupStudyRequest, dict] = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Study: + r"""Looks a study up using the user-defined display_name field + instead of the fully qualified resource name. + + Args: + request (Union[google.cloud.aiplatform_v1.types.LookupStudyRequest, dict]): + The request object. Request message for + [VizierService.LookupStudy][google.cloud.aiplatform.v1.VizierService.LookupStudy]. + parent (str): + Required. The resource name of the Location to get the + Study from. Format: + ``projects/{project}/locations/{location}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Study: + A message representing a Study. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.LookupStudyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.LookupStudyRequest): + request = vizier_service.LookupStudyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.lookup_study] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def suggest_trials( + self, + request: Union[vizier_service.SuggestTrialsRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Adds one or more Trials to a Study, with parameter values + suggested by Vertex Vizier. Returns a long-running operation + associated with the generation of Trial suggestions. When this + long-running operation succeeds, it will contain a + [SuggestTrialsResponse][google.cloud.ml.v1.SuggestTrialsResponse]. + + Args: + request (Union[google.cloud.aiplatform_v1.types.SuggestTrialsRequest, dict]): + The request object. Request message for + [VizierService.SuggestTrials][google.cloud.aiplatform.v1.VizierService.SuggestTrials]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.aiplatform_v1.types.SuggestTrialsResponse` + Response message for + [VizierService.SuggestTrials][google.cloud.aiplatform.v1.VizierService.SuggestTrials]. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.SuggestTrialsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.SuggestTrialsRequest): + request = vizier_service.SuggestTrialsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.suggest_trials] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + vizier_service.SuggestTrialsResponse, + metadata_type=vizier_service.SuggestTrialsMetadata, + ) + + # Done; return the response. + return response + + def create_trial( + self, + request: Union[vizier_service.CreateTrialRequest, dict] = None, + *, + parent: str = None, + trial: study.Trial = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Trial: + r"""Adds a user provided Trial to a Study. + + Args: + request (Union[google.cloud.aiplatform_v1.types.CreateTrialRequest, dict]): + The request object. Request message for + [VizierService.CreateTrial][google.cloud.aiplatform.v1.VizierService.CreateTrial]. + parent (str): + Required. The resource name of the Study to create the + Trial in. Format: + ``projects/{project}/locations/{location}/studies/{study}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + trial (google.cloud.aiplatform_v1.types.Trial): + Required. The Trial to create. + This corresponds to the ``trial`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Trial: + A message representing a Trial. A + Trial contains a unique set of + Parameters that has been or will be + evaluated, along with the objective + metrics got by running the Trial. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent, trial]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.CreateTrialRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.CreateTrialRequest): + request = vizier_service.CreateTrialRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if trial is not None: + request.trial = trial + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_trial] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def get_trial( + self, + request: Union[vizier_service.GetTrialRequest, dict] = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Trial: + r"""Gets a Trial. + + Args: + request (Union[google.cloud.aiplatform_v1.types.GetTrialRequest, dict]): + The request object. Request message for + [VizierService.GetTrial][google.cloud.aiplatform.v1.VizierService.GetTrial]. + name (str): + Required. The name of the Trial resource. Format: + ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Trial: + A message representing a Trial. A + Trial contains a unique set of + Parameters that has been or will be + evaluated, along with the objective + metrics got by running the Trial. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.GetTrialRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.GetTrialRequest): + request = vizier_service.GetTrialRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_trial] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_trials( + self, + request: Union[vizier_service.ListTrialsRequest, dict] = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListTrialsPager: + r"""Lists the Trials associated with a Study. + + Args: + request (Union[google.cloud.aiplatform_v1.types.ListTrialsRequest, dict]): + The request object. Request message for + [VizierService.ListTrials][google.cloud.aiplatform.v1.VizierService.ListTrials]. + parent (str): + Required. The resource name of the Study to list the + Trial from. Format: + ``projects/{project}/locations/{location}/studies/{study}`` + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.services.vizier_service.pagers.ListTrialsPager: + Response message for + [VizierService.ListTrials][google.cloud.aiplatform.v1.VizierService.ListTrials]. + + Iterating over this object will yield results and + resolve additional pages automatically. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.ListTrialsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.ListTrialsRequest): + request = vizier_service.ListTrialsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_trials] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListTrialsPager( + method=rpc, request=request, response=response, metadata=metadata, + ) + + # Done; return the response. + return response + + def add_trial_measurement( + self, + request: Union[vizier_service.AddTrialMeasurementRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Trial: + r"""Adds a measurement of the objective metrics to a + Trial. This measurement is assumed to have been taken + before the Trial is complete. + + Args: + request (Union[google.cloud.aiplatform_v1.types.AddTrialMeasurementRequest, dict]): + The request object. Request message for + [VizierService.AddTrialMeasurement][google.cloud.aiplatform.v1.VizierService.AddTrialMeasurement]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Trial: + A message representing a Trial. A + Trial contains a unique set of + Parameters that has been or will be + evaluated, along with the objective + metrics got by running the Trial. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.AddTrialMeasurementRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.AddTrialMeasurementRequest): + request = vizier_service.AddTrialMeasurementRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.add_trial_measurement] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("trial_name", request.trial_name),) + ), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def complete_trial( + self, + request: Union[vizier_service.CompleteTrialRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Trial: + r"""Marks a Trial as complete. + + Args: + request (Union[google.cloud.aiplatform_v1.types.CompleteTrialRequest, dict]): + The request object. Request message for + [VizierService.CompleteTrial][google.cloud.aiplatform.v1.VizierService.CompleteTrial]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Trial: + A message representing a Trial. A + Trial contains a unique set of + Parameters that has been or will be + evaluated, along with the objective + metrics got by running the Trial. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.CompleteTrialRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.CompleteTrialRequest): + request = vizier_service.CompleteTrialRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.complete_trial] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def delete_trial( + self, + request: Union[vizier_service.DeleteTrialRequest, dict] = None, + *, + name: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes a Trial. + + Args: + request (Union[google.cloud.aiplatform_v1.types.DeleteTrialRequest, dict]): + The request object. Request message for + [VizierService.DeleteTrial][google.cloud.aiplatform.v1.VizierService.DeleteTrial]. + name (str): + Required. The Trial's name. Format: + ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.DeleteTrialRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.DeleteTrialRequest): + request = vizier_service.DeleteTrialRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_trial] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + rpc( + request, retry=retry, timeout=timeout, metadata=metadata, + ) + + def check_trial_early_stopping_state( + self, + request: Union[vizier_service.CheckTrialEarlyStoppingStateRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation.Operation: + r"""Checks whether a Trial should stop or not. Returns a + long-running operation. When the operation is successful, it + will contain a + [CheckTrialEarlyStoppingStateResponse][google.cloud.ml.v1.CheckTrialEarlyStoppingStateResponse]. + + Args: + request (Union[google.cloud.aiplatform_v1.types.CheckTrialEarlyStoppingStateRequest, dict]): + The request object. Request message for + [VizierService.CheckTrialEarlyStoppingState][google.cloud.aiplatform.v1.VizierService.CheckTrialEarlyStoppingState]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.aiplatform_v1.types.CheckTrialEarlyStoppingStateResponse` + Response message for + [VizierService.CheckTrialEarlyStoppingState][google.cloud.aiplatform.v1.VizierService.CheckTrialEarlyStoppingState]. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.CheckTrialEarlyStoppingStateRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.CheckTrialEarlyStoppingStateRequest): + request = vizier_service.CheckTrialEarlyStoppingStateRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.check_trial_early_stopping_state + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("trial_name", request.trial_name),) + ), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Wrap the response in an operation future. + response = operation.from_gapic( + response, + self._transport.operations_client, + vizier_service.CheckTrialEarlyStoppingStateResponse, + metadata_type=vizier_service.CheckTrialEarlyStoppingStateMetatdata, + ) + + # Done; return the response. + return response + + def stop_trial( + self, + request: Union[vizier_service.StopTrialRequest, dict] = None, + *, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> study.Trial: + r"""Stops a Trial. + + Args: + request (Union[google.cloud.aiplatform_v1.types.StopTrialRequest, dict]): + The request object. Request message for + [VizierService.StopTrial][google.cloud.aiplatform.v1.VizierService.StopTrial]. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.Trial: + A message representing a Trial. A + Trial contains a unique set of + Parameters that has been or will be + evaluated, along with the objective + metrics got by running the Trial. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.StopTrialRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.StopTrialRequest): + request = vizier_service.StopTrialRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.stop_trial] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_optimal_trials( + self, + request: Union[vizier_service.ListOptimalTrialsRequest, dict] = None, + *, + parent: str = None, + retry: retries.Retry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> vizier_service.ListOptimalTrialsResponse: + r"""Lists the pareto-optimal Trials for multi-objective Study or the + optimal Trials for single-objective Study. The definition of + pareto-optimal can be checked in wiki page. + https://en.wikipedia.org/wiki/Pareto_efficiency + + Args: + request (Union[google.cloud.aiplatform_v1.types.ListOptimalTrialsRequest, dict]): + The request object. Request message for + [VizierService.ListOptimalTrials][google.cloud.aiplatform.v1.VizierService.ListOptimalTrials]. + parent (str): + Required. The name of the Study that + the optimal Trial belongs to. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + google.cloud.aiplatform_v1.types.ListOptimalTrialsResponse: + Response message for + [VizierService.ListOptimalTrials][google.cloud.aiplatform.v1.VizierService.ListOptimalTrials]. + + """ + # Create or coerce a protobuf request object. + # Sanity check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a vizier_service.ListOptimalTrialsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, vizier_service.ListOptimalTrialsRequest): + request = vizier_service.ListOptimalTrialsRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_optimal_trials] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)), + ) + + # Send the request. + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-aiplatform", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + + +__all__ = ("VizierServiceClient",) diff --git a/google/cloud/aiplatform_v1/services/vizier_service/pagers.py b/google/cloud/aiplatform_v1/services/vizier_service/pagers.py new file mode 100644 index 0000000000..cf31a35ecc --- /dev/null +++ b/google/cloud/aiplatform_v1/services/vizier_service/pagers.py @@ -0,0 +1,284 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from typing import ( + Any, + AsyncIterable, + Awaitable, + Callable, + Iterable, + Sequence, + Tuple, + Optional, +) + +from google.cloud.aiplatform_v1.types import study +from google.cloud.aiplatform_v1.types import vizier_service + + +class ListStudiesPager: + """A pager for iterating through ``list_studies`` requests. + + This class thinly wraps an initial + :class:`google.cloud.aiplatform_v1.types.ListStudiesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``studies`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListStudies`` requests and continue to iterate + through the ``studies`` field on the + corresponding responses. + + All the usual :class:`google.cloud.aiplatform_v1.types.ListStudiesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., vizier_service.ListStudiesResponse], + request: vizier_service.ListStudiesRequest, + response: vizier_service.ListStudiesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.aiplatform_v1.types.ListStudiesRequest): + The initial request object. + response (google.cloud.aiplatform_v1.types.ListStudiesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = vizier_service.ListStudiesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[vizier_service.ListStudiesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[study.Study]: + for page in self.pages: + yield from page.studies + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListStudiesAsyncPager: + """A pager for iterating through ``list_studies`` requests. + + This class thinly wraps an initial + :class:`google.cloud.aiplatform_v1.types.ListStudiesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``studies`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListStudies`` requests and continue to iterate + through the ``studies`` field on the + corresponding responses. + + All the usual :class:`google.cloud.aiplatform_v1.types.ListStudiesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[vizier_service.ListStudiesResponse]], + request: vizier_service.ListStudiesRequest, + response: vizier_service.ListStudiesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.aiplatform_v1.types.ListStudiesRequest): + The initial request object. + response (google.cloud.aiplatform_v1.types.ListStudiesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = vizier_service.ListStudiesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[vizier_service.ListStudiesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[study.Study]: + async def async_generator(): + async for page in self.pages: + for response in page.studies: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListTrialsPager: + """A pager for iterating through ``list_trials`` requests. + + This class thinly wraps an initial + :class:`google.cloud.aiplatform_v1.types.ListTrialsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``trials`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListTrials`` requests and continue to iterate + through the ``trials`` field on the + corresponding responses. + + All the usual :class:`google.cloud.aiplatform_v1.types.ListTrialsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., vizier_service.ListTrialsResponse], + request: vizier_service.ListTrialsRequest, + response: vizier_service.ListTrialsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.aiplatform_v1.types.ListTrialsRequest): + The initial request object. + response (google.cloud.aiplatform_v1.types.ListTrialsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = vizier_service.ListTrialsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterable[vizier_service.ListTrialsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterable[study.Trial]: + for page in self.pages: + yield from page.trials + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListTrialsAsyncPager: + """A pager for iterating through ``list_trials`` requests. + + This class thinly wraps an initial + :class:`google.cloud.aiplatform_v1.types.ListTrialsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``trials`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListTrials`` requests and continue to iterate + through the ``trials`` field on the + corresponding responses. + + All the usual :class:`google.cloud.aiplatform_v1.types.ListTrialsResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., Awaitable[vizier_service.ListTrialsResponse]], + request: vizier_service.ListTrialsRequest, + response: vizier_service.ListTrialsResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.aiplatform_v1.types.ListTrialsRequest): + The initial request object. + response (google.cloud.aiplatform_v1.types.ListTrialsResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = vizier_service.ListTrialsRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterable[vizier_service.ListTrialsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterable[study.Trial]: + async def async_generator(): + async for page in self.pages: + for response in page.trials: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/google/cloud/aiplatform_v1/services/vizier_service/transports/__init__.py b/google/cloud/aiplatform_v1/services/vizier_service/transports/__init__.py new file mode 100644 index 0000000000..4fdc0272ee --- /dev/null +++ b/google/cloud/aiplatform_v1/services/vizier_service/transports/__init__.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from collections import OrderedDict +from typing import Dict, Type + +from .base import VizierServiceTransport +from .grpc import VizierServiceGrpcTransport +from .grpc_asyncio import VizierServiceGrpcAsyncIOTransport + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[VizierServiceTransport]] +_transport_registry["grpc"] = VizierServiceGrpcTransport +_transport_registry["grpc_asyncio"] = VizierServiceGrpcAsyncIOTransport + +__all__ = ( + "VizierServiceTransport", + "VizierServiceGrpcTransport", + "VizierServiceGrpcAsyncIOTransport", +) diff --git a/google/cloud/aiplatform_v1/services/vizier_service/transports/base.py b/google/cloud/aiplatform_v1/services/vizier_service/transports/base.py new file mode 100644 index 0000000000..0c56af5452 --- /dev/null +++ b/google/cloud/aiplatform_v1/services/vizier_service/transports/base.py @@ -0,0 +1,358 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version +import pkg_resources + +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore +from google.api_core import gapic_v1 # type: ignore +from google.api_core import retry as retries # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.aiplatform_v1.types import study +from google.cloud.aiplatform_v1.types import study as gca_study +from google.cloud.aiplatform_v1.types import vizier_service +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore + +try: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=pkg_resources.get_distribution( + "google-cloud-aiplatform", + ).version, + ) +except pkg_resources.DistributionNotFound: + DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + + +class VizierServiceTransport(abc.ABC): + """Abstract transport class for VizierService.""" + + AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + + DEFAULT_HOST: str = "aiplatform.googleapis.com" + + def __init__( + self, + *, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + 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 ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ":" not in host: + host += ":443" + self._host = host + + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + + # Save the scopes. + self._scopes = scopes + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise core_exceptions.DuplicateCredentialArgs( + "'credentials_file' and 'credentials' are mutually exclusive" + ) + + if credentials_file is not None: + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id + ) + + elif credentials is None: + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id + ) + + # If the credentials are service account credentials, then always try to use self signed JWT. + if ( + always_use_jwt_access + and isinstance(credentials, service_account.Credentials) + and hasattr(service_account.Credentials, "with_always_use_jwt_access") + ): + credentials = credentials.with_always_use_jwt_access(True) + + # Save the credentials. + self._credentials = credentials + + # TODO(busunkim): This method is in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-auth is increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.create_study: gapic_v1.method.wrap_method( + self.create_study, default_timeout=None, client_info=client_info, + ), + self.get_study: gapic_v1.method.wrap_method( + self.get_study, default_timeout=None, client_info=client_info, + ), + self.list_studies: gapic_v1.method.wrap_method( + self.list_studies, default_timeout=None, client_info=client_info, + ), + self.delete_study: gapic_v1.method.wrap_method( + self.delete_study, default_timeout=None, client_info=client_info, + ), + self.lookup_study: gapic_v1.method.wrap_method( + self.lookup_study, default_timeout=None, client_info=client_info, + ), + self.suggest_trials: gapic_v1.method.wrap_method( + self.suggest_trials, default_timeout=None, client_info=client_info, + ), + self.create_trial: gapic_v1.method.wrap_method( + self.create_trial, default_timeout=None, client_info=client_info, + ), + self.get_trial: gapic_v1.method.wrap_method( + self.get_trial, default_timeout=None, client_info=client_info, + ), + self.list_trials: gapic_v1.method.wrap_method( + self.list_trials, default_timeout=None, client_info=client_info, + ), + self.add_trial_measurement: gapic_v1.method.wrap_method( + self.add_trial_measurement, + default_timeout=None, + client_info=client_info, + ), + self.complete_trial: gapic_v1.method.wrap_method( + self.complete_trial, default_timeout=None, client_info=client_info, + ), + self.delete_trial: gapic_v1.method.wrap_method( + self.delete_trial, default_timeout=None, client_info=client_info, + ), + self.check_trial_early_stopping_state: gapic_v1.method.wrap_method( + self.check_trial_early_stopping_state, + default_timeout=None, + client_info=client_info, + ), + self.stop_trial: gapic_v1.method.wrap_method( + self.stop_trial, default_timeout=None, client_info=client_info, + ), + self.list_optimal_trials: gapic_v1.method.wrap_method( + self.list_optimal_trials, default_timeout=None, client_info=client_info, + ), + } + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Return the client designed to process long-running operations.""" + raise NotImplementedError() + + @property + def create_study( + self, + ) -> Callable[ + [vizier_service.CreateStudyRequest], + Union[gca_study.Study, Awaitable[gca_study.Study]], + ]: + raise NotImplementedError() + + @property + def get_study( + self, + ) -> Callable[ + [vizier_service.GetStudyRequest], Union[study.Study, Awaitable[study.Study]] + ]: + raise NotImplementedError() + + @property + def list_studies( + self, + ) -> Callable[ + [vizier_service.ListStudiesRequest], + Union[ + vizier_service.ListStudiesResponse, + Awaitable[vizier_service.ListStudiesResponse], + ], + ]: + raise NotImplementedError() + + @property + def delete_study( + self, + ) -> Callable[ + [vizier_service.DeleteStudyRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def lookup_study( + self, + ) -> Callable[ + [vizier_service.LookupStudyRequest], Union[study.Study, Awaitable[study.Study]] + ]: + raise NotImplementedError() + + @property + def suggest_trials( + self, + ) -> Callable[ + [vizier_service.SuggestTrialsRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def create_trial( + self, + ) -> Callable[ + [vizier_service.CreateTrialRequest], Union[study.Trial, Awaitable[study.Trial]] + ]: + raise NotImplementedError() + + @property + def get_trial( + self, + ) -> Callable[ + [vizier_service.GetTrialRequest], Union[study.Trial, Awaitable[study.Trial]] + ]: + raise NotImplementedError() + + @property + def list_trials( + self, + ) -> Callable[ + [vizier_service.ListTrialsRequest], + Union[ + vizier_service.ListTrialsResponse, + Awaitable[vizier_service.ListTrialsResponse], + ], + ]: + raise NotImplementedError() + + @property + def add_trial_measurement( + self, + ) -> Callable[ + [vizier_service.AddTrialMeasurementRequest], + Union[study.Trial, Awaitable[study.Trial]], + ]: + raise NotImplementedError() + + @property + def complete_trial( + self, + ) -> Callable[ + [vizier_service.CompleteTrialRequest], + Union[study.Trial, Awaitable[study.Trial]], + ]: + raise NotImplementedError() + + @property + def delete_trial( + self, + ) -> Callable[ + [vizier_service.DeleteTrialRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + + @property + def check_trial_early_stopping_state( + self, + ) -> Callable[ + [vizier_service.CheckTrialEarlyStoppingStateRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + + @property + def stop_trial( + self, + ) -> Callable[ + [vizier_service.StopTrialRequest], Union[study.Trial, Awaitable[study.Trial]] + ]: + raise NotImplementedError() + + @property + def list_optimal_trials( + self, + ) -> Callable[ + [vizier_service.ListOptimalTrialsRequest], + Union[ + vizier_service.ListOptimalTrialsResponse, + Awaitable[vizier_service.ListOptimalTrialsResponse], + ], + ]: + raise NotImplementedError() + + +__all__ = ("VizierServiceTransport",) diff --git a/google/cloud/aiplatform_v1/services/vizier_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/vizier_service/transports/grpc.py new file mode 100644 index 0000000000..f9630cd824 --- /dev/null +++ b/google/cloud/aiplatform_v1/services/vizier_service/transports/grpc.py @@ -0,0 +1,663 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.aiplatform_v1.types import study +from google.cloud.aiplatform_v1.types import study as gca_study +from google.cloud.aiplatform_v1.types import vizier_service +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from .base import VizierServiceTransport, DEFAULT_CLIENT_INFO + + +class VizierServiceGrpcTransport(VizierServiceTransport): + """gRPC backend transport for VizierService. + + Vertex Vizier API. + Vizier service is a GCP service to solve blackbox optimization + problems, such as tuning machine learning hyperparameters and + searching over deep learning architectures. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + + _stubs: Dict[str, Callable] + + def __init__( + self, + *, + host: str = "aiplatform.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + channel: grpc.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or application default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for the grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure a mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + 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 ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel( + cls, + host: str = "aiplatform.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.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. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs, + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + + # Return the client from cache. + return self._operations_client + + @property + def create_study( + self, + ) -> Callable[[vizier_service.CreateStudyRequest], gca_study.Study]: + r"""Return a callable for the create study method over gRPC. + + Creates a Study. A resource name will be generated + after creation of the Study. + + Returns: + Callable[[~.CreateStudyRequest], + ~.Study]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_study" not in self._stubs: + self._stubs["create_study"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/CreateStudy", + request_serializer=vizier_service.CreateStudyRequest.serialize, + response_deserializer=gca_study.Study.deserialize, + ) + return self._stubs["create_study"] + + @property + def get_study(self) -> Callable[[vizier_service.GetStudyRequest], study.Study]: + r"""Return a callable for the get study method over gRPC. + + Gets a Study by name. + + Returns: + Callable[[~.GetStudyRequest], + ~.Study]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_study" not in self._stubs: + self._stubs["get_study"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/GetStudy", + request_serializer=vizier_service.GetStudyRequest.serialize, + response_deserializer=study.Study.deserialize, + ) + return self._stubs["get_study"] + + @property + def list_studies( + self, + ) -> Callable[ + [vizier_service.ListStudiesRequest], vizier_service.ListStudiesResponse + ]: + r"""Return a callable for the list studies method over gRPC. + + Lists all the studies in a region for an associated + project. + + Returns: + Callable[[~.ListStudiesRequest], + ~.ListStudiesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_studies" not in self._stubs: + self._stubs["list_studies"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/ListStudies", + request_serializer=vizier_service.ListStudiesRequest.serialize, + response_deserializer=vizier_service.ListStudiesResponse.deserialize, + ) + return self._stubs["list_studies"] + + @property + def delete_study( + self, + ) -> Callable[[vizier_service.DeleteStudyRequest], empty_pb2.Empty]: + r"""Return a callable for the delete study method over gRPC. + + Deletes a Study. + + Returns: + Callable[[~.DeleteStudyRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_study" not in self._stubs: + self._stubs["delete_study"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/DeleteStudy", + request_serializer=vizier_service.DeleteStudyRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_study"] + + @property + def lookup_study( + self, + ) -> Callable[[vizier_service.LookupStudyRequest], study.Study]: + r"""Return a callable for the lookup study method over gRPC. + + Looks a study up using the user-defined display_name field + instead of the fully qualified resource name. + + Returns: + Callable[[~.LookupStudyRequest], + ~.Study]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "lookup_study" not in self._stubs: + self._stubs["lookup_study"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/LookupStudy", + request_serializer=vizier_service.LookupStudyRequest.serialize, + response_deserializer=study.Study.deserialize, + ) + return self._stubs["lookup_study"] + + @property + def suggest_trials( + self, + ) -> Callable[[vizier_service.SuggestTrialsRequest], operations_pb2.Operation]: + r"""Return a callable for the suggest trials method over gRPC. + + Adds one or more Trials to a Study, with parameter values + suggested by Vertex Vizier. Returns a long-running operation + associated with the generation of Trial suggestions. When this + long-running operation succeeds, it will contain a + [SuggestTrialsResponse][google.cloud.ml.v1.SuggestTrialsResponse]. + + Returns: + Callable[[~.SuggestTrialsRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "suggest_trials" not in self._stubs: + self._stubs["suggest_trials"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/SuggestTrials", + request_serializer=vizier_service.SuggestTrialsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["suggest_trials"] + + @property + def create_trial( + self, + ) -> Callable[[vizier_service.CreateTrialRequest], study.Trial]: + r"""Return a callable for the create trial method over gRPC. + + Adds a user provided Trial to a Study. + + Returns: + Callable[[~.CreateTrialRequest], + ~.Trial]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_trial" not in self._stubs: + self._stubs["create_trial"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/CreateTrial", + request_serializer=vizier_service.CreateTrialRequest.serialize, + response_deserializer=study.Trial.deserialize, + ) + return self._stubs["create_trial"] + + @property + def get_trial(self) -> Callable[[vizier_service.GetTrialRequest], study.Trial]: + r"""Return a callable for the get trial method over gRPC. + + Gets a Trial. + + Returns: + Callable[[~.GetTrialRequest], + ~.Trial]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_trial" not in self._stubs: + self._stubs["get_trial"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/GetTrial", + request_serializer=vizier_service.GetTrialRequest.serialize, + response_deserializer=study.Trial.deserialize, + ) + return self._stubs["get_trial"] + + @property + def list_trials( + self, + ) -> Callable[ + [vizier_service.ListTrialsRequest], vizier_service.ListTrialsResponse + ]: + r"""Return a callable for the list trials method over gRPC. + + Lists the Trials associated with a Study. + + Returns: + Callable[[~.ListTrialsRequest], + ~.ListTrialsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_trials" not in self._stubs: + self._stubs["list_trials"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/ListTrials", + request_serializer=vizier_service.ListTrialsRequest.serialize, + response_deserializer=vizier_service.ListTrialsResponse.deserialize, + ) + return self._stubs["list_trials"] + + @property + def add_trial_measurement( + self, + ) -> Callable[[vizier_service.AddTrialMeasurementRequest], study.Trial]: + r"""Return a callable for the add trial measurement method over gRPC. + + Adds a measurement of the objective metrics to a + Trial. This measurement is assumed to have been taken + before the Trial is complete. + + Returns: + Callable[[~.AddTrialMeasurementRequest], + ~.Trial]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "add_trial_measurement" not in self._stubs: + self._stubs["add_trial_measurement"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/AddTrialMeasurement", + request_serializer=vizier_service.AddTrialMeasurementRequest.serialize, + response_deserializer=study.Trial.deserialize, + ) + return self._stubs["add_trial_measurement"] + + @property + def complete_trial( + self, + ) -> Callable[[vizier_service.CompleteTrialRequest], study.Trial]: + r"""Return a callable for the complete trial method over gRPC. + + Marks a Trial as complete. + + Returns: + Callable[[~.CompleteTrialRequest], + ~.Trial]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "complete_trial" not in self._stubs: + self._stubs["complete_trial"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/CompleteTrial", + request_serializer=vizier_service.CompleteTrialRequest.serialize, + response_deserializer=study.Trial.deserialize, + ) + return self._stubs["complete_trial"] + + @property + def delete_trial( + self, + ) -> Callable[[vizier_service.DeleteTrialRequest], empty_pb2.Empty]: + r"""Return a callable for the delete trial method over gRPC. + + Deletes a Trial. + + Returns: + Callable[[~.DeleteTrialRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_trial" not in self._stubs: + self._stubs["delete_trial"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/DeleteTrial", + request_serializer=vizier_service.DeleteTrialRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_trial"] + + @property + def check_trial_early_stopping_state( + self, + ) -> Callable[ + [vizier_service.CheckTrialEarlyStoppingStateRequest], operations_pb2.Operation + ]: + r"""Return a callable for the check trial early stopping + state method over gRPC. + + Checks whether a Trial should stop or not. Returns a + long-running operation. When the operation is successful, it + will contain a + [CheckTrialEarlyStoppingStateResponse][google.cloud.ml.v1.CheckTrialEarlyStoppingStateResponse]. + + Returns: + Callable[[~.CheckTrialEarlyStoppingStateRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "check_trial_early_stopping_state" not in self._stubs: + self._stubs[ + "check_trial_early_stopping_state" + ] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/CheckTrialEarlyStoppingState", + request_serializer=vizier_service.CheckTrialEarlyStoppingStateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["check_trial_early_stopping_state"] + + @property + def stop_trial(self) -> Callable[[vizier_service.StopTrialRequest], study.Trial]: + r"""Return a callable for the stop trial method over gRPC. + + Stops a Trial. + + Returns: + Callable[[~.StopTrialRequest], + ~.Trial]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "stop_trial" not in self._stubs: + self._stubs["stop_trial"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/StopTrial", + request_serializer=vizier_service.StopTrialRequest.serialize, + response_deserializer=study.Trial.deserialize, + ) + return self._stubs["stop_trial"] + + @property + def list_optimal_trials( + self, + ) -> Callable[ + [vizier_service.ListOptimalTrialsRequest], + vizier_service.ListOptimalTrialsResponse, + ]: + r"""Return a callable for the list optimal trials method over gRPC. + + Lists the pareto-optimal Trials for multi-objective Study or the + optimal Trials for single-objective Study. The definition of + pareto-optimal can be checked in wiki page. + https://en.wikipedia.org/wiki/Pareto_efficiency + + Returns: + Callable[[~.ListOptimalTrialsRequest], + ~.ListOptimalTrialsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_optimal_trials" not in self._stubs: + self._stubs["list_optimal_trials"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/ListOptimalTrials", + request_serializer=vizier_service.ListOptimalTrialsRequest.serialize, + response_deserializer=vizier_service.ListOptimalTrialsResponse.deserialize, + ) + return self._stubs["list_optimal_trials"] + + +__all__ = ("VizierServiceGrpcTransport",) diff --git a/google/cloud/aiplatform_v1/services/vizier_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/vizier_service/transports/grpc_asyncio.py new file mode 100644 index 0000000000..c5f83bbd25 --- /dev/null +++ b/google/cloud/aiplatform_v1/services/vizier_service/transports/grpc_asyncio.py @@ -0,0 +1,678 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import operations_v1 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.aiplatform_v1.types import study +from google.cloud.aiplatform_v1.types import study as gca_study +from google.cloud.aiplatform_v1.types import vizier_service +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from .base import VizierServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import VizierServiceGrpcTransport + + +class VizierServiceGrpcAsyncIOTransport(VizierServiceTransport): + """gRPC AsyncIO backend transport for VizierService. + + Vertex Vizier API. + Vizier service is a GCP service to solve blackbox optimization + problems, such as tuning machine learning hyperparameters and + searching over deep learning architectures. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + + _grpc_channel: aio.Channel + _stubs: Dict[str, Callable] = {} + + @classmethod + def create_channel( + cls, + host: str = "aiplatform.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs, + ) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.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. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs, + ) + + def __init__( + self, + *, + host: str = "aiplatform.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: aio.Channel = None, + api_mtls_endpoint: str = None, + client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, + ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id=None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or application default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for the grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure a mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + 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 ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + credentials=self._credentials, + credentials_file=credentials_file, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def operations_client(self) -> operations_v1.OperationsAsyncClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Sanity check: Only create a new client if we do not already have one. + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( + self.grpc_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_study( + self, + ) -> Callable[[vizier_service.CreateStudyRequest], Awaitable[gca_study.Study]]: + r"""Return a callable for the create study method over gRPC. + + Creates a Study. A resource name will be generated + after creation of the Study. + + Returns: + Callable[[~.CreateStudyRequest], + Awaitable[~.Study]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_study" not in self._stubs: + self._stubs["create_study"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/CreateStudy", + request_serializer=vizier_service.CreateStudyRequest.serialize, + response_deserializer=gca_study.Study.deserialize, + ) + return self._stubs["create_study"] + + @property + def get_study( + self, + ) -> Callable[[vizier_service.GetStudyRequest], Awaitable[study.Study]]: + r"""Return a callable for the get study method over gRPC. + + Gets a Study by name. + + Returns: + Callable[[~.GetStudyRequest], + Awaitable[~.Study]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_study" not in self._stubs: + self._stubs["get_study"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/GetStudy", + request_serializer=vizier_service.GetStudyRequest.serialize, + response_deserializer=study.Study.deserialize, + ) + return self._stubs["get_study"] + + @property + def list_studies( + self, + ) -> Callable[ + [vizier_service.ListStudiesRequest], + Awaitable[vizier_service.ListStudiesResponse], + ]: + r"""Return a callable for the list studies method over gRPC. + + Lists all the studies in a region for an associated + project. + + Returns: + Callable[[~.ListStudiesRequest], + Awaitable[~.ListStudiesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_studies" not in self._stubs: + self._stubs["list_studies"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/ListStudies", + request_serializer=vizier_service.ListStudiesRequest.serialize, + response_deserializer=vizier_service.ListStudiesResponse.deserialize, + ) + return self._stubs["list_studies"] + + @property + def delete_study( + self, + ) -> Callable[[vizier_service.DeleteStudyRequest], Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete study method over gRPC. + + Deletes a Study. + + Returns: + Callable[[~.DeleteStudyRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_study" not in self._stubs: + self._stubs["delete_study"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/DeleteStudy", + request_serializer=vizier_service.DeleteStudyRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_study"] + + @property + def lookup_study( + self, + ) -> Callable[[vizier_service.LookupStudyRequest], Awaitable[study.Study]]: + r"""Return a callable for the lookup study method over gRPC. + + Looks a study up using the user-defined display_name field + instead of the fully qualified resource name. + + Returns: + Callable[[~.LookupStudyRequest], + Awaitable[~.Study]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "lookup_study" not in self._stubs: + self._stubs["lookup_study"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/LookupStudy", + request_serializer=vizier_service.LookupStudyRequest.serialize, + response_deserializer=study.Study.deserialize, + ) + return self._stubs["lookup_study"] + + @property + def suggest_trials( + self, + ) -> Callable[ + [vizier_service.SuggestTrialsRequest], Awaitable[operations_pb2.Operation] + ]: + r"""Return a callable for the suggest trials method over gRPC. + + Adds one or more Trials to a Study, with parameter values + suggested by Vertex Vizier. Returns a long-running operation + associated with the generation of Trial suggestions. When this + long-running operation succeeds, it will contain a + [SuggestTrialsResponse][google.cloud.ml.v1.SuggestTrialsResponse]. + + Returns: + Callable[[~.SuggestTrialsRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "suggest_trials" not in self._stubs: + self._stubs["suggest_trials"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/SuggestTrials", + request_serializer=vizier_service.SuggestTrialsRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["suggest_trials"] + + @property + def create_trial( + self, + ) -> Callable[[vizier_service.CreateTrialRequest], Awaitable[study.Trial]]: + r"""Return a callable for the create trial method over gRPC. + + Adds a user provided Trial to a Study. + + Returns: + Callable[[~.CreateTrialRequest], + Awaitable[~.Trial]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_trial" not in self._stubs: + self._stubs["create_trial"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/CreateTrial", + request_serializer=vizier_service.CreateTrialRequest.serialize, + response_deserializer=study.Trial.deserialize, + ) + return self._stubs["create_trial"] + + @property + def get_trial( + self, + ) -> Callable[[vizier_service.GetTrialRequest], Awaitable[study.Trial]]: + r"""Return a callable for the get trial method over gRPC. + + Gets a Trial. + + Returns: + Callable[[~.GetTrialRequest], + Awaitable[~.Trial]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_trial" not in self._stubs: + self._stubs["get_trial"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/GetTrial", + request_serializer=vizier_service.GetTrialRequest.serialize, + response_deserializer=study.Trial.deserialize, + ) + return self._stubs["get_trial"] + + @property + def list_trials( + self, + ) -> Callable[ + [vizier_service.ListTrialsRequest], Awaitable[vizier_service.ListTrialsResponse] + ]: + r"""Return a callable for the list trials method over gRPC. + + Lists the Trials associated with a Study. + + Returns: + Callable[[~.ListTrialsRequest], + Awaitable[~.ListTrialsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_trials" not in self._stubs: + self._stubs["list_trials"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/ListTrials", + request_serializer=vizier_service.ListTrialsRequest.serialize, + response_deserializer=vizier_service.ListTrialsResponse.deserialize, + ) + return self._stubs["list_trials"] + + @property + def add_trial_measurement( + self, + ) -> Callable[[vizier_service.AddTrialMeasurementRequest], Awaitable[study.Trial]]: + r"""Return a callable for the add trial measurement method over gRPC. + + Adds a measurement of the objective metrics to a + Trial. This measurement is assumed to have been taken + before the Trial is complete. + + Returns: + Callable[[~.AddTrialMeasurementRequest], + Awaitable[~.Trial]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "add_trial_measurement" not in self._stubs: + self._stubs["add_trial_measurement"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/AddTrialMeasurement", + request_serializer=vizier_service.AddTrialMeasurementRequest.serialize, + response_deserializer=study.Trial.deserialize, + ) + return self._stubs["add_trial_measurement"] + + @property + def complete_trial( + self, + ) -> Callable[[vizier_service.CompleteTrialRequest], Awaitable[study.Trial]]: + r"""Return a callable for the complete trial method over gRPC. + + Marks a Trial as complete. + + Returns: + Callable[[~.CompleteTrialRequest], + Awaitable[~.Trial]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "complete_trial" not in self._stubs: + self._stubs["complete_trial"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/CompleteTrial", + request_serializer=vizier_service.CompleteTrialRequest.serialize, + response_deserializer=study.Trial.deserialize, + ) + return self._stubs["complete_trial"] + + @property + def delete_trial( + self, + ) -> Callable[[vizier_service.DeleteTrialRequest], Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete trial method over gRPC. + + Deletes a Trial. + + Returns: + Callable[[~.DeleteTrialRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_trial" not in self._stubs: + self._stubs["delete_trial"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/DeleteTrial", + request_serializer=vizier_service.DeleteTrialRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_trial"] + + @property + def check_trial_early_stopping_state( + self, + ) -> Callable[ + [vizier_service.CheckTrialEarlyStoppingStateRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the check trial early stopping + state method over gRPC. + + Checks whether a Trial should stop or not. Returns a + long-running operation. When the operation is successful, it + will contain a + [CheckTrialEarlyStoppingStateResponse][google.cloud.ml.v1.CheckTrialEarlyStoppingStateResponse]. + + Returns: + Callable[[~.CheckTrialEarlyStoppingStateRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "check_trial_early_stopping_state" not in self._stubs: + self._stubs[ + "check_trial_early_stopping_state" + ] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/CheckTrialEarlyStoppingState", + request_serializer=vizier_service.CheckTrialEarlyStoppingStateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["check_trial_early_stopping_state"] + + @property + def stop_trial( + self, + ) -> Callable[[vizier_service.StopTrialRequest], Awaitable[study.Trial]]: + r"""Return a callable for the stop trial method over gRPC. + + Stops a Trial. + + Returns: + Callable[[~.StopTrialRequest], + Awaitable[~.Trial]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "stop_trial" not in self._stubs: + self._stubs["stop_trial"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/StopTrial", + request_serializer=vizier_service.StopTrialRequest.serialize, + response_deserializer=study.Trial.deserialize, + ) + return self._stubs["stop_trial"] + + @property + def list_optimal_trials( + self, + ) -> Callable[ + [vizier_service.ListOptimalTrialsRequest], + Awaitable[vizier_service.ListOptimalTrialsResponse], + ]: + r"""Return a callable for the list optimal trials method over gRPC. + + Lists the pareto-optimal Trials for multi-objective Study or the + optimal Trials for single-objective Study. The definition of + pareto-optimal can be checked in wiki page. + https://en.wikipedia.org/wiki/Pareto_efficiency + + Returns: + Callable[[~.ListOptimalTrialsRequest], + Awaitable[~.ListOptimalTrialsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_optimal_trials" not in self._stubs: + self._stubs["list_optimal_trials"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1.VizierService/ListOptimalTrials", + request_serializer=vizier_service.ListOptimalTrialsRequest.serialize, + response_deserializer=vizier_service.ListOptimalTrialsResponse.deserialize, + ) + return self._stubs["list_optimal_trials"] + + +__all__ = ("VizierServiceGrpcAsyncIOTransport",) diff --git a/google/cloud/aiplatform_v1/types/__init__.py b/google/cloud/aiplatform_v1/types/__init__.py index e5f784becb..524f0749e6 100644 --- a/google/cloud/aiplatform_v1/types/__init__.py +++ b/google/cloud/aiplatform_v1/types/__init__.py @@ -296,6 +296,30 @@ ) from .user_action_reference import UserActionReference from .value import Value +from .vizier_service import ( + AddTrialMeasurementRequest, + CheckTrialEarlyStoppingStateMetatdata, + CheckTrialEarlyStoppingStateRequest, + CheckTrialEarlyStoppingStateResponse, + CompleteTrialRequest, + CreateStudyRequest, + CreateTrialRequest, + DeleteStudyRequest, + DeleteTrialRequest, + GetStudyRequest, + GetTrialRequest, + ListOptimalTrialsRequest, + ListOptimalTrialsResponse, + ListStudiesRequest, + ListStudiesResponse, + ListTrialsRequest, + ListTrialsResponse, + LookupStudyRequest, + StopTrialRequest, + SuggestTrialsMetadata, + SuggestTrialsRequest, + SuggestTrialsResponse, +) __all__ = ( "AcceleratorType", @@ -534,4 +558,26 @@ "TrainingPipeline", "UserActionReference", "Value", + "AddTrialMeasurementRequest", + "CheckTrialEarlyStoppingStateMetatdata", + "CheckTrialEarlyStoppingStateRequest", + "CheckTrialEarlyStoppingStateResponse", + "CompleteTrialRequest", + "CreateStudyRequest", + "CreateTrialRequest", + "DeleteStudyRequest", + "DeleteTrialRequest", + "GetStudyRequest", + "GetTrialRequest", + "ListOptimalTrialsRequest", + "ListOptimalTrialsResponse", + "ListStudiesRequest", + "ListStudiesResponse", + "ListTrialsRequest", + "ListTrialsResponse", + "LookupStudyRequest", + "StopTrialRequest", + "SuggestTrialsMetadata", + "SuggestTrialsRequest", + "SuggestTrialsResponse", ) diff --git a/google/cloud/aiplatform_v1/types/vizier_service.py b/google/cloud/aiplatform_v1/types/vizier_service.py new file mode 100644 index 0000000000..e444c64751 --- /dev/null +++ b/google/cloud/aiplatform_v1/types/vizier_service.py @@ -0,0 +1,454 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import proto # type: ignore + +from google.cloud.aiplatform_v1.types import operation +from google.cloud.aiplatform_v1.types import study as gca_study +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package="google.cloud.aiplatform.v1", + manifest={ + "GetStudyRequest", + "CreateStudyRequest", + "ListStudiesRequest", + "ListStudiesResponse", + "DeleteStudyRequest", + "LookupStudyRequest", + "SuggestTrialsRequest", + "SuggestTrialsResponse", + "SuggestTrialsMetadata", + "CreateTrialRequest", + "GetTrialRequest", + "ListTrialsRequest", + "ListTrialsResponse", + "AddTrialMeasurementRequest", + "CompleteTrialRequest", + "DeleteTrialRequest", + "CheckTrialEarlyStoppingStateRequest", + "CheckTrialEarlyStoppingStateResponse", + "CheckTrialEarlyStoppingStateMetatdata", + "StopTrialRequest", + "ListOptimalTrialsRequest", + "ListOptimalTrialsResponse", + }, +) + + +class GetStudyRequest(proto.Message): + r"""Request message for + [VizierService.GetStudy][google.cloud.aiplatform.v1.VizierService.GetStudy]. + + Attributes: + name (str): + Required. The name of the Study resource. Format: + ``projects/{project}/locations/{location}/studies/{study}`` + """ + + name = proto.Field(proto.STRING, number=1,) + + +class CreateStudyRequest(proto.Message): + r"""Request message for + [VizierService.CreateStudy][google.cloud.aiplatform.v1.VizierService.CreateStudy]. + + Attributes: + parent (str): + Required. The resource name of the Location to create the + CustomJob in. Format: + ``projects/{project}/locations/{location}`` + study (google.cloud.aiplatform_v1.types.Study): + Required. The Study configuration used to + create the Study. + """ + + parent = proto.Field(proto.STRING, number=1,) + study = proto.Field(proto.MESSAGE, number=2, message=gca_study.Study,) + + +class ListStudiesRequest(proto.Message): + r"""Request message for + [VizierService.ListStudies][google.cloud.aiplatform.v1.VizierService.ListStudies]. + + Attributes: + parent (str): + Required. The resource name of the Location to list the + Study from. Format: + ``projects/{project}/locations/{location}`` + page_token (str): + Optional. A page token to request the next + page of results. If unspecified, there are no + subsequent pages. + page_size (int): + Optional. The maximum number of studies to + return per "page" of results. If unspecified, + service will pick an appropriate default. + """ + + parent = proto.Field(proto.STRING, number=1,) + page_token = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + + +class ListStudiesResponse(proto.Message): + r"""Response message for + [VizierService.ListStudies][google.cloud.aiplatform.v1.VizierService.ListStudies]. + + Attributes: + studies (Sequence[google.cloud.aiplatform_v1.types.Study]): + The studies associated with the project. + next_page_token (str): + Passes this token as the ``page_token`` field of the request + for a subsequent call. If this field is omitted, there are + no subsequent pages. + """ + + @property + def raw_page(self): + return self + + studies = proto.RepeatedField(proto.MESSAGE, number=1, message=gca_study.Study,) + next_page_token = proto.Field(proto.STRING, number=2,) + + +class DeleteStudyRequest(proto.Message): + r"""Request message for + [VizierService.DeleteStudy][google.cloud.aiplatform.v1.VizierService.DeleteStudy]. + + Attributes: + name (str): + Required. The name of the Study resource to be deleted. + Format: + ``projects/{project}/locations/{location}/studies/{study}`` + """ + + name = proto.Field(proto.STRING, number=1,) + + +class LookupStudyRequest(proto.Message): + r"""Request message for + [VizierService.LookupStudy][google.cloud.aiplatform.v1.VizierService.LookupStudy]. + + Attributes: + parent (str): + Required. The resource name of the Location to get the Study + from. Format: ``projects/{project}/locations/{location}`` + display_name (str): + Required. The user-defined display name of + the Study + """ + + parent = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + + +class SuggestTrialsRequest(proto.Message): + r"""Request message for + [VizierService.SuggestTrials][google.cloud.aiplatform.v1.VizierService.SuggestTrials]. + + Attributes: + parent (str): + Required. The project and location that the Study belongs + to. Format: + ``projects/{project}/locations/{location}/studies/{study}`` + suggestion_count (int): + Required. The number of suggestions + requested. + client_id (str): + Required. The identifier of the client that is requesting + the suggestion. + + If multiple SuggestTrialsRequests have the same + ``client_id``, the service will return the identical + suggested Trial if the Trial is pending, and provide a new + Trial if the last suggested Trial was completed. + """ + + parent = proto.Field(proto.STRING, number=1,) + suggestion_count = proto.Field(proto.INT32, number=2,) + client_id = proto.Field(proto.STRING, number=3,) + + +class SuggestTrialsResponse(proto.Message): + r"""Response message for + [VizierService.SuggestTrials][google.cloud.aiplatform.v1.VizierService.SuggestTrials]. + + Attributes: + trials (Sequence[google.cloud.aiplatform_v1.types.Trial]): + A list of Trials. + study_state (google.cloud.aiplatform_v1.types.Study.State): + The state of the Study. + start_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which the operation was started. + end_time (google.protobuf.timestamp_pb2.Timestamp): + The time at which operation processing + completed. + """ + + trials = proto.RepeatedField(proto.MESSAGE, number=1, message=gca_study.Trial,) + study_state = proto.Field(proto.ENUM, number=2, enum=gca_study.Study.State,) + start_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + + +class SuggestTrialsMetadata(proto.Message): + r"""Details of operations that perform Trials suggestion. + Attributes: + generic_metadata (google.cloud.aiplatform_v1.types.GenericOperationMetadata): + Operation metadata for suggesting Trials. + client_id (str): + The identifier of the client that is requesting the + suggestion. + + If multiple SuggestTrialsRequests have the same + ``client_id``, the service will return the identical + suggested Trial if the Trial is pending, and provide a new + Trial if the last suggested Trial was completed. + """ + + generic_metadata = proto.Field( + proto.MESSAGE, number=1, message=operation.GenericOperationMetadata, + ) + client_id = proto.Field(proto.STRING, number=2,) + + +class CreateTrialRequest(proto.Message): + r"""Request message for + [VizierService.CreateTrial][google.cloud.aiplatform.v1.VizierService.CreateTrial]. + + Attributes: + parent (str): + Required. The resource name of the Study to create the Trial + in. Format: + ``projects/{project}/locations/{location}/studies/{study}`` + trial (google.cloud.aiplatform_v1.types.Trial): + Required. The Trial to create. + """ + + parent = proto.Field(proto.STRING, number=1,) + trial = proto.Field(proto.MESSAGE, number=2, message=gca_study.Trial,) + + +class GetTrialRequest(proto.Message): + r"""Request message for + [VizierService.GetTrial][google.cloud.aiplatform.v1.VizierService.GetTrial]. + + Attributes: + name (str): + Required. The name of the Trial resource. Format: + ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` + """ + + name = proto.Field(proto.STRING, number=1,) + + +class ListTrialsRequest(proto.Message): + r"""Request message for + [VizierService.ListTrials][google.cloud.aiplatform.v1.VizierService.ListTrials]. + + Attributes: + parent (str): + Required. The resource name of the Study to list the Trial + from. Format: + ``projects/{project}/locations/{location}/studies/{study}`` + page_token (str): + Optional. A page token to request the next + page of results. If unspecified, there are no + subsequent pages. + page_size (int): + Optional. The number of Trials to retrieve + per "page" of results. If unspecified, the + service will pick an appropriate default. + """ + + parent = proto.Field(proto.STRING, number=1,) + page_token = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + + +class ListTrialsResponse(proto.Message): + r"""Response message for + [VizierService.ListTrials][google.cloud.aiplatform.v1.VizierService.ListTrials]. + + Attributes: + trials (Sequence[google.cloud.aiplatform_v1.types.Trial]): + The Trials associated with the Study. + next_page_token (str): + Pass this token as the ``page_token`` field of the request + for a subsequent call. If this field is omitted, there are + no subsequent pages. + """ + + @property + def raw_page(self): + return self + + trials = proto.RepeatedField(proto.MESSAGE, number=1, message=gca_study.Trial,) + next_page_token = proto.Field(proto.STRING, number=2,) + + +class AddTrialMeasurementRequest(proto.Message): + r"""Request message for + [VizierService.AddTrialMeasurement][google.cloud.aiplatform.v1.VizierService.AddTrialMeasurement]. + + Attributes: + trial_name (str): + Required. The name of the trial to add measurement. Format: + ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` + measurement (google.cloud.aiplatform_v1.types.Measurement): + Required. The measurement to be added to a + Trial. + """ + + trial_name = proto.Field(proto.STRING, number=1,) + measurement = proto.Field(proto.MESSAGE, number=3, message=gca_study.Measurement,) + + +class CompleteTrialRequest(proto.Message): + r"""Request message for + [VizierService.CompleteTrial][google.cloud.aiplatform.v1.VizierService.CompleteTrial]. + + Attributes: + name (str): + Required. The Trial's name. Format: + ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` + final_measurement (google.cloud.aiplatform_v1.types.Measurement): + Optional. If provided, it will be used as the completed + Trial's final_measurement; Otherwise, the service will + auto-select a previously reported measurement as the + final-measurement + trial_infeasible (bool): + Optional. True if the Trial cannot be run with the given + Parameter, and final_measurement will be ignored. + infeasible_reason (str): + Optional. A human readable reason why the trial was + infeasible. This should only be provided if + ``trial_infeasible`` is true. + """ + + name = proto.Field(proto.STRING, number=1,) + final_measurement = proto.Field( + proto.MESSAGE, number=2, message=gca_study.Measurement, + ) + trial_infeasible = proto.Field(proto.BOOL, number=3,) + infeasible_reason = proto.Field(proto.STRING, number=4,) + + +class DeleteTrialRequest(proto.Message): + r"""Request message for + [VizierService.DeleteTrial][google.cloud.aiplatform.v1.VizierService.DeleteTrial]. + + Attributes: + name (str): + Required. The Trial's name. Format: + ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` + """ + + name = proto.Field(proto.STRING, number=1,) + + +class CheckTrialEarlyStoppingStateRequest(proto.Message): + r"""Request message for + [VizierService.CheckTrialEarlyStoppingState][google.cloud.aiplatform.v1.VizierService.CheckTrialEarlyStoppingState]. + + Attributes: + trial_name (str): + Required. The Trial's name. Format: + ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` + """ + + trial_name = proto.Field(proto.STRING, number=1,) + + +class CheckTrialEarlyStoppingStateResponse(proto.Message): + r"""Response message for + [VizierService.CheckTrialEarlyStoppingState][google.cloud.aiplatform.v1.VizierService.CheckTrialEarlyStoppingState]. + + Attributes: + should_stop (bool): + True if the Trial should stop. + """ + + should_stop = proto.Field(proto.BOOL, number=1,) + + +class CheckTrialEarlyStoppingStateMetatdata(proto.Message): + r"""This message will be placed in the metadata field of a + google.longrunning.Operation associated with a + CheckTrialEarlyStoppingState request. + + Attributes: + generic_metadata (google.cloud.aiplatform_v1.types.GenericOperationMetadata): + Operation metadata for suggesting Trials. + study (str): + The name of the Study that the Trial belongs + to. + trial (str): + The Trial name. + """ + + generic_metadata = proto.Field( + proto.MESSAGE, number=1, message=operation.GenericOperationMetadata, + ) + study = proto.Field(proto.STRING, number=2,) + trial = proto.Field(proto.STRING, number=3,) + + +class StopTrialRequest(proto.Message): + r"""Request message for + [VizierService.StopTrial][google.cloud.aiplatform.v1.VizierService.StopTrial]. + + Attributes: + name (str): + Required. The Trial's name. Format: + ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` + """ + + name = proto.Field(proto.STRING, number=1,) + + +class ListOptimalTrialsRequest(proto.Message): + r"""Request message for + [VizierService.ListOptimalTrials][google.cloud.aiplatform.v1.VizierService.ListOptimalTrials]. + + Attributes: + parent (str): + Required. The name of the Study that the + optimal Trial belongs to. + """ + + parent = proto.Field(proto.STRING, number=1,) + + +class ListOptimalTrialsResponse(proto.Message): + r"""Response message for + [VizierService.ListOptimalTrials][google.cloud.aiplatform.v1.VizierService.ListOptimalTrials]. + + Attributes: + optimal_trials (Sequence[google.cloud.aiplatform_v1.types.Trial]): + The pareto-optimal Trials for multiple objective Study or + the optimal trial for single objective Study. The definition + of pareto-optimal can be checked in wiki page. + https://en.wikipedia.org/wiki/Pareto_efficiency + """ + + optimal_trials = proto.RepeatedField( + proto.MESSAGE, number=1, message=gca_study.Trial, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/services/dataset_service/client.py b/google/cloud/aiplatform_v1beta1/services/dataset_service/client.py index 25a2c78ae4..bf0fe63a4c 100644 --- a/google/cloud/aiplatform_v1beta1/services/dataset_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/dataset_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -428,7 +428,7 @@ def __init__( def create_dataset( self, - request: dataset_service.CreateDatasetRequest = None, + request: Union[dataset_service.CreateDatasetRequest, dict] = None, *, parent: str = None, dataset: gca_dataset.Dataset = None, @@ -439,7 +439,7 @@ def create_dataset( r"""Creates a Dataset. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateDatasetRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateDatasetRequest, dict]): The request object. Request message for [DatasetService.CreateDataset][google.cloud.aiplatform.v1beta1.DatasetService.CreateDataset]. parent (str): @@ -519,7 +519,7 @@ def create_dataset( def get_dataset( self, - request: dataset_service.GetDatasetRequest = None, + request: Union[dataset_service.GetDatasetRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -529,7 +529,7 @@ def get_dataset( r"""Gets a Dataset. Args: - request (google.cloud.aiplatform_v1beta1.types.GetDatasetRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetDatasetRequest, dict]): The request object. Request message for [DatasetService.GetDataset][google.cloud.aiplatform.v1beta1.DatasetService.GetDataset]. name (str): @@ -590,7 +590,7 @@ def get_dataset( def update_dataset( self, - request: dataset_service.UpdateDatasetRequest = None, + request: Union[dataset_service.UpdateDatasetRequest, dict] = None, *, dataset: gca_dataset.Dataset = None, update_mask: field_mask_pb2.FieldMask = None, @@ -601,7 +601,7 @@ def update_dataset( r"""Updates a Dataset. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateDatasetRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateDatasetRequest, dict]): The request object. Request message for [DatasetService.UpdateDataset][google.cloud.aiplatform.v1beta1.DatasetService.UpdateDataset]. dataset (google.cloud.aiplatform_v1beta1.types.Dataset): @@ -679,7 +679,7 @@ def update_dataset( def list_datasets( self, - request: dataset_service.ListDatasetsRequest = None, + request: Union[dataset_service.ListDatasetsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -689,7 +689,7 @@ def list_datasets( r"""Lists Datasets in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListDatasetsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListDatasetsRequest, dict]): The request object. Request message for [DatasetService.ListDatasets][google.cloud.aiplatform.v1beta1.DatasetService.ListDatasets]. parent (str): @@ -759,7 +759,7 @@ def list_datasets( def delete_dataset( self, - request: dataset_service.DeleteDatasetRequest = None, + request: Union[dataset_service.DeleteDatasetRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -769,7 +769,7 @@ def delete_dataset( r"""Deletes a Dataset. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteDatasetRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteDatasetRequest, dict]): The request object. Request message for [DatasetService.DeleteDataset][google.cloud.aiplatform.v1beta1.DatasetService.DeleteDataset]. name (str): @@ -852,7 +852,7 @@ def delete_dataset( def import_data( self, - request: dataset_service.ImportDataRequest = None, + request: Union[dataset_service.ImportDataRequest, dict] = None, *, name: str = None, import_configs: Sequence[dataset.ImportDataConfig] = None, @@ -863,7 +863,7 @@ def import_data( r"""Imports data into a Dataset. Args: - request (google.cloud.aiplatform_v1beta1.types.ImportDataRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ImportDataRequest, dict]): The request object. Request message for [DatasetService.ImportData][google.cloud.aiplatform.v1beta1.DatasetService.ImportData]. name (str): @@ -946,7 +946,7 @@ def import_data( def export_data( self, - request: dataset_service.ExportDataRequest = None, + request: Union[dataset_service.ExportDataRequest, dict] = None, *, name: str = None, export_config: dataset.ExportDataConfig = None, @@ -957,7 +957,7 @@ def export_data( r"""Exports data from a Dataset. Args: - request (google.cloud.aiplatform_v1beta1.types.ExportDataRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ExportDataRequest, dict]): The request object. Request message for [DatasetService.ExportData][google.cloud.aiplatform.v1beta1.DatasetService.ExportData]. name (str): @@ -1039,7 +1039,7 @@ def export_data( def list_data_items( self, - request: dataset_service.ListDataItemsRequest = None, + request: Union[dataset_service.ListDataItemsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1049,7 +1049,7 @@ def list_data_items( r"""Lists DataItems in a Dataset. Args: - request (google.cloud.aiplatform_v1beta1.types.ListDataItemsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListDataItemsRequest, dict]): The request object. Request message for [DatasetService.ListDataItems][google.cloud.aiplatform.v1beta1.DatasetService.ListDataItems]. parent (str): @@ -1120,7 +1120,7 @@ def list_data_items( def get_annotation_spec( self, - request: dataset_service.GetAnnotationSpecRequest = None, + request: Union[dataset_service.GetAnnotationSpecRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1130,7 +1130,7 @@ def get_annotation_spec( r"""Gets an AnnotationSpec. Args: - request (google.cloud.aiplatform_v1beta1.types.GetAnnotationSpecRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetAnnotationSpecRequest, dict]): The request object. Request message for [DatasetService.GetAnnotationSpec][google.cloud.aiplatform.v1beta1.DatasetService.GetAnnotationSpec]. name (str): @@ -1192,7 +1192,7 @@ def get_annotation_spec( def list_annotations( self, - request: dataset_service.ListAnnotationsRequest = None, + request: Union[dataset_service.ListAnnotationsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1202,7 +1202,7 @@ def list_annotations( r"""Lists Annotations belongs to a dataitem Args: - request (google.cloud.aiplatform_v1beta1.types.ListAnnotationsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListAnnotationsRequest, dict]): The request object. Request message for [DatasetService.ListAnnotations][google.cloud.aiplatform.v1beta1.DatasetService.ListAnnotations]. parent (str): diff --git a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/base.py index b043f64b6a..c426f50cd9 100644 --- a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/base.py @@ -122,7 +122,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc.py index ccdc689d25..d0e30acb76 100644 --- a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc.py @@ -86,16 +86,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc_asyncio.py index a11f9e1062..80ad36fdce 100644 --- a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc_asyncio.py @@ -133,16 +133,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/endpoint_service/client.py b/google/cloud/aiplatform_v1beta1/services/endpoint_service/client.py index c165f350a4..7682a5a0c9 100644 --- a/google/cloud/aiplatform_v1beta1/services/endpoint_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/endpoint_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -412,7 +412,7 @@ def __init__( def create_endpoint( self, - request: endpoint_service.CreateEndpointRequest = None, + request: Union[endpoint_service.CreateEndpointRequest, dict] = None, *, parent: str = None, endpoint: gca_endpoint.Endpoint = None, @@ -423,7 +423,7 @@ def create_endpoint( r"""Creates an Endpoint. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateEndpointRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateEndpointRequest, dict]): The request object. Request message for [EndpointService.CreateEndpoint][google.cloud.aiplatform.v1beta1.EndpointService.CreateEndpoint]. parent (str): @@ -502,7 +502,7 @@ def create_endpoint( def get_endpoint( self, - request: endpoint_service.GetEndpointRequest = None, + request: Union[endpoint_service.GetEndpointRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -512,7 +512,7 @@ def get_endpoint( r"""Gets an Endpoint. Args: - request (google.cloud.aiplatform_v1beta1.types.GetEndpointRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetEndpointRequest, dict]): The request object. Request message for [EndpointService.GetEndpoint][google.cloud.aiplatform.v1beta1.EndpointService.GetEndpoint] name (str): @@ -574,7 +574,7 @@ def get_endpoint( def list_endpoints( self, - request: endpoint_service.ListEndpointsRequest = None, + request: Union[endpoint_service.ListEndpointsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -584,7 +584,7 @@ def list_endpoints( r"""Lists Endpoints in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListEndpointsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListEndpointsRequest, dict]): The request object. Request message for [EndpointService.ListEndpoints][google.cloud.aiplatform.v1beta1.EndpointService.ListEndpoints]. parent (str): @@ -655,7 +655,7 @@ def list_endpoints( def update_endpoint( self, - request: endpoint_service.UpdateEndpointRequest = None, + request: Union[endpoint_service.UpdateEndpointRequest, dict] = None, *, endpoint: gca_endpoint.Endpoint = None, update_mask: field_mask_pb2.FieldMask = None, @@ -666,7 +666,7 @@ def update_endpoint( r"""Updates an Endpoint. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateEndpointRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateEndpointRequest, dict]): The request object. Request message for [EndpointService.UpdateEndpoint][google.cloud.aiplatform.v1beta1.EndpointService.UpdateEndpoint]. endpoint (google.cloud.aiplatform_v1beta1.types.Endpoint): @@ -739,7 +739,7 @@ def update_endpoint( def delete_endpoint( self, - request: endpoint_service.DeleteEndpointRequest = None, + request: Union[endpoint_service.DeleteEndpointRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -749,7 +749,7 @@ def delete_endpoint( r"""Deletes an Endpoint. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteEndpointRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteEndpointRequest, dict]): The request object. Request message for [EndpointService.DeleteEndpoint][google.cloud.aiplatform.v1beta1.EndpointService.DeleteEndpoint]. name (str): @@ -832,7 +832,7 @@ def delete_endpoint( def deploy_model( self, - request: endpoint_service.DeployModelRequest = None, + request: Union[endpoint_service.DeployModelRequest, dict] = None, *, endpoint: str = None, deployed_model: gca_endpoint.DeployedModel = None, @@ -847,7 +847,7 @@ def deploy_model( DeployedModel within it. Args: - request (google.cloud.aiplatform_v1beta1.types.DeployModelRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeployModelRequest, dict]): The request object. Request message for [EndpointService.DeployModel][google.cloud.aiplatform.v1beta1.EndpointService.DeployModel]. endpoint (str): @@ -956,7 +956,7 @@ def deploy_model( def undeploy_model( self, - request: endpoint_service.UndeployModelRequest = None, + request: Union[endpoint_service.UndeployModelRequest, dict] = None, *, endpoint: str = None, deployed_model_id: str = None, @@ -972,7 +972,7 @@ def undeploy_model( using. Args: - request (google.cloud.aiplatform_v1beta1.types.UndeployModelRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UndeployModelRequest, dict]): The request object. Request message for [EndpointService.UndeployModel][google.cloud.aiplatform.v1beta1.EndpointService.UndeployModel]. endpoint (str): diff --git a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/base.py index c6a2bbf5d8..44c8e7c965 100644 --- a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/base.py @@ -121,7 +121,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc.py index 876c624304..c9c803a844 100644 --- a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc.py @@ -84,16 +84,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc_asyncio.py index 899b7af023..beaf5f91df 100644 --- a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc_asyncio.py @@ -131,16 +131,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/client.py b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/client.py index 71d6c6193d..8c20c86f62 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Iterable, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Iterable, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -367,7 +367,9 @@ def __init__( def read_feature_values( self, - request: featurestore_online_service.ReadFeatureValuesRequest = None, + request: Union[ + featurestore_online_service.ReadFeatureValuesRequest, dict + ] = None, *, entity_type: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -380,7 +382,7 @@ def read_feature_values( StreamingReadFeatureValues. Args: - request (google.cloud.aiplatform_v1beta1.types.ReadFeatureValuesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ReadFeatureValuesRequest, dict]): The request object. Request message for [FeaturestoreOnlineServingService.ReadFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreOnlineServingService.ReadFeatureValues]. entity_type (str): @@ -449,7 +451,9 @@ def read_feature_values( def streaming_read_feature_values( self, - request: featurestore_online_service.StreamingReadFeatureValuesRequest = None, + request: Union[ + featurestore_online_service.StreamingReadFeatureValuesRequest, dict + ] = None, *, entity_type: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -461,7 +465,7 @@ def streaming_read_feature_values( up across multiple responses. Args: - request (google.cloud.aiplatform_v1beta1.types.StreamingReadFeatureValuesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.StreamingReadFeatureValuesRequest, dict]): The request object. Request message for [FeaturestoreOnlineServingService.StreamingFeatureValuesRead][]. entity_type (str): diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/base.py index 349146d525..77950d90c2 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/base.py @@ -117,7 +117,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc.py index 745a85b6d6..e9277a6e5d 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc.py @@ -82,16 +82,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc_asyncio.py index cc3907066e..6ebe5b3e45 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc_asyncio.py @@ -129,16 +129,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_service/client.py b/google/cloud/aiplatform_v1beta1/services/featurestore_service/client.py index 0dfe99140f..30de94ef37 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -413,7 +413,7 @@ def __init__( def create_featurestore( self, - request: featurestore_service.CreateFeaturestoreRequest = None, + request: Union[featurestore_service.CreateFeaturestoreRequest, dict] = None, *, parent: str = None, featurestore: gca_featurestore.Featurestore = None, @@ -425,7 +425,7 @@ def create_featurestore( location. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateFeaturestoreRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateFeaturestoreRequest, dict]): The request object. Request message for [FeaturestoreService.CreateFeaturestore][google.cloud.aiplatform.v1beta1.FeaturestoreService.CreateFeaturestore]. parent (str): @@ -506,7 +506,7 @@ def create_featurestore( def get_featurestore( self, - request: featurestore_service.GetFeaturestoreRequest = None, + request: Union[featurestore_service.GetFeaturestoreRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -516,7 +516,7 @@ def get_featurestore( r"""Gets details of a single Featurestore. Args: - request (google.cloud.aiplatform_v1beta1.types.GetFeaturestoreRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetFeaturestoreRequest, dict]): The request object. Request message for [FeaturestoreService.GetFeaturestore][google.cloud.aiplatform.v1beta1.FeaturestoreService.GetFeaturestore]. name (str): @@ -578,7 +578,7 @@ def get_featurestore( def list_featurestores( self, - request: featurestore_service.ListFeaturestoresRequest = None, + request: Union[featurestore_service.ListFeaturestoresRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -588,7 +588,7 @@ def list_featurestores( r"""Lists Featurestores in a given project and location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListFeaturestoresRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListFeaturestoresRequest, dict]): The request object. Request message for [FeaturestoreService.ListFeaturestores][google.cloud.aiplatform.v1beta1.FeaturestoreService.ListFeaturestores]. parent (str): @@ -659,7 +659,7 @@ def list_featurestores( def update_featurestore( self, - request: featurestore_service.UpdateFeaturestoreRequest = None, + request: Union[featurestore_service.UpdateFeaturestoreRequest, dict] = None, *, featurestore: gca_featurestore.Featurestore = None, update_mask: field_mask_pb2.FieldMask = None, @@ -670,7 +670,7 @@ def update_featurestore( r"""Updates the parameters of a single Featurestore. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateFeaturestoreRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateFeaturestoreRequest, dict]): The request object. Request message for [FeaturestoreService.UpdateFeaturestore][google.cloud.aiplatform.v1beta1.FeaturestoreService.UpdateFeaturestore]. featurestore (google.cloud.aiplatform_v1beta1.types.Featurestore): @@ -766,7 +766,7 @@ def update_featurestore( def delete_featurestore( self, - request: featurestore_service.DeleteFeaturestoreRequest = None, + request: Union[featurestore_service.DeleteFeaturestoreRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -778,7 +778,7 @@ def delete_featurestore( to succeed. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteFeaturestoreRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteFeaturestoreRequest, dict]): The request object. Request message for [FeaturestoreService.DeleteFeaturestore][google.cloud.aiplatform.v1beta1.FeaturestoreService.DeleteFeaturestore]. name (str): @@ -861,7 +861,7 @@ def delete_featurestore( def create_entity_type( self, - request: featurestore_service.CreateEntityTypeRequest = None, + request: Union[featurestore_service.CreateEntityTypeRequest, dict] = None, *, parent: str = None, entity_type: gca_entity_type.EntityType = None, @@ -872,7 +872,7 @@ def create_entity_type( r"""Creates a new EntityType in a given Featurestore. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateEntityTypeRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateEntityTypeRequest, dict]): The request object. Request message for [FeaturestoreService.CreateEntityType][google.cloud.aiplatform.v1beta1.FeaturestoreService.CreateEntityType]. parent (str): @@ -953,7 +953,7 @@ def create_entity_type( def get_entity_type( self, - request: featurestore_service.GetEntityTypeRequest = None, + request: Union[featurestore_service.GetEntityTypeRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -963,7 +963,7 @@ def get_entity_type( r"""Gets details of a single EntityType. Args: - request (google.cloud.aiplatform_v1beta1.types.GetEntityTypeRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetEntityTypeRequest, dict]): The request object. Request message for [FeaturestoreService.GetEntityType][google.cloud.aiplatform.v1beta1.FeaturestoreService.GetEntityType]. name (str): @@ -1028,7 +1028,7 @@ def get_entity_type( def list_entity_types( self, - request: featurestore_service.ListEntityTypesRequest = None, + request: Union[featurestore_service.ListEntityTypesRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1038,7 +1038,7 @@ def list_entity_types( r"""Lists EntityTypes in a given Featurestore. Args: - request (google.cloud.aiplatform_v1beta1.types.ListEntityTypesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListEntityTypesRequest, dict]): The request object. Request message for [FeaturestoreService.ListEntityTypes][google.cloud.aiplatform.v1beta1.FeaturestoreService.ListEntityTypes]. parent (str): @@ -1109,7 +1109,7 @@ def list_entity_types( def update_entity_type( self, - request: featurestore_service.UpdateEntityTypeRequest = None, + request: Union[featurestore_service.UpdateEntityTypeRequest, dict] = None, *, entity_type: gca_entity_type.EntityType = None, update_mask: field_mask_pb2.FieldMask = None, @@ -1120,7 +1120,7 @@ def update_entity_type( r"""Updates the parameters of a single EntityType. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateEntityTypeRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateEntityTypeRequest, dict]): The request object. Request message for [FeaturestoreService.UpdateEntityType][google.cloud.aiplatform.v1beta1.FeaturestoreService.UpdateEntityType]. entity_type (google.cloud.aiplatform_v1beta1.types.EntityType): @@ -1210,7 +1210,7 @@ def update_entity_type( def delete_entity_type( self, - request: featurestore_service.DeleteEntityTypeRequest = None, + request: Union[featurestore_service.DeleteEntityTypeRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1222,7 +1222,7 @@ def delete_entity_type( succeed. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteEntityTypeRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteEntityTypeRequest, dict]): The request object. Request message for [FeaturestoreService.DeleteEntityTypes][]. name (str): @@ -1305,7 +1305,7 @@ def delete_entity_type( def create_feature( self, - request: featurestore_service.CreateFeatureRequest = None, + request: Union[featurestore_service.CreateFeatureRequest, dict] = None, *, parent: str = None, feature: gca_feature.Feature = None, @@ -1316,7 +1316,7 @@ def create_feature( r"""Creates a new Feature in a given EntityType. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateFeatureRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateFeatureRequest, dict]): The request object. Request message for [FeaturestoreService.CreateFeature][google.cloud.aiplatform.v1beta1.FeaturestoreService.CreateFeature]. parent (str): @@ -1396,7 +1396,7 @@ def create_feature( def batch_create_features( self, - request: featurestore_service.BatchCreateFeaturesRequest = None, + request: Union[featurestore_service.BatchCreateFeaturesRequest, dict] = None, *, parent: str = None, requests: Sequence[featurestore_service.CreateFeatureRequest] = None, @@ -1407,7 +1407,7 @@ def batch_create_features( r"""Creates a batch of Features in a given EntityType. Args: - request (google.cloud.aiplatform_v1beta1.types.BatchCreateFeaturesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.BatchCreateFeaturesRequest, dict]): The request object. Request message for [FeaturestoreService.BatchCreateFeatures][google.cloud.aiplatform.v1beta1.FeaturestoreService.BatchCreateFeatures]. parent (str): @@ -1494,7 +1494,7 @@ def batch_create_features( def get_feature( self, - request: featurestore_service.GetFeatureRequest = None, + request: Union[featurestore_service.GetFeatureRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1504,7 +1504,7 @@ def get_feature( r"""Gets details of a single Feature. Args: - request (google.cloud.aiplatform_v1beta1.types.GetFeatureRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetFeatureRequest, dict]): The request object. Request message for [FeaturestoreService.GetFeature][google.cloud.aiplatform.v1beta1.FeaturestoreService.GetFeature]. name (str): @@ -1568,7 +1568,7 @@ def get_feature( def list_features( self, - request: featurestore_service.ListFeaturesRequest = None, + request: Union[featurestore_service.ListFeaturesRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1578,7 +1578,7 @@ def list_features( r"""Lists Features in a given EntityType. Args: - request (google.cloud.aiplatform_v1beta1.types.ListFeaturesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListFeaturesRequest, dict]): The request object. Request message for [FeaturestoreService.ListFeatures][google.cloud.aiplatform.v1beta1.FeaturestoreService.ListFeatures]. parent (str): @@ -1649,7 +1649,7 @@ def list_features( def update_feature( self, - request: featurestore_service.UpdateFeatureRequest = None, + request: Union[featurestore_service.UpdateFeatureRequest, dict] = None, *, feature: gca_feature.Feature = None, update_mask: field_mask_pb2.FieldMask = None, @@ -1660,7 +1660,7 @@ def update_feature( r"""Updates the parameters of a single Feature. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateFeatureRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateFeatureRequest, dict]): The request object. Request message for [FeaturestoreService.UpdateFeature][google.cloud.aiplatform.v1beta1.FeaturestoreService.UpdateFeature]. feature (google.cloud.aiplatform_v1beta1.types.Feature): @@ -1749,7 +1749,7 @@ def update_feature( def delete_feature( self, - request: featurestore_service.DeleteFeatureRequest = None, + request: Union[featurestore_service.DeleteFeatureRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1759,7 +1759,7 @@ def delete_feature( r"""Deletes a single Feature. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteFeatureRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteFeatureRequest, dict]): The request object. Request message for [FeaturestoreService.DeleteFeature][google.cloud.aiplatform.v1beta1.FeaturestoreService.DeleteFeature]. name (str): @@ -1842,7 +1842,7 @@ def delete_feature( def import_feature_values( self, - request: featurestore_service.ImportFeatureValuesRequest = None, + request: Union[featurestore_service.ImportFeatureValuesRequest, dict] = None, *, entity_type: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1872,7 +1872,7 @@ def import_feature_values( - Online serving cluster is under-provisioned. Args: - request (google.cloud.aiplatform_v1beta1.types.ImportFeatureValuesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ImportFeatureValuesRequest, dict]): The request object. Request message for [FeaturestoreService.ImportFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreService.ImportFeatureValues]. entity_type (str): @@ -1949,7 +1949,7 @@ def import_feature_values( def batch_read_feature_values( self, - request: featurestore_service.BatchReadFeatureValuesRequest = None, + request: Union[featurestore_service.BatchReadFeatureValuesRequest, dict] = None, *, featurestore: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1964,7 +1964,7 @@ def batch_read_feature_values( read instance as of each instance's read timestamp. Args: - request (google.cloud.aiplatform_v1beta1.types.BatchReadFeatureValuesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.BatchReadFeatureValuesRequest, dict]): The request object. Request message for [FeaturestoreService.BatchReadFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreService.BatchReadFeatureValues]. (- Next Id: 6 -) @@ -2043,7 +2043,7 @@ def batch_read_feature_values( def export_feature_values( self, - request: featurestore_service.ExportFeatureValuesRequest = None, + request: Union[featurestore_service.ExportFeatureValuesRequest, dict] = None, *, entity_type: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2054,7 +2054,7 @@ def export_feature_values( target EntityType. Args: - request (google.cloud.aiplatform_v1beta1.types.ExportFeatureValuesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ExportFeatureValuesRequest, dict]): The request object. Request message for [FeaturestoreService.ExportFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreService.ExportFeatureValues]. entity_type (str): @@ -2130,7 +2130,7 @@ def export_feature_values( def search_features( self, - request: featurestore_service.SearchFeaturesRequest = None, + request: Union[featurestore_service.SearchFeaturesRequest, dict] = None, *, location: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2141,7 +2141,7 @@ def search_features( project. Args: - request (google.cloud.aiplatform_v1beta1.types.SearchFeaturesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.SearchFeaturesRequest, dict]): The request object. Request message for [FeaturestoreService.SearchFeatures][google.cloud.aiplatform.v1beta1.FeaturestoreService.SearchFeatures]. location (str): diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/base.py index c2c03a28de..6a9b2a24a7 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/base.py @@ -124,7 +124,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc.py index d94ddae826..1d6220ab49 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc.py @@ -88,16 +88,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc_asyncio.py index 7f1344a6e7..1ee2fdfe47 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc_asyncio.py @@ -135,16 +135,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/client.py b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/client.py index ca692ee019..8978888ffa 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -378,7 +378,7 @@ def __init__( def create_index_endpoint( self, - request: index_endpoint_service.CreateIndexEndpointRequest = None, + request: Union[index_endpoint_service.CreateIndexEndpointRequest, dict] = None, *, parent: str = None, index_endpoint: gca_index_endpoint.IndexEndpoint = None, @@ -389,7 +389,7 @@ def create_index_endpoint( r"""Creates an IndexEndpoint. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateIndexEndpointRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateIndexEndpointRequest, dict]): The request object. Request message for [IndexEndpointService.CreateIndexEndpoint][google.cloud.aiplatform.v1beta1.IndexEndpointService.CreateIndexEndpoint]. parent (str): @@ -470,7 +470,7 @@ def create_index_endpoint( def get_index_endpoint( self, - request: index_endpoint_service.GetIndexEndpointRequest = None, + request: Union[index_endpoint_service.GetIndexEndpointRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -480,7 +480,7 @@ def get_index_endpoint( r"""Gets an IndexEndpoint. Args: - request (google.cloud.aiplatform_v1beta1.types.GetIndexEndpointRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetIndexEndpointRequest, dict]): The request object. Request message for [IndexEndpointService.GetIndexEndpoint][google.cloud.aiplatform.v1beta1.IndexEndpointService.GetIndexEndpoint] name (str): @@ -543,7 +543,7 @@ def get_index_endpoint( def list_index_endpoints( self, - request: index_endpoint_service.ListIndexEndpointsRequest = None, + request: Union[index_endpoint_service.ListIndexEndpointsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -553,7 +553,7 @@ def list_index_endpoints( r"""Lists IndexEndpoints in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListIndexEndpointsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListIndexEndpointsRequest, dict]): The request object. Request message for [IndexEndpointService.ListIndexEndpoints][google.cloud.aiplatform.v1beta1.IndexEndpointService.ListIndexEndpoints]. parent (str): @@ -624,7 +624,7 @@ def list_index_endpoints( def update_index_endpoint( self, - request: index_endpoint_service.UpdateIndexEndpointRequest = None, + request: Union[index_endpoint_service.UpdateIndexEndpointRequest, dict] = None, *, index_endpoint: gca_index_endpoint.IndexEndpoint = None, update_mask: field_mask_pb2.FieldMask = None, @@ -635,7 +635,7 @@ def update_index_endpoint( r"""Updates an IndexEndpoint. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateIndexEndpointRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateIndexEndpointRequest, dict]): The request object. Request message for [IndexEndpointService.UpdateIndexEndpoint][google.cloud.aiplatform.v1beta1.IndexEndpointService.UpdateIndexEndpoint]. index_endpoint (google.cloud.aiplatform_v1beta1.types.IndexEndpoint): @@ -708,7 +708,7 @@ def update_index_endpoint( def delete_index_endpoint( self, - request: index_endpoint_service.DeleteIndexEndpointRequest = None, + request: Union[index_endpoint_service.DeleteIndexEndpointRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -718,7 +718,7 @@ def delete_index_endpoint( r"""Deletes an IndexEndpoint. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteIndexEndpointRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteIndexEndpointRequest, dict]): The request object. Request message for [IndexEndpointService.DeleteIndexEndpoint][google.cloud.aiplatform.v1beta1.IndexEndpointService.DeleteIndexEndpoint]. name (str): @@ -801,7 +801,7 @@ def delete_index_endpoint( def deploy_index( self, - request: index_endpoint_service.DeployIndexRequest = None, + request: Union[index_endpoint_service.DeployIndexRequest, dict] = None, *, index_endpoint: str = None, deployed_index: gca_index_endpoint.DeployedIndex = None, @@ -814,7 +814,7 @@ def deploy_index( Only non-empty Indexes can be deployed. Args: - request (google.cloud.aiplatform_v1beta1.types.DeployIndexRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeployIndexRequest, dict]): The request object. Request message for [IndexEndpointService.DeployIndex][google.cloud.aiplatform.v1beta1.IndexEndpointService.DeployIndex]. index_endpoint (str): @@ -899,7 +899,7 @@ def deploy_index( def undeploy_index( self, - request: index_endpoint_service.UndeployIndexRequest = None, + request: Union[index_endpoint_service.UndeployIndexRequest, dict] = None, *, index_endpoint: str = None, deployed_index_id: str = None, @@ -912,7 +912,7 @@ def undeploy_index( using. Args: - request (google.cloud.aiplatform_v1beta1.types.UndeployIndexRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UndeployIndexRequest, dict]): The request object. Request message for [IndexEndpointService.UndeployIndex][google.cloud.aiplatform.v1beta1.IndexEndpointService.UndeployIndex]. index_endpoint (str): diff --git a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/base.py index 91d6e5783d..c5288f6eb6 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/base.py @@ -121,7 +121,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc.py index 4b56849bf2..77098f8a74 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc.py @@ -84,16 +84,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc_asyncio.py index f6e320fe0f..22cfc61ccc 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc_asyncio.py @@ -131,16 +131,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/index_service/client.py b/google/cloud/aiplatform_v1beta1/services/index_service/client.py index 67d8a97c6c..3d26ed6911 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/index_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -378,7 +378,7 @@ def __init__( def create_index( self, - request: index_service.CreateIndexRequest = None, + request: Union[index_service.CreateIndexRequest, dict] = None, *, parent: str = None, index: gca_index.Index = None, @@ -389,7 +389,7 @@ def create_index( r"""Creates an Index. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateIndexRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateIndexRequest, dict]): The request object. Request message for [IndexService.CreateIndex][google.cloud.aiplatform.v1beta1.IndexService.CreateIndex]. parent (str): @@ -469,7 +469,7 @@ def create_index( def get_index( self, - request: index_service.GetIndexRequest = None, + request: Union[index_service.GetIndexRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -479,7 +479,7 @@ def get_index( r"""Gets an Index. Args: - request (google.cloud.aiplatform_v1beta1.types.GetIndexRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetIndexRequest, dict]): The request object. Request message for [IndexService.GetIndex][google.cloud.aiplatform.v1beta1.IndexService.GetIndex] name (str): @@ -542,7 +542,7 @@ def get_index( def list_indexes( self, - request: index_service.ListIndexesRequest = None, + request: Union[index_service.ListIndexesRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -552,7 +552,7 @@ def list_indexes( r"""Lists Indexes in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListIndexesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListIndexesRequest, dict]): The request object. Request message for [IndexService.ListIndexes][google.cloud.aiplatform.v1beta1.IndexService.ListIndexes]. parent (str): @@ -623,7 +623,7 @@ def list_indexes( def update_index( self, - request: index_service.UpdateIndexRequest = None, + request: Union[index_service.UpdateIndexRequest, dict] = None, *, index: gca_index.Index = None, update_mask: field_mask_pb2.FieldMask = None, @@ -634,7 +634,7 @@ def update_index( r"""Updates an Index. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateIndexRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateIndexRequest, dict]): The request object. Request message for [IndexService.UpdateIndex][google.cloud.aiplatform.v1beta1.IndexService.UpdateIndex]. index (google.cloud.aiplatform_v1beta1.types.Index): @@ -718,7 +718,7 @@ def update_index( def delete_index( self, - request: index_service.DeleteIndexRequest = None, + request: Union[index_service.DeleteIndexRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -730,7 +730,7 @@ def delete_index( had been undeployed. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteIndexRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteIndexRequest, dict]): The request object. Request message for [IndexService.DeleteIndex][google.cloud.aiplatform.v1beta1.IndexService.DeleteIndex]. name (str): diff --git a/google/cloud/aiplatform_v1beta1/services/index_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/index_service/transports/base.py index 98cd4c01ce..96d8177d62 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/index_service/transports/base.py @@ -120,7 +120,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc.py index a6abb48dba..36c1a7061b 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc.py @@ -84,16 +84,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc_asyncio.py index 5038647b08..dc9c589c7e 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc_asyncio.py @@ -131,16 +131,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/job_service/client.py b/google/cloud/aiplatform_v1beta1/services/job_service/client.py index 4dd5f9fcea..e7c3079e67 100644 --- a/google/cloud/aiplatform_v1beta1/services/job_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/job_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -560,7 +560,7 @@ def __init__( def create_custom_job( self, - request: job_service.CreateCustomJobRequest = None, + request: Union[job_service.CreateCustomJobRequest, dict] = None, *, parent: str = None, custom_job: gca_custom_job.CustomJob = None, @@ -572,7 +572,7 @@ def create_custom_job( will be attempted to be run. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateCustomJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateCustomJobRequest, dict]): The request object. Request message for [JobService.CreateCustomJob][google.cloud.aiplatform.v1beta1.JobService.CreateCustomJob]. parent (str): @@ -647,7 +647,7 @@ def create_custom_job( def get_custom_job( self, - request: job_service.GetCustomJobRequest = None, + request: Union[job_service.GetCustomJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -657,7 +657,7 @@ def get_custom_job( r"""Gets a CustomJob. Args: - request (google.cloud.aiplatform_v1beta1.types.GetCustomJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetCustomJobRequest, dict]): The request object. Request message for [JobService.GetCustomJob][google.cloud.aiplatform.v1beta1.JobService.GetCustomJob]. name (str): @@ -724,7 +724,7 @@ def get_custom_job( def list_custom_jobs( self, - request: job_service.ListCustomJobsRequest = None, + request: Union[job_service.ListCustomJobsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -734,7 +734,7 @@ def list_custom_jobs( r"""Lists CustomJobs in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListCustomJobsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListCustomJobsRequest, dict]): The request object. Request message for [JobService.ListCustomJobs][google.cloud.aiplatform.v1beta1.JobService.ListCustomJobs]. parent (str): @@ -805,7 +805,7 @@ def list_custom_jobs( def delete_custom_job( self, - request: job_service.DeleteCustomJobRequest = None, + request: Union[job_service.DeleteCustomJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -815,7 +815,7 @@ def delete_custom_job( r"""Deletes a CustomJob. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteCustomJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteCustomJobRequest, dict]): The request object. Request message for [JobService.DeleteCustomJob][google.cloud.aiplatform.v1beta1.JobService.DeleteCustomJob]. name (str): @@ -898,7 +898,7 @@ def delete_custom_job( def cancel_custom_job( self, - request: job_service.CancelCustomJobRequest = None, + request: Union[job_service.CancelCustomJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -920,7 +920,7 @@ def cancel_custom_job( is set to ``CANCELLED``. Args: - request (google.cloud.aiplatform_v1beta1.types.CancelCustomJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CancelCustomJobRequest, dict]): The request object. Request message for [JobService.CancelCustomJob][google.cloud.aiplatform.v1beta1.JobService.CancelCustomJob]. name (str): @@ -974,7 +974,7 @@ def cancel_custom_job( def create_data_labeling_job( self, - request: job_service.CreateDataLabelingJobRequest = None, + request: Union[job_service.CreateDataLabelingJobRequest, dict] = None, *, parent: str = None, data_labeling_job: gca_data_labeling_job.DataLabelingJob = None, @@ -985,7 +985,7 @@ def create_data_labeling_job( r"""Creates a DataLabelingJob. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateDataLabelingJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateDataLabelingJobRequest, dict]): The request object. Request message for [JobService.CreateDataLabelingJob][google.cloud.aiplatform.v1beta1.JobService.CreateDataLabelingJob]. parent (str): @@ -1056,7 +1056,7 @@ def create_data_labeling_job( def get_data_labeling_job( self, - request: job_service.GetDataLabelingJobRequest = None, + request: Union[job_service.GetDataLabelingJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1066,7 +1066,7 @@ def get_data_labeling_job( r"""Gets a DataLabelingJob. Args: - request (google.cloud.aiplatform_v1beta1.types.GetDataLabelingJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetDataLabelingJobRequest, dict]): The request object. Request message for [JobService.GetDataLabelingJob][google.cloud.aiplatform.v1beta1.JobService.GetDataLabelingJob]. name (str): @@ -1128,7 +1128,7 @@ def get_data_labeling_job( def list_data_labeling_jobs( self, - request: job_service.ListDataLabelingJobsRequest = None, + request: Union[job_service.ListDataLabelingJobsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1138,7 +1138,7 @@ def list_data_labeling_jobs( r"""Lists DataLabelingJobs in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListDataLabelingJobsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListDataLabelingJobsRequest, dict]): The request object. Request message for [JobService.ListDataLabelingJobs][google.cloud.aiplatform.v1beta1.JobService.ListDataLabelingJobs]. parent (str): @@ -1208,7 +1208,7 @@ def list_data_labeling_jobs( def delete_data_labeling_job( self, - request: job_service.DeleteDataLabelingJobRequest = None, + request: Union[job_service.DeleteDataLabelingJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1218,7 +1218,7 @@ def delete_data_labeling_job( r"""Deletes a DataLabelingJob. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteDataLabelingJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteDataLabelingJobRequest, dict]): The request object. Request message for [JobService.DeleteDataLabelingJob][google.cloud.aiplatform.v1beta1.JobService.DeleteDataLabelingJob]. name (str): @@ -1301,7 +1301,7 @@ def delete_data_labeling_job( def cancel_data_labeling_job( self, - request: job_service.CancelDataLabelingJobRequest = None, + request: Union[job_service.CancelDataLabelingJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1312,7 +1312,7 @@ def cancel_data_labeling_job( not guaranteed. Args: - request (google.cloud.aiplatform_v1beta1.types.CancelDataLabelingJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CancelDataLabelingJobRequest, dict]): The request object. Request message for [JobService.CancelDataLabelingJob][google.cloud.aiplatform.v1beta1.JobService.CancelDataLabelingJob]. name (str): @@ -1366,7 +1366,7 @@ def cancel_data_labeling_job( def create_hyperparameter_tuning_job( self, - request: job_service.CreateHyperparameterTuningJobRequest = None, + request: Union[job_service.CreateHyperparameterTuningJobRequest, dict] = None, *, parent: str = None, hyperparameter_tuning_job: gca_hyperparameter_tuning_job.HyperparameterTuningJob = None, @@ -1377,7 +1377,7 @@ def create_hyperparameter_tuning_job( r"""Creates a HyperparameterTuningJob Args: - request (google.cloud.aiplatform_v1beta1.types.CreateHyperparameterTuningJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateHyperparameterTuningJobRequest, dict]): The request object. Request message for [JobService.CreateHyperparameterTuningJob][google.cloud.aiplatform.v1beta1.JobService.CreateHyperparameterTuningJob]. parent (str): @@ -1452,7 +1452,7 @@ def create_hyperparameter_tuning_job( def get_hyperparameter_tuning_job( self, - request: job_service.GetHyperparameterTuningJobRequest = None, + request: Union[job_service.GetHyperparameterTuningJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1462,7 +1462,7 @@ def get_hyperparameter_tuning_job( r"""Gets a HyperparameterTuningJob Args: - request (google.cloud.aiplatform_v1beta1.types.GetHyperparameterTuningJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetHyperparameterTuningJobRequest, dict]): The request object. Request message for [JobService.GetHyperparameterTuningJob][google.cloud.aiplatform.v1beta1.JobService.GetHyperparameterTuningJob]. name (str): @@ -1528,7 +1528,7 @@ def get_hyperparameter_tuning_job( def list_hyperparameter_tuning_jobs( self, - request: job_service.ListHyperparameterTuningJobsRequest = None, + request: Union[job_service.ListHyperparameterTuningJobsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1538,7 +1538,7 @@ def list_hyperparameter_tuning_jobs( r"""Lists HyperparameterTuningJobs in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListHyperparameterTuningJobsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListHyperparameterTuningJobsRequest, dict]): The request object. Request message for [JobService.ListHyperparameterTuningJobs][google.cloud.aiplatform.v1beta1.JobService.ListHyperparameterTuningJobs]. parent (str): @@ -1611,7 +1611,7 @@ def list_hyperparameter_tuning_jobs( def delete_hyperparameter_tuning_job( self, - request: job_service.DeleteHyperparameterTuningJobRequest = None, + request: Union[job_service.DeleteHyperparameterTuningJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1621,7 +1621,7 @@ def delete_hyperparameter_tuning_job( r"""Deletes a HyperparameterTuningJob. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteHyperparameterTuningJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteHyperparameterTuningJobRequest, dict]): The request object. Request message for [JobService.DeleteHyperparameterTuningJob][google.cloud.aiplatform.v1beta1.JobService.DeleteHyperparameterTuningJob]. name (str): @@ -1706,7 +1706,7 @@ def delete_hyperparameter_tuning_job( def cancel_hyperparameter_tuning_job( self, - request: job_service.CancelHyperparameterTuningJobRequest = None, + request: Union[job_service.CancelHyperparameterTuningJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1729,7 +1729,7 @@ def cancel_hyperparameter_tuning_job( is set to ``CANCELLED``. Args: - request (google.cloud.aiplatform_v1beta1.types.CancelHyperparameterTuningJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CancelHyperparameterTuningJobRequest, dict]): The request object. Request message for [JobService.CancelHyperparameterTuningJob][google.cloud.aiplatform.v1beta1.JobService.CancelHyperparameterTuningJob]. name (str): @@ -1786,7 +1786,7 @@ def cancel_hyperparameter_tuning_job( def create_batch_prediction_job( self, - request: job_service.CreateBatchPredictionJobRequest = None, + request: Union[job_service.CreateBatchPredictionJobRequest, dict] = None, *, parent: str = None, batch_prediction_job: gca_batch_prediction_job.BatchPredictionJob = None, @@ -1798,7 +1798,7 @@ def create_batch_prediction_job( once created will right away be attempted to start. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateBatchPredictionJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateBatchPredictionJobRequest, dict]): The request object. Request message for [JobService.CreateBatchPredictionJob][google.cloud.aiplatform.v1beta1.JobService.CreateBatchPredictionJob]. parent (str): @@ -1875,7 +1875,7 @@ def create_batch_prediction_job( def get_batch_prediction_job( self, - request: job_service.GetBatchPredictionJobRequest = None, + request: Union[job_service.GetBatchPredictionJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1885,7 +1885,7 @@ def get_batch_prediction_job( r"""Gets a BatchPredictionJob Args: - request (google.cloud.aiplatform_v1beta1.types.GetBatchPredictionJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetBatchPredictionJobRequest, dict]): The request object. Request message for [JobService.GetBatchPredictionJob][google.cloud.aiplatform.v1beta1.JobService.GetBatchPredictionJob]. name (str): @@ -1951,7 +1951,7 @@ def get_batch_prediction_job( def list_batch_prediction_jobs( self, - request: job_service.ListBatchPredictionJobsRequest = None, + request: Union[job_service.ListBatchPredictionJobsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1961,7 +1961,7 @@ def list_batch_prediction_jobs( r"""Lists BatchPredictionJobs in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListBatchPredictionJobsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListBatchPredictionJobsRequest, dict]): The request object. Request message for [JobService.ListBatchPredictionJobs][google.cloud.aiplatform.v1beta1.JobService.ListBatchPredictionJobs]. parent (str): @@ -2034,7 +2034,7 @@ def list_batch_prediction_jobs( def delete_batch_prediction_job( self, - request: job_service.DeleteBatchPredictionJobRequest = None, + request: Union[job_service.DeleteBatchPredictionJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2045,7 +2045,7 @@ def delete_batch_prediction_job( jobs that already finished. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteBatchPredictionJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteBatchPredictionJobRequest, dict]): The request object. Request message for [JobService.DeleteBatchPredictionJob][google.cloud.aiplatform.v1beta1.JobService.DeleteBatchPredictionJob]. name (str): @@ -2130,7 +2130,7 @@ def delete_batch_prediction_job( def cancel_batch_prediction_job( self, - request: job_service.CancelBatchPredictionJobRequest = None, + request: Union[job_service.CancelBatchPredictionJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2151,7 +2151,7 @@ def cancel_batch_prediction_job( are not deleted. Args: - request (google.cloud.aiplatform_v1beta1.types.CancelBatchPredictionJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CancelBatchPredictionJobRequest, dict]): The request object. Request message for [JobService.CancelBatchPredictionJob][google.cloud.aiplatform.v1beta1.JobService.CancelBatchPredictionJob]. name (str): @@ -2208,7 +2208,9 @@ def cancel_batch_prediction_job( def create_model_deployment_monitoring_job( self, - request: job_service.CreateModelDeploymentMonitoringJobRequest = None, + request: Union[ + job_service.CreateModelDeploymentMonitoringJobRequest, dict + ] = None, *, parent: str = None, model_deployment_monitoring_job: gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob = None, @@ -2220,7 +2222,7 @@ def create_model_deployment_monitoring_job( periodically on a configured interval. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateModelDeploymentMonitoringJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateModelDeploymentMonitoringJobRequest, dict]): The request object. Request message for [JobService.CreateModelDeploymentMonitoringJob][google.cloud.aiplatform.v1beta1.JobService.CreateModelDeploymentMonitoringJob]. parent (str): @@ -2300,7 +2302,9 @@ def create_model_deployment_monitoring_job( def search_model_deployment_monitoring_stats_anomalies( self, - request: job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest = None, + request: Union[ + job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest, dict + ] = None, *, model_deployment_monitoring_job: str = None, deployed_model_id: str = None, @@ -2312,7 +2316,7 @@ def search_model_deployment_monitoring_stats_anomalies( a given time window. Args: - request (google.cloud.aiplatform_v1beta1.types.SearchModelDeploymentMonitoringStatsAnomaliesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.SearchModelDeploymentMonitoringStatsAnomaliesRequest, dict]): The request object. Request message for [JobService.SearchModelDeploymentMonitoringStatsAnomalies][google.cloud.aiplatform.v1beta1.JobService.SearchModelDeploymentMonitoringStatsAnomalies]. model_deployment_monitoring_job (str): @@ -2407,7 +2411,7 @@ def search_model_deployment_monitoring_stats_anomalies( def get_model_deployment_monitoring_job( self, - request: job_service.GetModelDeploymentMonitoringJobRequest = None, + request: Union[job_service.GetModelDeploymentMonitoringJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2417,7 +2421,7 @@ def get_model_deployment_monitoring_job( r"""Gets a ModelDeploymentMonitoringJob. Args: - request (google.cloud.aiplatform_v1beta1.types.GetModelDeploymentMonitoringJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetModelDeploymentMonitoringJobRequest, dict]): The request object. Request message for [JobService.GetModelDeploymentMonitoringJob][google.cloud.aiplatform.v1beta1.JobService.GetModelDeploymentMonitoringJob]. name (str): @@ -2484,7 +2488,9 @@ def get_model_deployment_monitoring_job( def list_model_deployment_monitoring_jobs( self, - request: job_service.ListModelDeploymentMonitoringJobsRequest = None, + request: Union[ + job_service.ListModelDeploymentMonitoringJobsRequest, dict + ] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2494,7 +2500,7 @@ def list_model_deployment_monitoring_jobs( r"""Lists ModelDeploymentMonitoringJobs in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListModelDeploymentMonitoringJobsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListModelDeploymentMonitoringJobsRequest, dict]): The request object. Request message for [JobService.ListModelDeploymentMonitoringJobs][google.cloud.aiplatform.v1beta1.JobService.ListModelDeploymentMonitoringJobs]. parent (str): @@ -2569,7 +2575,9 @@ def list_model_deployment_monitoring_jobs( def update_model_deployment_monitoring_job( self, - request: job_service.UpdateModelDeploymentMonitoringJobRequest = None, + request: Union[ + job_service.UpdateModelDeploymentMonitoringJobRequest, dict + ] = None, *, model_deployment_monitoring_job: gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob = None, update_mask: field_mask_pb2.FieldMask = None, @@ -2580,7 +2588,7 @@ def update_model_deployment_monitoring_job( r"""Updates a ModelDeploymentMonitoringJob. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateModelDeploymentMonitoringJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateModelDeploymentMonitoringJobRequest, dict]): The request object. Request message for [JobService.UpdateModelDeploymentMonitoringJob][google.cloud.aiplatform.v1beta1.JobService.UpdateModelDeploymentMonitoringJob]. model_deployment_monitoring_job (google.cloud.aiplatform_v1beta1.types.ModelDeploymentMonitoringJob): @@ -2675,7 +2683,9 @@ def update_model_deployment_monitoring_job( def delete_model_deployment_monitoring_job( self, - request: job_service.DeleteModelDeploymentMonitoringJobRequest = None, + request: Union[ + job_service.DeleteModelDeploymentMonitoringJobRequest, dict + ] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2685,7 +2695,7 @@ def delete_model_deployment_monitoring_job( r"""Deletes a ModelDeploymentMonitoringJob. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteModelDeploymentMonitoringJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteModelDeploymentMonitoringJobRequest, dict]): The request object. Request message for [JobService.DeleteModelDeploymentMonitoringJob][google.cloud.aiplatform.v1beta1.JobService.DeleteModelDeploymentMonitoringJob]. name (str): @@ -2772,7 +2782,9 @@ def delete_model_deployment_monitoring_job( def pause_model_deployment_monitoring_job( self, - request: job_service.PauseModelDeploymentMonitoringJobRequest = None, + request: Union[ + job_service.PauseModelDeploymentMonitoringJobRequest, dict + ] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2785,7 +2797,7 @@ def pause_model_deployment_monitoring_job( to 'PAUSED'. Args: - request (google.cloud.aiplatform_v1beta1.types.PauseModelDeploymentMonitoringJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.PauseModelDeploymentMonitoringJobRequest, dict]): The request object. Request message for [JobService.PauseModelDeploymentMonitoringJob][google.cloud.aiplatform.v1beta1.JobService.PauseModelDeploymentMonitoringJob]. name (str): @@ -2844,7 +2856,9 @@ def pause_model_deployment_monitoring_job( def resume_model_deployment_monitoring_job( self, - request: job_service.ResumeModelDeploymentMonitoringJobRequest = None, + request: Union[ + job_service.ResumeModelDeploymentMonitoringJobRequest, dict + ] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2856,7 +2870,7 @@ def resume_model_deployment_monitoring_job( ModelDeploymentMonitoringJob can't be resumed. Args: - request (google.cloud.aiplatform_v1beta1.types.ResumeModelDeploymentMonitoringJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ResumeModelDeploymentMonitoringJobRequest, dict]): The request object. Request message for [JobService.ResumeModelDeploymentMonitoringJob][google.cloud.aiplatform.v1beta1.JobService.ResumeModelDeploymentMonitoringJob]. name (str): diff --git a/google/cloud/aiplatform_v1beta1/services/job_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/job_service/transports/base.py index 8698bed1e9..84ea327f16 100644 --- a/google/cloud/aiplatform_v1beta1/services/job_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/job_service/transports/base.py @@ -138,7 +138,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc.py index c233b8a6ee..4e8ac8ff63 100644 --- a/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc.py @@ -101,16 +101,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc_asyncio.py index 8dc7fcb242..60e6479913 100644 --- a/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc_asyncio.py @@ -148,16 +148,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/metadata_service/client.py b/google/cloud/aiplatform_v1beta1/services/metadata_service/client.py index 8fd792f79e..ae276d6a34 100644 --- a/google/cloud/aiplatform_v1beta1/services/metadata_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/metadata_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -456,7 +456,7 @@ def __init__( def create_metadata_store( self, - request: metadata_service.CreateMetadataStoreRequest = None, + request: Union[metadata_service.CreateMetadataStoreRequest, dict] = None, *, parent: str = None, metadata_store: gca_metadata_store.MetadataStore = None, @@ -469,7 +469,7 @@ def create_metadata_store( resources. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateMetadataStoreRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateMetadataStoreRequest, dict]): The request object. Request message for [MetadataService.CreateMetadataStore][google.cloud.aiplatform.v1beta1.MetadataService.CreateMetadataStore]. parent (str): @@ -568,7 +568,7 @@ def create_metadata_store( def get_metadata_store( self, - request: metadata_service.GetMetadataStoreRequest = None, + request: Union[metadata_service.GetMetadataStoreRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -578,7 +578,7 @@ def get_metadata_store( r"""Retrieves a specific MetadataStore. Args: - request (google.cloud.aiplatform_v1beta1.types.GetMetadataStoreRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetMetadataStoreRequest, dict]): The request object. Request message for [MetadataService.GetMetadataStore][google.cloud.aiplatform.v1beta1.MetadataService.GetMetadataStore]. name (str): @@ -641,7 +641,7 @@ def get_metadata_store( def list_metadata_stores( self, - request: metadata_service.ListMetadataStoresRequest = None, + request: Union[metadata_service.ListMetadataStoresRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -651,7 +651,7 @@ def list_metadata_stores( r"""Lists MetadataStores for a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListMetadataStoresRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListMetadataStoresRequest, dict]): The request object. Request message for [MetadataService.ListMetadataStores][google.cloud.aiplatform.v1beta1.MetadataService.ListMetadataStores]. parent (str): @@ -722,7 +722,7 @@ def list_metadata_stores( def delete_metadata_store( self, - request: metadata_service.DeleteMetadataStoreRequest = None, + request: Union[metadata_service.DeleteMetadataStoreRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -733,7 +733,7 @@ def delete_metadata_store( resources (Artifacts, Executions, and Contexts). Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteMetadataStoreRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteMetadataStoreRequest, dict]): The request object. Request message for [MetadataService.DeleteMetadataStore][google.cloud.aiplatform.v1beta1.MetadataService.DeleteMetadataStore]. name (str): @@ -816,7 +816,7 @@ def delete_metadata_store( def create_artifact( self, - request: metadata_service.CreateArtifactRequest = None, + request: Union[metadata_service.CreateArtifactRequest, dict] = None, *, parent: str = None, artifact: gca_artifact.Artifact = None, @@ -828,7 +828,7 @@ def create_artifact( r"""Creates an Artifact associated with a MetadataStore. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateArtifactRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateArtifactRequest, dict]): The request object. Request message for [MetadataService.CreateArtifact][google.cloud.aiplatform.v1beta1.MetadataService.CreateArtifact]. parent (str): @@ -913,7 +913,7 @@ def create_artifact( def get_artifact( self, - request: metadata_service.GetArtifactRequest = None, + request: Union[metadata_service.GetArtifactRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -923,7 +923,7 @@ def get_artifact( r"""Retrieves a specific Artifact. Args: - request (google.cloud.aiplatform_v1beta1.types.GetArtifactRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetArtifactRequest, dict]): The request object. Request message for [MetadataService.GetArtifact][google.cloud.aiplatform.v1beta1.MetadataService.GetArtifact]. name (str): @@ -983,7 +983,7 @@ def get_artifact( def list_artifacts( self, - request: metadata_service.ListArtifactsRequest = None, + request: Union[metadata_service.ListArtifactsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -993,7 +993,7 @@ def list_artifacts( r"""Lists Artifacts in the MetadataStore. Args: - request (google.cloud.aiplatform_v1beta1.types.ListArtifactsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListArtifactsRequest, dict]): The request object. Request message for [MetadataService.ListArtifacts][google.cloud.aiplatform.v1beta1.MetadataService.ListArtifacts]. parent (str): @@ -1064,7 +1064,7 @@ def list_artifacts( def update_artifact( self, - request: metadata_service.UpdateArtifactRequest = None, + request: Union[metadata_service.UpdateArtifactRequest, dict] = None, *, artifact: gca_artifact.Artifact = None, update_mask: field_mask_pb2.FieldMask = None, @@ -1075,7 +1075,7 @@ def update_artifact( r"""Updates a stored Artifact. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateArtifactRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateArtifactRequest, dict]): The request object. Request message for [MetadataService.UpdateArtifact][google.cloud.aiplatform.v1beta1.MetadataService.UpdateArtifact]. artifact (google.cloud.aiplatform_v1beta1.types.Artifact): @@ -1151,7 +1151,7 @@ def update_artifact( def delete_artifact( self, - request: metadata_service.DeleteArtifactRequest = None, + request: Union[metadata_service.DeleteArtifactRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1161,7 +1161,7 @@ def delete_artifact( r"""Deletes an Artifact. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteArtifactRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteArtifactRequest, dict]): The request object. Request message for [MetadataService.DeleteArtifact][google.cloud.aiplatform.v1beta1.MetadataService.DeleteArtifact]. name (str): @@ -1244,7 +1244,7 @@ def delete_artifact( def purge_artifacts( self, - request: metadata_service.PurgeArtifactsRequest = None, + request: Union[metadata_service.PurgeArtifactsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1254,7 +1254,7 @@ def purge_artifacts( r"""Purges Artifacts. Args: - request (google.cloud.aiplatform_v1beta1.types.PurgeArtifactsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.PurgeArtifactsRequest, dict]): The request object. Request message for [MetadataService.PurgeArtifacts][google.cloud.aiplatform.v1beta1.MetadataService.PurgeArtifacts]. parent (str): @@ -1328,7 +1328,7 @@ def purge_artifacts( def create_context( self, - request: metadata_service.CreateContextRequest = None, + request: Union[metadata_service.CreateContextRequest, dict] = None, *, parent: str = None, context: gca_context.Context = None, @@ -1340,7 +1340,7 @@ def create_context( r"""Creates a Context associated with a MetadataStore. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateContextRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateContextRequest, dict]): The request object. Request message for [MetadataService.CreateContext][google.cloud.aiplatform.v1beta1.MetadataService.CreateContext]. parent (str): @@ -1425,7 +1425,7 @@ def create_context( def get_context( self, - request: metadata_service.GetContextRequest = None, + request: Union[metadata_service.GetContextRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1435,7 +1435,7 @@ def get_context( r"""Retrieves a specific Context. Args: - request (google.cloud.aiplatform_v1beta1.types.GetContextRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetContextRequest, dict]): The request object. Request message for [MetadataService.GetContext][google.cloud.aiplatform.v1beta1.MetadataService.GetContext]. name (str): @@ -1495,7 +1495,7 @@ def get_context( def list_contexts( self, - request: metadata_service.ListContextsRequest = None, + request: Union[metadata_service.ListContextsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1505,7 +1505,7 @@ def list_contexts( r"""Lists Contexts on the MetadataStore. Args: - request (google.cloud.aiplatform_v1beta1.types.ListContextsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListContextsRequest, dict]): The request object. Request message for [MetadataService.ListContexts][google.cloud.aiplatform.v1beta1.MetadataService.ListContexts] parent (str): @@ -1576,7 +1576,7 @@ def list_contexts( def update_context( self, - request: metadata_service.UpdateContextRequest = None, + request: Union[metadata_service.UpdateContextRequest, dict] = None, *, context: gca_context.Context = None, update_mask: field_mask_pb2.FieldMask = None, @@ -1587,7 +1587,7 @@ def update_context( r"""Updates a stored Context. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateContextRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateContextRequest, dict]): The request object. Request message for [MetadataService.UpdateContext][google.cloud.aiplatform.v1beta1.MetadataService.UpdateContext]. context (google.cloud.aiplatform_v1beta1.types.Context): @@ -1662,7 +1662,7 @@ def update_context( def delete_context( self, - request: metadata_service.DeleteContextRequest = None, + request: Union[metadata_service.DeleteContextRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1672,7 +1672,7 @@ def delete_context( r"""Deletes a stored Context. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteContextRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteContextRequest, dict]): The request object. Request message for [MetadataService.DeleteContext][google.cloud.aiplatform.v1beta1.MetadataService.DeleteContext]. name (str): @@ -1755,7 +1755,7 @@ def delete_context( def purge_contexts( self, - request: metadata_service.PurgeContextsRequest = None, + request: Union[metadata_service.PurgeContextsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1765,7 +1765,7 @@ def purge_contexts( r"""Purges Contexts. Args: - request (google.cloud.aiplatform_v1beta1.types.PurgeContextsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.PurgeContextsRequest, dict]): The request object. Request message for [MetadataService.PurgeContexts][google.cloud.aiplatform.v1beta1.MetadataService.PurgeContexts]. parent (str): @@ -1839,7 +1839,9 @@ def purge_contexts( def add_context_artifacts_and_executions( self, - request: metadata_service.AddContextArtifactsAndExecutionsRequest = None, + request: Union[ + metadata_service.AddContextArtifactsAndExecutionsRequest, dict + ] = None, *, context: str = None, artifacts: Sequence[str] = None, @@ -1853,7 +1855,7 @@ def add_context_artifacts_and_executions( added to a Context, they are simply skipped. Args: - request (google.cloud.aiplatform_v1beta1.types.AddContextArtifactsAndExecutionsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.AddContextArtifactsAndExecutionsRequest, dict]): The request object. Request message for [MetadataService.AddContextArtifactsAndExecutions][google.cloud.aiplatform.v1beta1.MetadataService.AddContextArtifactsAndExecutions]. context (str): @@ -1943,7 +1945,7 @@ def add_context_artifacts_and_executions( def add_context_children( self, - request: metadata_service.AddContextChildrenRequest = None, + request: Union[metadata_service.AddContextChildrenRequest, dict] = None, *, context: str = None, child_contexts: Sequence[str] = None, @@ -1958,7 +1960,7 @@ def add_context_children( request will fail with an INVALID_ARGUMENT error. Args: - request (google.cloud.aiplatform_v1beta1.types.AddContextChildrenRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.AddContextChildrenRequest, dict]): The request object. Request message for [MetadataService.AddContextChildren][google.cloud.aiplatform.v1beta1.MetadataService.AddContextChildren]. context (str): @@ -2030,7 +2032,9 @@ def add_context_children( def query_context_lineage_subgraph( self, - request: metadata_service.QueryContextLineageSubgraphRequest = None, + request: Union[ + metadata_service.QueryContextLineageSubgraphRequest, dict + ] = None, *, context: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2042,7 +2046,7 @@ def query_context_lineage_subgraph( as a LineageSubgraph. Args: - request (google.cloud.aiplatform_v1beta1.types.QueryContextLineageSubgraphRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.QueryContextLineageSubgraphRequest, dict]): The request object. Request message for [MetadataService.QueryContextLineageSubgraph][google.cloud.aiplatform.v1beta1.MetadataService.QueryContextLineageSubgraph]. context (str): @@ -2113,7 +2117,7 @@ def query_context_lineage_subgraph( def create_execution( self, - request: metadata_service.CreateExecutionRequest = None, + request: Union[metadata_service.CreateExecutionRequest, dict] = None, *, parent: str = None, execution: gca_execution.Execution = None, @@ -2125,7 +2129,7 @@ def create_execution( r"""Creates an Execution associated with a MetadataStore. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateExecutionRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateExecutionRequest, dict]): The request object. Request message for [MetadataService.CreateExecution][google.cloud.aiplatform.v1beta1.MetadataService.CreateExecution]. parent (str): @@ -2210,7 +2214,7 @@ def create_execution( def get_execution( self, - request: metadata_service.GetExecutionRequest = None, + request: Union[metadata_service.GetExecutionRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2220,7 +2224,7 @@ def get_execution( r"""Retrieves a specific Execution. Args: - request (google.cloud.aiplatform_v1beta1.types.GetExecutionRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetExecutionRequest, dict]): The request object. Request message for [MetadataService.GetExecution][google.cloud.aiplatform.v1beta1.MetadataService.GetExecution]. name (str): @@ -2280,7 +2284,7 @@ def get_execution( def list_executions( self, - request: metadata_service.ListExecutionsRequest = None, + request: Union[metadata_service.ListExecutionsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2290,7 +2294,7 @@ def list_executions( r"""Lists Executions in the MetadataStore. Args: - request (google.cloud.aiplatform_v1beta1.types.ListExecutionsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListExecutionsRequest, dict]): The request object. Request message for [MetadataService.ListExecutions][google.cloud.aiplatform.v1beta1.MetadataService.ListExecutions]. parent (str): @@ -2361,7 +2365,7 @@ def list_executions( def update_execution( self, - request: metadata_service.UpdateExecutionRequest = None, + request: Union[metadata_service.UpdateExecutionRequest, dict] = None, *, execution: gca_execution.Execution = None, update_mask: field_mask_pb2.FieldMask = None, @@ -2372,7 +2376,7 @@ def update_execution( r"""Updates a stored Execution. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateExecutionRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateExecutionRequest, dict]): The request object. Request message for [MetadataService.UpdateExecution][google.cloud.aiplatform.v1beta1.MetadataService.UpdateExecution]. execution (google.cloud.aiplatform_v1beta1.types.Execution): @@ -2448,7 +2452,7 @@ def update_execution( def delete_execution( self, - request: metadata_service.DeleteExecutionRequest = None, + request: Union[metadata_service.DeleteExecutionRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2458,7 +2462,7 @@ def delete_execution( r"""Deletes an Execution. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteExecutionRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteExecutionRequest, dict]): The request object. Request message for [MetadataService.DeleteExecution][google.cloud.aiplatform.v1beta1.MetadataService.DeleteExecution]. name (str): @@ -2541,7 +2545,7 @@ def delete_execution( def purge_executions( self, - request: metadata_service.PurgeExecutionsRequest = None, + request: Union[metadata_service.PurgeExecutionsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2551,7 +2555,7 @@ def purge_executions( r"""Purges Executions. Args: - request (google.cloud.aiplatform_v1beta1.types.PurgeExecutionsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.PurgeExecutionsRequest, dict]): The request object. Request message for [MetadataService.PurgeExecutions][google.cloud.aiplatform.v1beta1.MetadataService.PurgeExecutions]. parent (str): @@ -2625,7 +2629,7 @@ def purge_executions( def add_execution_events( self, - request: metadata_service.AddExecutionEventsRequest = None, + request: Union[metadata_service.AddExecutionEventsRequest, dict] = None, *, execution: str = None, events: Sequence[event.Event] = None, @@ -2640,7 +2644,7 @@ def add_execution_events( skipped. Args: - request (google.cloud.aiplatform_v1beta1.types.AddExecutionEventsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.AddExecutionEventsRequest, dict]): The request object. Request message for [MetadataService.AddExecutionEvents][google.cloud.aiplatform.v1beta1.MetadataService.AddExecutionEvents]. execution (str): @@ -2712,7 +2716,9 @@ def add_execution_events( def query_execution_inputs_and_outputs( self, - request: metadata_service.QueryExecutionInputsAndOutputsRequest = None, + request: Union[ + metadata_service.QueryExecutionInputsAndOutputsRequest, dict + ] = None, *, execution: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2724,7 +2730,7 @@ def query_execution_inputs_and_outputs( contains the Execution and connecting Events. Args: - request (google.cloud.aiplatform_v1beta1.types.QueryExecutionInputsAndOutputsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.QueryExecutionInputsAndOutputsRequest, dict]): The request object. Request message for [MetadataService.QueryExecutionInputsAndOutputs][google.cloud.aiplatform.v1beta1.MetadataService.QueryExecutionInputsAndOutputs]. execution (str): @@ -2795,7 +2801,7 @@ def query_execution_inputs_and_outputs( def create_metadata_schema( self, - request: metadata_service.CreateMetadataSchemaRequest = None, + request: Union[metadata_service.CreateMetadataSchemaRequest, dict] = None, *, parent: str = None, metadata_schema: gca_metadata_schema.MetadataSchema = None, @@ -2807,7 +2813,7 @@ def create_metadata_schema( r"""Creates a MetadataSchema. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateMetadataSchemaRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateMetadataSchemaRequest, dict]): The request object. Request message for [MetadataService.CreateMetadataSchema][google.cloud.aiplatform.v1beta1.MetadataService.CreateMetadataSchema]. parent (str): @@ -2894,7 +2900,7 @@ def create_metadata_schema( def get_metadata_schema( self, - request: metadata_service.GetMetadataSchemaRequest = None, + request: Union[metadata_service.GetMetadataSchemaRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2904,7 +2910,7 @@ def get_metadata_schema( r"""Retrieves a specific MetadataSchema. Args: - request (google.cloud.aiplatform_v1beta1.types.GetMetadataSchemaRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetMetadataSchemaRequest, dict]): The request object. Request message for [MetadataService.GetMetadataSchema][google.cloud.aiplatform.v1beta1.MetadataService.GetMetadataSchema]. name (str): @@ -2964,7 +2970,7 @@ def get_metadata_schema( def list_metadata_schemas( self, - request: metadata_service.ListMetadataSchemasRequest = None, + request: Union[metadata_service.ListMetadataSchemasRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2974,7 +2980,7 @@ def list_metadata_schemas( r"""Lists MetadataSchemas. Args: - request (google.cloud.aiplatform_v1beta1.types.ListMetadataSchemasRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListMetadataSchemasRequest, dict]): The request object. Request message for [MetadataService.ListMetadataSchemas][google.cloud.aiplatform.v1beta1.MetadataService.ListMetadataSchemas]. parent (str): @@ -3046,7 +3052,9 @@ def list_metadata_schemas( def query_artifact_lineage_subgraph( self, - request: metadata_service.QueryArtifactLineageSubgraphRequest = None, + request: Union[ + metadata_service.QueryArtifactLineageSubgraphRequest, dict + ] = None, *, artifact: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -3058,7 +3066,7 @@ def query_artifact_lineage_subgraph( returned as a LineageSubgraph. Args: - request (google.cloud.aiplatform_v1beta1.types.QueryArtifactLineageSubgraphRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.QueryArtifactLineageSubgraphRequest, dict]): The request object. Request message for [MetadataService.QueryArtifactLineageSubgraph][google.cloud.aiplatform.v1beta1.MetadataService.QueryArtifactLineageSubgraph]. artifact (str): diff --git a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/base.py index 5b74127d6b..d0f2db53b6 100644 --- a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/base.py @@ -129,7 +129,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc.py index 616e305415..2f5e2cd754 100644 --- a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc.py @@ -92,16 +92,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc_asyncio.py index b8d93250d8..bffbb0b532 100644 --- a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc_asyncio.py @@ -139,16 +139,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/migration_service/client.py b/google/cloud/aiplatform_v1beta1/services/migration_service/client.py index 4810778f39..4a3bf16f36 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -195,32 +195,32 @@ def parse_dataset_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def dataset_path(project: str, location: str, dataset: str,) -> str: + def dataset_path(project: str, dataset: str,) -> str: """Returns a fully-qualified dataset string.""" - return "projects/{project}/locations/{location}/datasets/{dataset}".format( - project=project, location=location, dataset=dataset, + return "projects/{project}/datasets/{dataset}".format( + project=project, dataset=dataset, ) @staticmethod def parse_dataset_path(path: str) -> Dict[str, str]: """Parses a dataset path into its component segments.""" - m = re.match( - r"^projects/(?P.+?)/locations/(?P.+?)/datasets/(?P.+?)$", - path, - ) + m = re.match(r"^projects/(?P.+?)/datasets/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod - def dataset_path(project: str, dataset: str,) -> str: + def dataset_path(project: str, location: str, dataset: str,) -> str: """Returns a fully-qualified dataset string.""" - return "projects/{project}/datasets/{dataset}".format( - project=project, dataset=dataset, + return "projects/{project}/locations/{location}/datasets/{dataset}".format( + project=project, location=location, dataset=dataset, ) @staticmethod def parse_dataset_path(path: str) -> Dict[str, str]: """Parses a dataset path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/datasets/(?P.+?)$", path) + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/datasets/(?P.+?)$", + path, + ) return m.groupdict() if m else {} @staticmethod @@ -452,7 +452,7 @@ def __init__( def search_migratable_resources( self, - request: migration_service.SearchMigratableResourcesRequest = None, + request: Union[migration_service.SearchMigratableResourcesRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -465,7 +465,7 @@ def search_migratable_resources( given location. Args: - request (google.cloud.aiplatform_v1beta1.types.SearchMigratableResourcesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.SearchMigratableResourcesRequest, dict]): The request object. Request message for [MigrationService.SearchMigratableResources][google.cloud.aiplatform.v1beta1.MigrationService.SearchMigratableResources]. parent (str): @@ -540,7 +540,7 @@ def search_migratable_resources( def batch_migrate_resources( self, - request: migration_service.BatchMigrateResourcesRequest = None, + request: Union[migration_service.BatchMigrateResourcesRequest, dict] = None, *, parent: str = None, migrate_resource_requests: Sequence[ @@ -555,7 +555,7 @@ def batch_migrate_resources( to Vertex AI. Args: - request (google.cloud.aiplatform_v1beta1.types.BatchMigrateResourcesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.BatchMigrateResourcesRequest, dict]): The request object. Request message for [MigrationService.BatchMigrateResources][google.cloud.aiplatform.v1beta1.MigrationService.BatchMigrateResources]. parent (str): diff --git a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/base.py index 3405e5f216..e4a5ad3dbb 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/base.py @@ -119,7 +119,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc.py index 6d05e3be67..93f31c9cff 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc.py @@ -83,16 +83,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc_asyncio.py index dee450202b..e387a209b5 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc_asyncio.py @@ -130,16 +130,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/client.py b/google/cloud/aiplatform_v1beta1/services/model_service/client.py index b883c31e0f..442e21a2d8 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -438,7 +438,7 @@ def __init__( def upload_model( self, - request: model_service.UploadModelRequest = None, + request: Union[model_service.UploadModelRequest, dict] = None, *, parent: str = None, model: gca_model.Model = None, @@ -449,7 +449,7 @@ def upload_model( r"""Uploads a Model artifact into Vertex AI. Args: - request (google.cloud.aiplatform_v1beta1.types.UploadModelRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UploadModelRequest, dict]): The request object. Request message for [ModelService.UploadModel][google.cloud.aiplatform.v1beta1.ModelService.UploadModel]. parent (str): @@ -531,7 +531,7 @@ def upload_model( def get_model( self, - request: model_service.GetModelRequest = None, + request: Union[model_service.GetModelRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -541,7 +541,7 @@ def get_model( r"""Gets a Model. Args: - request (google.cloud.aiplatform_v1beta1.types.GetModelRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetModelRequest, dict]): The request object. Request message for [ModelService.GetModel][google.cloud.aiplatform.v1beta1.ModelService.GetModel]. name (str): @@ -600,7 +600,7 @@ def get_model( def list_models( self, - request: model_service.ListModelsRequest = None, + request: Union[model_service.ListModelsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -610,7 +610,7 @@ def list_models( r"""Lists Models in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListModelsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListModelsRequest, dict]): The request object. Request message for [ModelService.ListModels][google.cloud.aiplatform.v1beta1.ModelService.ListModels]. parent (str): @@ -681,7 +681,7 @@ def list_models( def update_model( self, - request: model_service.UpdateModelRequest = None, + request: Union[model_service.UpdateModelRequest, dict] = None, *, model: gca_model.Model = None, update_mask: field_mask_pb2.FieldMask = None, @@ -692,7 +692,7 @@ def update_model( r"""Updates a Model. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateModelRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateModelRequest, dict]): The request object. Request message for [ModelService.UpdateModel][google.cloud.aiplatform.v1beta1.ModelService.UpdateModel]. model (google.cloud.aiplatform_v1beta1.types.Model): @@ -763,7 +763,7 @@ def update_model( def delete_model( self, - request: model_service.DeleteModelRequest = None, + request: Union[model_service.DeleteModelRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -775,7 +775,7 @@ def delete_model( DeployedModels created from it. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteModelRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteModelRequest, dict]): The request object. Request message for [ModelService.DeleteModel][google.cloud.aiplatform.v1beta1.ModelService.DeleteModel]. name (str): @@ -858,7 +858,7 @@ def delete_model( def export_model( self, - request: model_service.ExportModelRequest = None, + request: Union[model_service.ExportModelRequest, dict] = None, *, name: str = None, output_config: model_service.ExportModelRequest.OutputConfig = None, @@ -872,7 +872,7 @@ def export_model( format][google.cloud.aiplatform.v1beta1.Model.supported_export_formats]. Args: - request (google.cloud.aiplatform_v1beta1.types.ExportModelRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ExportModelRequest, dict]): The request object. Request message for [ModelService.ExportModel][google.cloud.aiplatform.v1beta1.ModelService.ExportModel]. name (str): @@ -956,7 +956,7 @@ def export_model( def get_model_evaluation( self, - request: model_service.GetModelEvaluationRequest = None, + request: Union[model_service.GetModelEvaluationRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -966,7 +966,7 @@ def get_model_evaluation( r"""Gets a ModelEvaluation. Args: - request (google.cloud.aiplatform_v1beta1.types.GetModelEvaluationRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetModelEvaluationRequest, dict]): The request object. Request message for [ModelService.GetModelEvaluation][google.cloud.aiplatform.v1beta1.ModelService.GetModelEvaluation]. name (str): @@ -1030,7 +1030,7 @@ def get_model_evaluation( def list_model_evaluations( self, - request: model_service.ListModelEvaluationsRequest = None, + request: Union[model_service.ListModelEvaluationsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1040,7 +1040,7 @@ def list_model_evaluations( r"""Lists ModelEvaluations in a Model. Args: - request (google.cloud.aiplatform_v1beta1.types.ListModelEvaluationsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListModelEvaluationsRequest, dict]): The request object. Request message for [ModelService.ListModelEvaluations][google.cloud.aiplatform.v1beta1.ModelService.ListModelEvaluations]. parent (str): @@ -1111,7 +1111,7 @@ def list_model_evaluations( def get_model_evaluation_slice( self, - request: model_service.GetModelEvaluationSliceRequest = None, + request: Union[model_service.GetModelEvaluationSliceRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1121,7 +1121,7 @@ def get_model_evaluation_slice( r"""Gets a ModelEvaluationSlice. Args: - request (google.cloud.aiplatform_v1beta1.types.GetModelEvaluationSliceRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetModelEvaluationSliceRequest, dict]): The request object. Request message for [ModelService.GetModelEvaluationSlice][google.cloud.aiplatform.v1beta1.ModelService.GetModelEvaluationSlice]. name (str): @@ -1187,7 +1187,7 @@ def get_model_evaluation_slice( def list_model_evaluation_slices( self, - request: model_service.ListModelEvaluationSlicesRequest = None, + request: Union[model_service.ListModelEvaluationSlicesRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1197,7 +1197,7 @@ def list_model_evaluation_slices( r"""Lists ModelEvaluationSlices in a ModelEvaluation. Args: - request (google.cloud.aiplatform_v1beta1.types.ListModelEvaluationSlicesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListModelEvaluationSlicesRequest, dict]): The request object. Request message for [ModelService.ListModelEvaluationSlices][google.cloud.aiplatform.v1beta1.ModelService.ListModelEvaluationSlices]. parent (str): diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/model_service/transports/base.py index e96cb0c0de..bc1db67191 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/transports/base.py @@ -123,7 +123,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc.py index 2e4b11a0ca..11707783bc 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc.py @@ -86,16 +86,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc_asyncio.py index 78bdc7709e..e60807e791 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc_asyncio.py @@ -133,16 +133,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/pipeline_service/client.py b/google/cloud/aiplatform_v1beta1/services/pipeline_service/client.py index 06eba87b60..59934749f2 100644 --- a/google/cloud/aiplatform_v1beta1/services/pipeline_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/pipeline_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -516,7 +516,7 @@ def __init__( def create_training_pipeline( self, - request: pipeline_service.CreateTrainingPipelineRequest = None, + request: Union[pipeline_service.CreateTrainingPipelineRequest, dict] = None, *, parent: str = None, training_pipeline: gca_training_pipeline.TrainingPipeline = None, @@ -528,7 +528,7 @@ def create_training_pipeline( TrainingPipeline right away will be attempted to be run. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateTrainingPipelineRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateTrainingPipelineRequest, dict]): The request object. Request message for [PipelineService.CreateTrainingPipeline][google.cloud.aiplatform.v1beta1.PipelineService.CreateTrainingPipeline]. parent (str): @@ -603,7 +603,7 @@ def create_training_pipeline( def get_training_pipeline( self, - request: pipeline_service.GetTrainingPipelineRequest = None, + request: Union[pipeline_service.GetTrainingPipelineRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -613,7 +613,7 @@ def get_training_pipeline( r"""Gets a TrainingPipeline. Args: - request (google.cloud.aiplatform_v1beta1.types.GetTrainingPipelineRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetTrainingPipelineRequest, dict]): The request object. Request message for [PipelineService.GetTrainingPipeline][google.cloud.aiplatform.v1beta1.PipelineService.GetTrainingPipeline]. name (str): @@ -679,7 +679,7 @@ def get_training_pipeline( def list_training_pipelines( self, - request: pipeline_service.ListTrainingPipelinesRequest = None, + request: Union[pipeline_service.ListTrainingPipelinesRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -689,7 +689,7 @@ def list_training_pipelines( r"""Lists TrainingPipelines in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListTrainingPipelinesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListTrainingPipelinesRequest, dict]): The request object. Request message for [PipelineService.ListTrainingPipelines][google.cloud.aiplatform.v1beta1.PipelineService.ListTrainingPipelines]. parent (str): @@ -760,7 +760,7 @@ def list_training_pipelines( def delete_training_pipeline( self, - request: pipeline_service.DeleteTrainingPipelineRequest = None, + request: Union[pipeline_service.DeleteTrainingPipelineRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -770,7 +770,7 @@ def delete_training_pipeline( r"""Deletes a TrainingPipeline. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteTrainingPipelineRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteTrainingPipelineRequest, dict]): The request object. Request message for [PipelineService.DeleteTrainingPipeline][google.cloud.aiplatform.v1beta1.PipelineService.DeleteTrainingPipeline]. name (str): @@ -853,7 +853,7 @@ def delete_training_pipeline( def cancel_training_pipeline( self, - request: pipeline_service.CancelTrainingPipelineRequest = None, + request: Union[pipeline_service.CancelTrainingPipelineRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -875,7 +875,7 @@ def cancel_training_pipeline( is set to ``CANCELLED``. Args: - request (google.cloud.aiplatform_v1beta1.types.CancelTrainingPipelineRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CancelTrainingPipelineRequest, dict]): The request object. Request message for [PipelineService.CancelTrainingPipeline][google.cloud.aiplatform.v1beta1.PipelineService.CancelTrainingPipeline]. name (str): @@ -930,7 +930,7 @@ def cancel_training_pipeline( def create_pipeline_job( self, - request: pipeline_service.CreatePipelineJobRequest = None, + request: Union[pipeline_service.CreatePipelineJobRequest, dict] = None, *, parent: str = None, pipeline_job: gca_pipeline_job.PipelineJob = None, @@ -943,7 +943,7 @@ def create_pipeline_job( immediately when created. Args: - request (google.cloud.aiplatform_v1beta1.types.CreatePipelineJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreatePipelineJobRequest, dict]): The request object. Request message for [PipelineService.CreatePipelineJob][google.cloud.aiplatform.v1beta1.PipelineService.CreatePipelineJob]. parent (str): @@ -1025,7 +1025,7 @@ def create_pipeline_job( def get_pipeline_job( self, - request: pipeline_service.GetPipelineJobRequest = None, + request: Union[pipeline_service.GetPipelineJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1035,7 +1035,7 @@ def get_pipeline_job( r"""Gets a PipelineJob. Args: - request (google.cloud.aiplatform_v1beta1.types.GetPipelineJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetPipelineJobRequest, dict]): The request object. Request message for [PipelineService.GetPipelineJob][google.cloud.aiplatform.v1beta1.PipelineService.GetPipelineJob]. name (str): @@ -1096,7 +1096,7 @@ def get_pipeline_job( def list_pipeline_jobs( self, - request: pipeline_service.ListPipelineJobsRequest = None, + request: Union[pipeline_service.ListPipelineJobsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1106,7 +1106,7 @@ def list_pipeline_jobs( r"""Lists PipelineJobs in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListPipelineJobsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListPipelineJobsRequest, dict]): The request object. Request message for [PipelineService.ListPipelineJobs][google.cloud.aiplatform.v1beta1.PipelineService.ListPipelineJobs]. parent (str): @@ -1177,7 +1177,7 @@ def list_pipeline_jobs( def delete_pipeline_job( self, - request: pipeline_service.DeletePipelineJobRequest = None, + request: Union[pipeline_service.DeletePipelineJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1187,7 +1187,7 @@ def delete_pipeline_job( r"""Deletes a PipelineJob. Args: - request (google.cloud.aiplatform_v1beta1.types.DeletePipelineJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeletePipelineJobRequest, dict]): The request object. Request message for [PipelineService.DeletePipelineJob][google.cloud.aiplatform.v1beta1.PipelineService.DeletePipelineJob]. name (str): @@ -1270,7 +1270,7 @@ def delete_pipeline_job( def cancel_pipeline_job( self, - request: pipeline_service.CancelPipelineJobRequest = None, + request: Union[pipeline_service.CancelPipelineJobRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1292,7 +1292,7 @@ def cancel_pipeline_job( is set to ``CANCELLED``. Args: - request (google.cloud.aiplatform_v1beta1.types.CancelPipelineJobRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CancelPipelineJobRequest, dict]): The request object. Request message for [PipelineService.CancelPipelineJob][google.cloud.aiplatform.v1beta1.PipelineService.CancelPipelineJob]. name (str): diff --git a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/base.py index d862d4e558..f7088c087c 100644 --- a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/base.py @@ -126,7 +126,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc.py index a7f1f05a1c..76f7eb1ff7 100644 --- a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc.py @@ -92,16 +92,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc_asyncio.py index 57c91c01e2..6b43165aea 100644 --- a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc_asyncio.py @@ -139,16 +139,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/prediction_service/client.py b/google/cloud/aiplatform_v1beta1/services/prediction_service/client.py index 7e7104474c..6259b8949c 100644 --- a/google/cloud/aiplatform_v1beta1/services/prediction_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/prediction_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -357,7 +357,7 @@ def __init__( def predict( self, - request: prediction_service.PredictRequest = None, + request: Union[prediction_service.PredictRequest, dict] = None, *, endpoint: str = None, instances: Sequence[struct_pb2.Value] = None, @@ -369,7 +369,7 @@ def predict( r"""Perform an online prediction. Args: - request (google.cloud.aiplatform_v1beta1.types.PredictRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.PredictRequest, dict]): The request object. Request message for [PredictionService.Predict][google.cloud.aiplatform.v1beta1.PredictionService.Predict]. endpoint (str): @@ -462,7 +462,7 @@ def predict( def raw_predict( self, - request: prediction_service.RawPredictRequest = None, + request: Union[prediction_service.RawPredictRequest, dict] = None, *, endpoint: str = None, http_body: httpbody_pb2.HttpBody = None, @@ -474,7 +474,7 @@ def raw_predict( payload. Args: - request (google.cloud.aiplatform_v1beta1.types.RawPredictRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.RawPredictRequest, dict]): The request object. Request message for [PredictionService.RawPredict][google.cloud.aiplatform.v1beta1.PredictionService.RawPredict]. endpoint (str): @@ -607,7 +607,7 @@ def raw_predict( def explain( self, - request: prediction_service.ExplainRequest = None, + request: Union[prediction_service.ExplainRequest, dict] = None, *, endpoint: str = None, instances: Sequence[struct_pb2.Value] = None, @@ -631,7 +631,7 @@ def explain( explanation_spec. Args: - request (google.cloud.aiplatform_v1beta1.types.ExplainRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ExplainRequest, dict]): The request object. Request message for [PredictionService.Explain][google.cloud.aiplatform.v1beta1.PredictionService.Explain]. endpoint (str): diff --git a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/base.py index 535940029d..8ddec736d2 100644 --- a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/base.py @@ -118,7 +118,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc.py index 0914e151f7..2c38fec99b 100644 --- a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc.py @@ -81,16 +81,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc_asyncio.py index ea9ba4af2d..141f2f9866 100644 --- a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc_asyncio.py @@ -128,16 +128,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/client.py b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/client.py index cb27dfbf9b..1389e506a7 100644 --- a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -367,7 +367,9 @@ def __init__( def create_specialist_pool( self, - request: specialist_pool_service.CreateSpecialistPoolRequest = None, + request: Union[ + specialist_pool_service.CreateSpecialistPoolRequest, dict + ] = None, *, parent: str = None, specialist_pool: gca_specialist_pool.SpecialistPool = None, @@ -378,7 +380,7 @@ def create_specialist_pool( r"""Creates a SpecialistPool. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateSpecialistPoolRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateSpecialistPoolRequest, dict]): The request object. Request message for [SpecialistPoolService.CreateSpecialistPool][google.cloud.aiplatform.v1beta1.SpecialistPoolService.CreateSpecialistPool]. parent (str): @@ -465,7 +467,7 @@ def create_specialist_pool( def get_specialist_pool( self, - request: specialist_pool_service.GetSpecialistPoolRequest = None, + request: Union[specialist_pool_service.GetSpecialistPoolRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -475,7 +477,7 @@ def get_specialist_pool( r"""Gets a SpecialistPool. Args: - request (google.cloud.aiplatform_v1beta1.types.GetSpecialistPoolRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetSpecialistPoolRequest, dict]): The request object. Request message for [SpecialistPoolService.GetSpecialistPool][google.cloud.aiplatform.v1beta1.SpecialistPoolService.GetSpecialistPool]. name (str): @@ -547,7 +549,7 @@ def get_specialist_pool( def list_specialist_pools( self, - request: specialist_pool_service.ListSpecialistPoolsRequest = None, + request: Union[specialist_pool_service.ListSpecialistPoolsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -557,7 +559,7 @@ def list_specialist_pools( r"""Lists SpecialistPools in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListSpecialistPoolsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListSpecialistPoolsRequest, dict]): The request object. Request message for [SpecialistPoolService.ListSpecialistPools][google.cloud.aiplatform.v1beta1.SpecialistPoolService.ListSpecialistPools]. parent (str): @@ -628,7 +630,9 @@ def list_specialist_pools( def delete_specialist_pool( self, - request: specialist_pool_service.DeleteSpecialistPoolRequest = None, + request: Union[ + specialist_pool_service.DeleteSpecialistPoolRequest, dict + ] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -639,7 +643,7 @@ def delete_specialist_pool( in the pool. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteSpecialistPoolRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteSpecialistPoolRequest, dict]): The request object. Request message for [SpecialistPoolService.DeleteSpecialistPool][google.cloud.aiplatform.v1beta1.SpecialistPoolService.DeleteSpecialistPool]. name (str): @@ -722,7 +726,9 @@ def delete_specialist_pool( def update_specialist_pool( self, - request: specialist_pool_service.UpdateSpecialistPoolRequest = None, + request: Union[ + specialist_pool_service.UpdateSpecialistPoolRequest, dict + ] = None, *, specialist_pool: gca_specialist_pool.SpecialistPool = None, update_mask: field_mask_pb2.FieldMask = None, @@ -733,7 +739,7 @@ def update_specialist_pool( r"""Updates a SpecialistPool. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateSpecialistPoolRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateSpecialistPoolRequest, dict]): The request object. Request message for [SpecialistPoolService.UpdateSpecialistPool][google.cloud.aiplatform.v1beta1.SpecialistPoolService.UpdateSpecialistPool]. specialist_pool (google.cloud.aiplatform_v1beta1.types.SpecialistPool): diff --git a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/base.py index 1a42154dca..935ef9846d 100644 --- a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/base.py @@ -120,7 +120,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc.py index 94aa3bc866..bd2e88fa2e 100644 --- a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc.py @@ -88,16 +88,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc_asyncio.py index d7257c54dc..496dee453e 100644 --- a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc_asyncio.py @@ -135,16 +135,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/client.py b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/client.py index 57e9dd36dd..85afe3ed71 100644 --- a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Iterable, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Iterable, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -445,7 +445,7 @@ def __init__( def create_tensorboard( self, - request: tensorboard_service.CreateTensorboardRequest = None, + request: Union[tensorboard_service.CreateTensorboardRequest, dict] = None, *, parent: str = None, tensorboard: gca_tensorboard.Tensorboard = None, @@ -456,7 +456,7 @@ def create_tensorboard( r"""Creates a Tensorboard. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateTensorboardRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateTensorboardRequest, dict]): The request object. Request message for [TensorboardService.CreateTensorboard][google.cloud.aiplatform.v1beta1.TensorboardService.CreateTensorboard]. parent (str): @@ -537,7 +537,7 @@ def create_tensorboard( def get_tensorboard( self, - request: tensorboard_service.GetTensorboardRequest = None, + request: Union[tensorboard_service.GetTensorboardRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -547,7 +547,7 @@ def get_tensorboard( r"""Gets a Tensorboard. Args: - request (google.cloud.aiplatform_v1beta1.types.GetTensorboardRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetTensorboardRequest, dict]): The request object. Request message for [TensorboardService.GetTensorboard][google.cloud.aiplatform.v1beta1.TensorboardService.GetTensorboard]. name (str): @@ -612,7 +612,7 @@ def get_tensorboard( def update_tensorboard( self, - request: tensorboard_service.UpdateTensorboardRequest = None, + request: Union[tensorboard_service.UpdateTensorboardRequest, dict] = None, *, tensorboard: gca_tensorboard.Tensorboard = None, update_mask: field_mask_pb2.FieldMask = None, @@ -623,7 +623,7 @@ def update_tensorboard( r"""Updates a Tensorboard. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateTensorboardRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateTensorboardRequest, dict]): The request object. Request message for [TensorboardService.UpdateTensorboard][google.cloud.aiplatform.v1beta1.TensorboardService.UpdateTensorboard]. tensorboard (google.cloud.aiplatform_v1beta1.types.Tensorboard): @@ -713,7 +713,7 @@ def update_tensorboard( def list_tensorboards( self, - request: tensorboard_service.ListTensorboardsRequest = None, + request: Union[tensorboard_service.ListTensorboardsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -723,7 +723,7 @@ def list_tensorboards( r"""Lists Tensorboards in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListTensorboardsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListTensorboardsRequest, dict]): The request object. Request message for [TensorboardService.ListTensorboards][google.cloud.aiplatform.v1beta1.TensorboardService.ListTensorboards]. parent (str): @@ -794,7 +794,7 @@ def list_tensorboards( def delete_tensorboard( self, - request: tensorboard_service.DeleteTensorboardRequest = None, + request: Union[tensorboard_service.DeleteTensorboardRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -804,7 +804,7 @@ def delete_tensorboard( r"""Deletes a Tensorboard. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteTensorboardRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteTensorboardRequest, dict]): The request object. Request message for [TensorboardService.DeleteTensorboard][google.cloud.aiplatform.v1beta1.TensorboardService.DeleteTensorboard]. name (str): @@ -887,7 +887,9 @@ def delete_tensorboard( def create_tensorboard_experiment( self, - request: tensorboard_service.CreateTensorboardExperimentRequest = None, + request: Union[ + tensorboard_service.CreateTensorboardExperimentRequest, dict + ] = None, *, parent: str = None, tensorboard_experiment: gca_tensorboard_experiment.TensorboardExperiment = None, @@ -899,7 +901,7 @@ def create_tensorboard_experiment( r"""Creates a TensorboardExperiment. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateTensorboardExperimentRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateTensorboardExperimentRequest, dict]): The request object. Request message for [TensorboardService.CreateTensorboardExperiment][google.cloud.aiplatform.v1beta1.TensorboardService.CreateTensorboardExperiment]. parent (str): @@ -989,7 +991,9 @@ def create_tensorboard_experiment( def get_tensorboard_experiment( self, - request: tensorboard_service.GetTensorboardExperimentRequest = None, + request: Union[ + tensorboard_service.GetTensorboardExperimentRequest, dict + ] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -999,7 +1003,7 @@ def get_tensorboard_experiment( r"""Gets a TensorboardExperiment. Args: - request (google.cloud.aiplatform_v1beta1.types.GetTensorboardExperimentRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetTensorboardExperimentRequest, dict]): The request object. Request message for [TensorboardService.GetTensorboardExperiment][google.cloud.aiplatform.v1beta1.TensorboardService.GetTensorboardExperiment]. name (str): @@ -1065,7 +1069,9 @@ def get_tensorboard_experiment( def update_tensorboard_experiment( self, - request: tensorboard_service.UpdateTensorboardExperimentRequest = None, + request: Union[ + tensorboard_service.UpdateTensorboardExperimentRequest, dict + ] = None, *, tensorboard_experiment: gca_tensorboard_experiment.TensorboardExperiment = None, update_mask: field_mask_pb2.FieldMask = None, @@ -1076,7 +1082,7 @@ def update_tensorboard_experiment( r"""Updates a TensorboardExperiment. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateTensorboardExperimentRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateTensorboardExperimentRequest, dict]): The request object. Request message for [TensorboardService.UpdateTensorboardExperiment][google.cloud.aiplatform.v1beta1.TensorboardService.UpdateTensorboardExperiment]. tensorboard_experiment (google.cloud.aiplatform_v1beta1.types.TensorboardExperiment): @@ -1161,7 +1167,9 @@ def update_tensorboard_experiment( def list_tensorboard_experiments( self, - request: tensorboard_service.ListTensorboardExperimentsRequest = None, + request: Union[ + tensorboard_service.ListTensorboardExperimentsRequest, dict + ] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1171,7 +1179,7 @@ def list_tensorboard_experiments( r"""Lists TensorboardExperiments in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListTensorboardExperimentsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListTensorboardExperimentsRequest, dict]): The request object. Request message for [TensorboardService.ListTensorboardExperiments][google.cloud.aiplatform.v1beta1.TensorboardService.ListTensorboardExperiments]. parent (str): @@ -1247,7 +1255,9 @@ def list_tensorboard_experiments( def delete_tensorboard_experiment( self, - request: tensorboard_service.DeleteTensorboardExperimentRequest = None, + request: Union[ + tensorboard_service.DeleteTensorboardExperimentRequest, dict + ] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1257,7 +1267,7 @@ def delete_tensorboard_experiment( r"""Deletes a TensorboardExperiment. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteTensorboardExperimentRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteTensorboardExperimentRequest, dict]): The request object. Request message for [TensorboardService.DeleteTensorboardExperiment][google.cloud.aiplatform.v1beta1.TensorboardService.DeleteTensorboardExperiment]. name (str): @@ -1344,7 +1354,7 @@ def delete_tensorboard_experiment( def create_tensorboard_run( self, - request: tensorboard_service.CreateTensorboardRunRequest = None, + request: Union[tensorboard_service.CreateTensorboardRunRequest, dict] = None, *, parent: str = None, tensorboard_run: gca_tensorboard_run.TensorboardRun = None, @@ -1356,7 +1366,7 @@ def create_tensorboard_run( r"""Creates a TensorboardRun. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateTensorboardRunRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateTensorboardRunRequest, dict]): The request object. Request message for [TensorboardService.CreateTensorboardRun][google.cloud.aiplatform.v1beta1.TensorboardService.CreateTensorboardRun]. parent (str): @@ -1442,7 +1452,9 @@ def create_tensorboard_run( def batch_create_tensorboard_runs( self, - request: tensorboard_service.BatchCreateTensorboardRunsRequest = None, + request: Union[ + tensorboard_service.BatchCreateTensorboardRunsRequest, dict + ] = None, *, parent: str = None, requests: Sequence[tensorboard_service.CreateTensorboardRunRequest] = None, @@ -1453,7 +1465,7 @@ def batch_create_tensorboard_runs( r"""Batch create TensorboardRuns. Args: - request (google.cloud.aiplatform_v1beta1.types.BatchCreateTensorboardRunsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.BatchCreateTensorboardRunsRequest, dict]): The request object. Request message for [TensorboardService.BatchCreateTensorboardRuns][google.cloud.aiplatform.v1beta1.TensorboardService.BatchCreateTensorboardRuns]. parent (str): @@ -1533,7 +1545,7 @@ def batch_create_tensorboard_runs( def get_tensorboard_run( self, - request: tensorboard_service.GetTensorboardRunRequest = None, + request: Union[tensorboard_service.GetTensorboardRunRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1543,7 +1555,7 @@ def get_tensorboard_run( r"""Gets a TensorboardRun. Args: - request (google.cloud.aiplatform_v1beta1.types.GetTensorboardRunRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetTensorboardRunRequest, dict]): The request object. Request message for [TensorboardService.GetTensorboardRun][google.cloud.aiplatform.v1beta1.TensorboardService.GetTensorboardRun]. name (str): @@ -1607,7 +1619,7 @@ def get_tensorboard_run( def update_tensorboard_run( self, - request: tensorboard_service.UpdateTensorboardRunRequest = None, + request: Union[tensorboard_service.UpdateTensorboardRunRequest, dict] = None, *, tensorboard_run: gca_tensorboard_run.TensorboardRun = None, update_mask: field_mask_pb2.FieldMask = None, @@ -1618,7 +1630,7 @@ def update_tensorboard_run( r"""Updates a TensorboardRun. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateTensorboardRunRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateTensorboardRunRequest, dict]): The request object. Request message for [TensorboardService.UpdateTensorboardRun][google.cloud.aiplatform.v1beta1.TensorboardService.UpdateTensorboardRun]. tensorboard_run (google.cloud.aiplatform_v1beta1.types.TensorboardRun): @@ -1698,7 +1710,7 @@ def update_tensorboard_run( def list_tensorboard_runs( self, - request: tensorboard_service.ListTensorboardRunsRequest = None, + request: Union[tensorboard_service.ListTensorboardRunsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1708,7 +1720,7 @@ def list_tensorboard_runs( r"""Lists TensorboardRuns in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListTensorboardRunsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListTensorboardRunsRequest, dict]): The request object. Request message for [TensorboardService.ListTensorboardRuns][google.cloud.aiplatform.v1beta1.TensorboardService.ListTensorboardRuns]. parent (str): @@ -1780,7 +1792,7 @@ def list_tensorboard_runs( def delete_tensorboard_run( self, - request: tensorboard_service.DeleteTensorboardRunRequest = None, + request: Union[tensorboard_service.DeleteTensorboardRunRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1790,7 +1802,7 @@ def delete_tensorboard_run( r"""Deletes a TensorboardRun. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteTensorboardRunRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteTensorboardRunRequest, dict]): The request object. Request message for [TensorboardService.DeleteTensorboardRun][google.cloud.aiplatform.v1beta1.TensorboardService.DeleteTensorboardRun]. name (str): @@ -1873,7 +1885,9 @@ def delete_tensorboard_run( def batch_create_tensorboard_time_series( self, - request: tensorboard_service.BatchCreateTensorboardTimeSeriesRequest = None, + request: Union[ + tensorboard_service.BatchCreateTensorboardTimeSeriesRequest, dict + ] = None, *, parent: str = None, requests: Sequence[ @@ -1887,7 +1901,7 @@ def batch_create_tensorboard_time_series( TensorboardExperiment. Args: - request (google.cloud.aiplatform_v1beta1.types.BatchCreateTensorboardTimeSeriesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.BatchCreateTensorboardTimeSeriesRequest, dict]): The request object. Request message for [TensorboardService.BatchCreateTensorboardTimeSeries][google.cloud.aiplatform.v1beta1.TensorboardService.BatchCreateTensorboardTimeSeries]. parent (str): @@ -1970,7 +1984,9 @@ def batch_create_tensorboard_time_series( def create_tensorboard_time_series( self, - request: tensorboard_service.CreateTensorboardTimeSeriesRequest = None, + request: Union[ + tensorboard_service.CreateTensorboardTimeSeriesRequest, dict + ] = None, *, parent: str = None, tensorboard_time_series: gca_tensorboard_time_series.TensorboardTimeSeries = None, @@ -1981,7 +1997,7 @@ def create_tensorboard_time_series( r"""Creates a TensorboardTimeSeries. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateTensorboardTimeSeriesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateTensorboardTimeSeriesRequest, dict]): The request object. Request message for [TensorboardService.CreateTensorboardTimeSeries][google.cloud.aiplatform.v1beta1.TensorboardService.CreateTensorboardTimeSeries]. parent (str): @@ -2056,7 +2072,9 @@ def create_tensorboard_time_series( def get_tensorboard_time_series( self, - request: tensorboard_service.GetTensorboardTimeSeriesRequest = None, + request: Union[ + tensorboard_service.GetTensorboardTimeSeriesRequest, dict + ] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2066,7 +2084,7 @@ def get_tensorboard_time_series( r"""Gets a TensorboardTimeSeries. Args: - request (google.cloud.aiplatform_v1beta1.types.GetTensorboardTimeSeriesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetTensorboardTimeSeriesRequest, dict]): The request object. Request message for [TensorboardService.GetTensorboardTimeSeries][google.cloud.aiplatform.v1beta1.TensorboardService.GetTensorboardTimeSeries]. name (str): @@ -2130,7 +2148,9 @@ def get_tensorboard_time_series( def update_tensorboard_time_series( self, - request: tensorboard_service.UpdateTensorboardTimeSeriesRequest = None, + request: Union[ + tensorboard_service.UpdateTensorboardTimeSeriesRequest, dict + ] = None, *, tensorboard_time_series: gca_tensorboard_time_series.TensorboardTimeSeries = None, update_mask: field_mask_pb2.FieldMask = None, @@ -2141,7 +2161,7 @@ def update_tensorboard_time_series( r"""Updates a TensorboardTimeSeries. Args: - request (google.cloud.aiplatform_v1beta1.types.UpdateTensorboardTimeSeriesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateTensorboardTimeSeriesRequest, dict]): The request object. Request message for [TensorboardService.UpdateTensorboardTimeSeries][google.cloud.aiplatform.v1beta1.TensorboardService.UpdateTensorboardTimeSeries]. tensorboard_time_series (google.cloud.aiplatform_v1beta1.types.TensorboardTimeSeries): @@ -2229,7 +2249,9 @@ def update_tensorboard_time_series( def list_tensorboard_time_series( self, - request: tensorboard_service.ListTensorboardTimeSeriesRequest = None, + request: Union[ + tensorboard_service.ListTensorboardTimeSeriesRequest, dict + ] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2239,7 +2261,7 @@ def list_tensorboard_time_series( r"""Lists TensorboardTimeSeries in a Location. Args: - request (google.cloud.aiplatform_v1beta1.types.ListTensorboardTimeSeriesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListTensorboardTimeSeriesRequest, dict]): The request object. Request message for [TensorboardService.ListTensorboardTimeSeries][google.cloud.aiplatform.v1beta1.TensorboardService.ListTensorboardTimeSeries]. parent (str): @@ -2315,7 +2337,9 @@ def list_tensorboard_time_series( def delete_tensorboard_time_series( self, - request: tensorboard_service.DeleteTensorboardTimeSeriesRequest = None, + request: Union[ + tensorboard_service.DeleteTensorboardTimeSeriesRequest, dict + ] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2325,7 +2349,7 @@ def delete_tensorboard_time_series( r"""Deletes a TensorboardTimeSeries. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteTensorboardTimeSeriesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteTensorboardTimeSeriesRequest, dict]): The request object. Request message for [TensorboardService.DeleteTensorboardTimeSeries][google.cloud.aiplatform.v1beta1.TensorboardService.DeleteTensorboardTimeSeries]. name (str): @@ -2412,7 +2436,9 @@ def delete_tensorboard_time_series( def read_tensorboard_time_series_data( self, - request: tensorboard_service.ReadTensorboardTimeSeriesDataRequest = None, + request: Union[ + tensorboard_service.ReadTensorboardTimeSeriesDataRequest, dict + ] = None, *, tensorboard_time_series: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2427,7 +2453,7 @@ def read_tensorboard_time_series_data( max_data_points. Args: - request (google.cloud.aiplatform_v1beta1.types.ReadTensorboardTimeSeriesDataRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ReadTensorboardTimeSeriesDataRequest, dict]): The request object. Request message for [TensorboardService.ReadTensorboardTimeSeriesData][google.cloud.aiplatform.v1beta1.TensorboardService.ReadTensorboardTimeSeriesData]. tensorboard_time_series (str): @@ -2495,7 +2521,7 @@ def read_tensorboard_time_series_data( def read_tensorboard_blob_data( self, - request: tensorboard_service.ReadTensorboardBlobDataRequest = None, + request: Union[tensorboard_service.ReadTensorboardBlobDataRequest, dict] = None, *, time_series: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2508,7 +2534,7 @@ def read_tensorboard_blob_data( obtain Cloud Storage access permission. Args: - request (google.cloud.aiplatform_v1beta1.types.ReadTensorboardBlobDataRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ReadTensorboardBlobDataRequest, dict]): The request object. Request message for [TensorboardService.ReadTensorboardBlobData][google.cloud.aiplatform.v1beta1.TensorboardService.ReadTensorboardBlobData]. time_series (str): @@ -2574,7 +2600,9 @@ def read_tensorboard_blob_data( def write_tensorboard_experiment_data( self, - request: tensorboard_service.WriteTensorboardExperimentDataRequest = None, + request: Union[ + tensorboard_service.WriteTensorboardExperimentDataRequest, dict + ] = None, *, tensorboard_experiment: str = None, write_run_data_requests: Sequence[ @@ -2589,7 +2617,7 @@ def write_tensorboard_experiment_data( any data fail to be ingested, an error will be returned. Args: - request (google.cloud.aiplatform_v1beta1.types.WriteTensorboardExperimentDataRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.WriteTensorboardExperimentDataRequest, dict]): The request object. Request message for [TensorboardService.WriteTensorboardExperimentData][google.cloud.aiplatform.v1beta1.TensorboardService.WriteTensorboardExperimentData]. tensorboard_experiment (str): @@ -2666,7 +2694,7 @@ def write_tensorboard_experiment_data( def write_tensorboard_run_data( self, - request: tensorboard_service.WriteTensorboardRunDataRequest = None, + request: Union[tensorboard_service.WriteTensorboardRunDataRequest, dict] = None, *, tensorboard_run: str = None, time_series_data: Sequence[tensorboard_data.TimeSeriesData] = None, @@ -2679,7 +2707,7 @@ def write_tensorboard_run_data( data fail to be ingested, an error will be returned. Args: - request (google.cloud.aiplatform_v1beta1.types.WriteTensorboardRunDataRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.WriteTensorboardRunDataRequest, dict]): The request object. Request message for [TensorboardService.WriteTensorboardRunData][google.cloud.aiplatform.v1beta1.TensorboardService.WriteTensorboardRunData]. tensorboard_run (str): @@ -2760,7 +2788,9 @@ def write_tensorboard_run_data( def export_tensorboard_time_series_data( self, - request: tensorboard_service.ExportTensorboardTimeSeriesDataRequest = None, + request: Union[ + tensorboard_service.ExportTensorboardTimeSeriesDataRequest, dict + ] = None, *, tensorboard_time_series: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -2771,7 +2801,7 @@ def export_tensorboard_time_series_data( returned in paginated responses. Args: - request (google.cloud.aiplatform_v1beta1.types.ExportTensorboardTimeSeriesDataRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ExportTensorboardTimeSeriesDataRequest, dict]): The request object. Request message for [TensorboardService.ExportTensorboardTimeSeriesData][google.cloud.aiplatform.v1beta1.TensorboardService.ExportTensorboardTimeSeriesData]. tensorboard_time_series (str): diff --git a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/base.py index 467bfa48fb..272883ce3d 100644 --- a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/base.py @@ -130,7 +130,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc.py index 4e65055f47..7f3efcbd11 100644 --- a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc.py @@ -93,16 +93,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc_asyncio.py index 3a16d00295..2301fe955f 100644 --- a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc_asyncio.py @@ -140,16 +140,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/vizier_service/client.py b/google/cloud/aiplatform_v1beta1/services/vizier_service/client.py index 5b458087a6..9b1a1e5875 100644 --- a/google/cloud/aiplatform_v1beta1/services/vizier_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/vizier_service/client.py @@ -17,7 +17,7 @@ from distutils import util import os import re -from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore @@ -391,7 +391,7 @@ def __init__( def create_study( self, - request: vizier_service.CreateStudyRequest = None, + request: Union[vizier_service.CreateStudyRequest, dict] = None, *, parent: str = None, study: gca_study.Study = None, @@ -403,7 +403,7 @@ def create_study( after creation of the Study. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateStudyRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateStudyRequest, dict]): The request object. Request message for [VizierService.CreateStudy][google.cloud.aiplatform.v1beta1.VizierService.CreateStudy]. parent (str): @@ -472,7 +472,7 @@ def create_study( def get_study( self, - request: vizier_service.GetStudyRequest = None, + request: Union[vizier_service.GetStudyRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -482,7 +482,7 @@ def get_study( r"""Gets a Study by name. Args: - request (google.cloud.aiplatform_v1beta1.types.GetStudyRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetStudyRequest, dict]): The request object. Request message for [VizierService.GetStudy][google.cloud.aiplatform.v1beta1.VizierService.GetStudy]. name (str): @@ -541,7 +541,7 @@ def get_study( def list_studies( self, - request: vizier_service.ListStudiesRequest = None, + request: Union[vizier_service.ListStudiesRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -552,7 +552,7 @@ def list_studies( project. Args: - request (google.cloud.aiplatform_v1beta1.types.ListStudiesRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListStudiesRequest, dict]): The request object. Request message for [VizierService.ListStudies][google.cloud.aiplatform.v1beta1.VizierService.ListStudies]. parent (str): @@ -623,7 +623,7 @@ def list_studies( def delete_study( self, - request: vizier_service.DeleteStudyRequest = None, + request: Union[vizier_service.DeleteStudyRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -633,7 +633,7 @@ def delete_study( r"""Deletes a Study. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteStudyRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteStudyRequest, dict]): The request object. Request message for [VizierService.DeleteStudy][google.cloud.aiplatform.v1beta1.VizierService.DeleteStudy]. name (str): @@ -688,7 +688,7 @@ def delete_study( def lookup_study( self, - request: vizier_service.LookupStudyRequest = None, + request: Union[vizier_service.LookupStudyRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -699,7 +699,7 @@ def lookup_study( instead of the fully qualified resource name. Args: - request (google.cloud.aiplatform_v1beta1.types.LookupStudyRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.LookupStudyRequest, dict]): The request object. Request message for [VizierService.LookupStudy][google.cloud.aiplatform.v1beta1.VizierService.LookupStudy]. parent (str): @@ -759,7 +759,7 @@ def lookup_study( def suggest_trials( self, - request: vizier_service.SuggestTrialsRequest = None, + request: Union[vizier_service.SuggestTrialsRequest, dict] = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, @@ -772,7 +772,7 @@ def suggest_trials( [SuggestTrialsResponse][google.cloud.ml.v1.SuggestTrialsResponse]. Args: - request (google.cloud.aiplatform_v1beta1.types.SuggestTrialsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.SuggestTrialsRequest, dict]): The request object. Request message for [VizierService.SuggestTrials][google.cloud.aiplatform.v1beta1.VizierService.SuggestTrials]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -825,7 +825,7 @@ def suggest_trials( def create_trial( self, - request: vizier_service.CreateTrialRequest = None, + request: Union[vizier_service.CreateTrialRequest, dict] = None, *, parent: str = None, trial: study.Trial = None, @@ -836,7 +836,7 @@ def create_trial( r"""Adds a user provided Trial to a Study. Args: - request (google.cloud.aiplatform_v1beta1.types.CreateTrialRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CreateTrialRequest, dict]): The request object. Request message for [VizierService.CreateTrial][google.cloud.aiplatform.v1beta1.VizierService.CreateTrial]. parent (str): @@ -908,7 +908,7 @@ def create_trial( def get_trial( self, - request: vizier_service.GetTrialRequest = None, + request: Union[vizier_service.GetTrialRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -918,7 +918,7 @@ def get_trial( r"""Gets a Trial. Args: - request (google.cloud.aiplatform_v1beta1.types.GetTrialRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.GetTrialRequest, dict]): The request object. Request message for [VizierService.GetTrial][google.cloud.aiplatform.v1beta1.VizierService.GetTrial]. name (str): @@ -982,7 +982,7 @@ def get_trial( def list_trials( self, - request: vizier_service.ListTrialsRequest = None, + request: Union[vizier_service.ListTrialsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -992,7 +992,7 @@ def list_trials( r"""Lists the Trials associated with a Study. Args: - request (google.cloud.aiplatform_v1beta1.types.ListTrialsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListTrialsRequest, dict]): The request object. Request message for [VizierService.ListTrials][google.cloud.aiplatform.v1beta1.VizierService.ListTrials]. parent (str): @@ -1063,7 +1063,7 @@ def list_trials( def add_trial_measurement( self, - request: vizier_service.AddTrialMeasurementRequest = None, + request: Union[vizier_service.AddTrialMeasurementRequest, dict] = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, @@ -1074,7 +1074,7 @@ def add_trial_measurement( before the Trial is complete. Args: - request (google.cloud.aiplatform_v1beta1.types.AddTrialMeasurementRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.AddTrialMeasurementRequest, dict]): The request object. Request message for [VizierService.AddTrialMeasurement][google.cloud.aiplatform.v1beta1.VizierService.AddTrialMeasurement]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1120,7 +1120,7 @@ def add_trial_measurement( def complete_trial( self, - request: vizier_service.CompleteTrialRequest = None, + request: Union[vizier_service.CompleteTrialRequest, dict] = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, @@ -1129,7 +1129,7 @@ def complete_trial( r"""Marks a Trial as complete. Args: - request (google.cloud.aiplatform_v1beta1.types.CompleteTrialRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CompleteTrialRequest, dict]): The request object. Request message for [VizierService.CompleteTrial][google.cloud.aiplatform.v1beta1.VizierService.CompleteTrial]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1173,7 +1173,7 @@ def complete_trial( def delete_trial( self, - request: vizier_service.DeleteTrialRequest = None, + request: Union[vizier_service.DeleteTrialRequest, dict] = None, *, name: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1183,7 +1183,7 @@ def delete_trial( r"""Deletes a Trial. Args: - request (google.cloud.aiplatform_v1beta1.types.DeleteTrialRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.DeleteTrialRequest, dict]): The request object. Request message for [VizierService.DeleteTrial][google.cloud.aiplatform.v1beta1.VizierService.DeleteTrial]. name (str): @@ -1237,7 +1237,7 @@ def delete_trial( def check_trial_early_stopping_state( self, - request: vizier_service.CheckTrialEarlyStoppingStateRequest = None, + request: Union[vizier_service.CheckTrialEarlyStoppingStateRequest, dict] = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, @@ -1249,7 +1249,7 @@ def check_trial_early_stopping_state( [CheckTrialEarlyStoppingStateResponse][google.cloud.ml.v1.CheckTrialEarlyStoppingStateResponse]. Args: - request (google.cloud.aiplatform_v1beta1.types.CheckTrialEarlyStoppingStateRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.CheckTrialEarlyStoppingStateRequest, dict]): The request object. Request message for [VizierService.CheckTrialEarlyStoppingState][google.cloud.aiplatform.v1beta1.VizierService.CheckTrialEarlyStoppingState]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1306,7 +1306,7 @@ def check_trial_early_stopping_state( def stop_trial( self, - request: vizier_service.StopTrialRequest = None, + request: Union[vizier_service.StopTrialRequest, dict] = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, @@ -1315,7 +1315,7 @@ def stop_trial( r"""Stops a Trial. Args: - request (google.cloud.aiplatform_v1beta1.types.StopTrialRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.StopTrialRequest, dict]): The request object. Request message for [VizierService.StopTrial][google.cloud.aiplatform.v1beta1.VizierService.StopTrial]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1359,7 +1359,7 @@ def stop_trial( def list_optimal_trials( self, - request: vizier_service.ListOptimalTrialsRequest = None, + request: Union[vizier_service.ListOptimalTrialsRequest, dict] = None, *, parent: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, @@ -1372,7 +1372,7 @@ def list_optimal_trials( https://en.wikipedia.org/wiki/Pareto_efficiency Args: - request (google.cloud.aiplatform_v1beta1.types.ListOptimalTrialsRequest): + request (Union[google.cloud.aiplatform_v1beta1.types.ListOptimalTrialsRequest, dict]): The request object. Request message for [VizierService.ListOptimalTrials][google.cloud.aiplatform.v1beta1.VizierService.ListOptimalTrials]. parent (str): diff --git a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/base.py index 144c60512c..7e1103ce59 100644 --- a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/base.py @@ -122,7 +122,7 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) - # If the credentials is service account credentials, then always try to use self signed JWT. + # If the credentials are service account credentials, then always try to use self signed JWT. if ( always_use_jwt_access and isinstance(credentials, service_account.Credentials) diff --git a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc.py index 67056b4cc4..baa7418cf1 100644 --- a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc.py @@ -88,16 +88,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc_asyncio.py index 63bfc701a5..98bc6fd859 100644 --- a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc_asyncio.py @@ -135,16 +135,16 @@ def __init__( api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. If provided, it overrides the ``host`` argument and tries to create a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or applicatin default SSL credentials. + ``client_cert_source`` or application default SSL credentials. client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): Deprecated. A callback to provide client SSL certificate bytes and private key bytes, both in PEM format. It is ignored if ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for grpc channel. It is ignored if ``channel`` is provided. + for the grpc channel. It is ignored if ``channel`` is provided. client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure mutual TLS channel. It is + both in PEM format. It is used to configure a mutual TLS channel. It is ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. diff --git a/schema/predict/instance/docs/conf.py b/schema/predict/instance/docs/conf.py index 670c3a5192..a12fb006b9 100644 --- a/schema/predict/instance/docs/conf.py +++ b/schema/predict/instance/docs/conf.py @@ -74,8 +74,8 @@ # The encoding of source files. # source_encoding = 'utf-8-sig' -# The root toctree document. -root_doc = "index" +# The master toctree document. +master_doc = "index" # General information about the project. project = u"google-cloud-aiplatform-v1-schema-predict-instance" @@ -272,7 +272,7 @@ # author, documentclass [howto, manual, or own class]). latex_documents = [ ( - root_doc, + master_doc, "google-cloud-aiplatform-v1-schema-predict-instance.tex", u"google-cloud-aiplatform-v1-schema-predict-instance Documentation", author, @@ -307,7 +307,7 @@ # (source start file, name, description, authors, manual section). man_pages = [ ( - root_doc, + master_doc, "google-cloud-aiplatform-v1-schema-predict-instance", u"Google Cloud Aiplatform V1 Schema Predict Instance Documentation", [author], @@ -326,7 +326,7 @@ # dir menu entry, description, category) texinfo_documents = [ ( - root_doc, + master_doc, "google-cloud-aiplatform-v1-schema-predict-instance", u"google-cloud-aiplatform-v1-schema-predict-instance Documentation", author, diff --git a/schema/predict/instance/scripts/fixup_instance_v1_keywords.py b/schema/predict/instance/scripts/fixup_instance_v1_keywords.py index d9e8bd0b17..52fe576948 100644 --- a/schema/predict/instance/scripts/fixup_instance_v1_keywords.py +++ b/schema/predict/instance/scripts/fixup_instance_v1_keywords.py @@ -57,7 +57,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: return updated kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, + lambda a: a.keyword.value not in self.CTRL_PARAMS, kwargs ) diff --git a/schema/predict/instance/scripts/fixup_instance_v1beta1_keywords.py b/schema/predict/instance/scripts/fixup_instance_v1beta1_keywords.py index d9e8bd0b17..52fe576948 100644 --- a/schema/predict/instance/scripts/fixup_instance_v1beta1_keywords.py +++ b/schema/predict/instance/scripts/fixup_instance_v1beta1_keywords.py @@ -57,7 +57,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: return updated kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, + lambda a: a.keyword.value not in self.CTRL_PARAMS, kwargs ) diff --git a/schema/predict/params/docs/conf.py b/schema/predict/params/docs/conf.py index 7b4605df71..6917071403 100644 --- a/schema/predict/params/docs/conf.py +++ b/schema/predict/params/docs/conf.py @@ -74,8 +74,8 @@ # The encoding of source files. # source_encoding = 'utf-8-sig' -# The root toctree document. -root_doc = "index" +# The master toctree document. +master_doc = "index" # General information about the project. project = u"google-cloud-aiplatform-v1-schema-predict-params" @@ -272,7 +272,7 @@ # author, documentclass [howto, manual, or own class]). latex_documents = [ ( - root_doc, + master_doc, "google-cloud-aiplatform-v1-schema-predict-params.tex", u"google-cloud-aiplatform-v1-schema-predict-params Documentation", author, @@ -307,7 +307,7 @@ # (source start file, name, description, authors, manual section). man_pages = [ ( - root_doc, + master_doc, "google-cloud-aiplatform-v1-schema-predict-params", u"Google Cloud Aiplatform V1 Schema Predict Params Documentation", [author], @@ -326,7 +326,7 @@ # dir menu entry, description, category) texinfo_documents = [ ( - root_doc, + master_doc, "google-cloud-aiplatform-v1-schema-predict-params", u"google-cloud-aiplatform-v1-schema-predict-params Documentation", author, diff --git a/schema/predict/params/scripts/fixup_params_v1_keywords.py b/schema/predict/params/scripts/fixup_params_v1_keywords.py index 17915abed8..6331faf507 100644 --- a/schema/predict/params/scripts/fixup_params_v1_keywords.py +++ b/schema/predict/params/scripts/fixup_params_v1_keywords.py @@ -57,7 +57,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: return updated kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, + lambda a: a.keyword.value not in self.CTRL_PARAMS, kwargs ) diff --git a/schema/predict/params/scripts/fixup_params_v1beta1_keywords.py b/schema/predict/params/scripts/fixup_params_v1beta1_keywords.py index 17915abed8..6331faf507 100644 --- a/schema/predict/params/scripts/fixup_params_v1beta1_keywords.py +++ b/schema/predict/params/scripts/fixup_params_v1beta1_keywords.py @@ -57,7 +57,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: return updated kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, + lambda a: a.keyword.value not in self.CTRL_PARAMS, kwargs ) diff --git a/schema/predict/prediction/docs/conf.py b/schema/predict/prediction/docs/conf.py index 43b935efb4..c0f73900a9 100644 --- a/schema/predict/prediction/docs/conf.py +++ b/schema/predict/prediction/docs/conf.py @@ -74,8 +74,8 @@ # The encoding of source files. # source_encoding = 'utf-8-sig' -# The root toctree document. -root_doc = "index" +# The master toctree document. +master_doc = "index" # General information about the project. project = u"google-cloud-aiplatform-v1-schema-predict-prediction" @@ -272,7 +272,7 @@ # author, documentclass [howto, manual, or own class]). latex_documents = [ ( - root_doc, + master_doc, "google-cloud-aiplatform-v1-schema-predict-prediction.tex", u"google-cloud-aiplatform-v1-schema-predict-prediction Documentation", author, @@ -307,7 +307,7 @@ # (source start file, name, description, authors, manual section). man_pages = [ ( - root_doc, + master_doc, "google-cloud-aiplatform-v1-schema-predict-prediction", u"Google Cloud Aiplatform V1 Schema Predict Prediction Documentation", [author], @@ -326,7 +326,7 @@ # dir menu entry, description, category) texinfo_documents = [ ( - root_doc, + master_doc, "google-cloud-aiplatform-v1-schema-predict-prediction", u"google-cloud-aiplatform-v1-schema-predict-prediction Documentation", author, diff --git a/schema/predict/prediction/scripts/fixup_prediction_v1_keywords.py b/schema/predict/prediction/scripts/fixup_prediction_v1_keywords.py index 7860bb63cf..df2a884371 100644 --- a/schema/predict/prediction/scripts/fixup_prediction_v1_keywords.py +++ b/schema/predict/prediction/scripts/fixup_prediction_v1_keywords.py @@ -57,7 +57,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: return updated kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, + lambda a: a.keyword.value not in self.CTRL_PARAMS, kwargs ) diff --git a/schema/predict/prediction/scripts/fixup_prediction_v1beta1_keywords.py b/schema/predict/prediction/scripts/fixup_prediction_v1beta1_keywords.py index 7860bb63cf..df2a884371 100644 --- a/schema/predict/prediction/scripts/fixup_prediction_v1beta1_keywords.py +++ b/schema/predict/prediction/scripts/fixup_prediction_v1beta1_keywords.py @@ -57,7 +57,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: return updated kwargs, ctrl_kwargs = partition( - lambda a: not a.keyword.value in self.CTRL_PARAMS, + lambda a: a.keyword.value not in self.CTRL_PARAMS, kwargs ) diff --git a/tests/unit/gapic/aiplatform_v1/test_vizier_service.py b/tests/unit/gapic/aiplatform_v1/test_vizier_service.py new file mode 100644 index 0000000000..0e52df7838 --- /dev/null +++ b/tests/unit/gapic/aiplatform_v1/test_vizier_service.py @@ -0,0 +1,4291 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +import mock +import packaging.version + +import grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import future +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import operation_async # type: ignore +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.aiplatform_v1.services.vizier_service import VizierServiceAsyncClient +from google.cloud.aiplatform_v1.services.vizier_service import VizierServiceClient +from google.cloud.aiplatform_v1.services.vizier_service import pagers +from google.cloud.aiplatform_v1.services.vizier_service import transports +from google.cloud.aiplatform_v1.services.vizier_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) +from google.cloud.aiplatform_v1.types import study +from google.cloud.aiplatform_v1.types import study as gca_study +from google.cloud.aiplatform_v1.types import vizier_service +from google.longrunning import operations_pb2 +from google.oauth2 import service_account +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively +# through google-api-core: +# - Delete the auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return ( + "foo.googleapis.com" + if ("localhost" in client.DEFAULT_ENDPOINT) + else client.DEFAULT_ENDPOINT + ) + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert VizierServiceClient._get_default_mtls_endpoint(None) is None + assert ( + VizierServiceClient._get_default_mtls_endpoint(api_endpoint) + == api_mtls_endpoint + ) + assert ( + VizierServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) + == api_mtls_endpoint + ) + assert ( + VizierServiceClient._get_default_mtls_endpoint(sandbox_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + VizierServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + VizierServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + ) + + +@pytest.mark.parametrize( + "client_class", [VizierServiceClient, VizierServiceAsyncClient,] +) +def test_vizier_service_client_from_service_account_info(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == "aiplatform.googleapis.com:443" + + +@pytest.mark.parametrize( + "transport_class,transport_name", + [ + (transports.VizierServiceGrpcTransport, "grpc"), + (transports.VizierServiceGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_vizier_service_client_service_account_always_use_jwt( + transport_class, transport_name +): + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=True) + use_jwt.assert_called_once_with(True) + + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + + +@pytest.mark.parametrize( + "client_class", [VizierServiceClient, VizierServiceAsyncClient,] +) +def test_vizier_service_client_from_service_account_file(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_file" + ) as factory: + factory.return_value = creds + client = client_class.from_service_account_file("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == "aiplatform.googleapis.com:443" + + +def test_vizier_service_client_get_transport_class(): + transport = VizierServiceClient.get_transport_class() + available_transports = [ + transports.VizierServiceGrpcTransport, + ] + assert transport in available_transports + + transport = VizierServiceClient.get_transport_class("grpc") + assert transport == transports.VizierServiceGrpcTransport + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (VizierServiceClient, transports.VizierServiceGrpcTransport, "grpc"), + ( + VizierServiceAsyncClient, + transports.VizierServiceGrpcAsyncIOTransport, + "grpc_asyncio", + ), + ], +) +@mock.patch.object( + VizierServiceClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(VizierServiceClient), +) +@mock.patch.object( + VizierServiceAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(VizierServiceAsyncClient), +) +def test_vizier_service_client_client_options( + client_class, transport_class, transport_name +): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(VizierServiceClient, "get_transport_class") as gtc: + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(VizierServiceClient, "get_transport_class") as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class() + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} + ): + with pytest.raises(ValueError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,use_client_cert_env", + [ + (VizierServiceClient, transports.VizierServiceGrpcTransport, "grpc", "true"), + ( + VizierServiceAsyncClient, + transports.VizierServiceGrpcAsyncIOTransport, + "grpc_asyncio", + "true", + ), + (VizierServiceClient, transports.VizierServiceGrpcTransport, "grpc", "false"), + ( + VizierServiceAsyncClient, + transports.VizierServiceGrpcAsyncIOTransport, + "grpc_asyncio", + "false", + ), + ], +) +@mock.patch.object( + VizierServiceClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(VizierServiceClient), +) +@mock.patch.object( + VizierServiceAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(VizierServiceAsyncClient), +) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_vizier_service_client_mtls_env_auto( + client_class, transport_class, transport_name, use_client_cert_env +): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + options = client_options.ClientOptions( + client_cert_source=client_cert_source_callback + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=client_cert_source_callback, + ): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (VizierServiceClient, transports.VizierServiceGrpcTransport, "grpc"), + ( + VizierServiceAsyncClient, + transports.VizierServiceGrpcAsyncIOTransport, + "grpc_asyncio", + ), + ], +) +def test_vizier_service_client_client_options_scopes( + client_class, transport_class, transport_name +): + # Check the case scopes are provided. + options = client_options.ClientOptions(scopes=["1", "2"],) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (VizierServiceClient, transports.VizierServiceGrpcTransport, "grpc"), + ( + VizierServiceAsyncClient, + transports.VizierServiceGrpcAsyncIOTransport, + "grpc_asyncio", + ), + ], +) +def test_vizier_service_client_client_options_credentials_file( + client_class, transport_class, transport_name +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + +def test_vizier_service_client_client_options_from_dict(): + with mock.patch( + "google.cloud.aiplatform_v1.services.vizier_service.transports.VizierServiceGrpcTransport.__init__" + ) as grpc_transport: + grpc_transport.return_value = None + client = VizierServiceClient( + client_options={"api_endpoint": "squid.clam.whelk"} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + +def test_create_study( + transport: str = "grpc", request_type=vizier_service.CreateStudyRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = gca_study.Study( + name="name_value", + display_name="display_name_value", + state=gca_study.Study.State.ACTIVE, + inactive_reason="inactive_reason_value", + ) + response = client.create_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.CreateStudyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gca_study.Study) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.state == gca_study.Study.State.ACTIVE + assert response.inactive_reason == "inactive_reason_value" + + +def test_create_study_from_dict(): + test_create_study(request_type=dict) + + +def test_create_study_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_study), "__call__") as call: + client.create_study() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.CreateStudyRequest() + + +@pytest.mark.asyncio +async def test_create_study_async( + transport: str = "grpc_asyncio", request_type=vizier_service.CreateStudyRequest +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + gca_study.Study( + name="name_value", + display_name="display_name_value", + state=gca_study.Study.State.ACTIVE, + inactive_reason="inactive_reason_value", + ) + ) + response = await client.create_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.CreateStudyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, gca_study.Study) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.state == gca_study.Study.State.ACTIVE + assert response.inactive_reason == "inactive_reason_value" + + +@pytest.mark.asyncio +async def test_create_study_async_from_dict(): + await test_create_study_async(request_type=dict) + + +def test_create_study_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.CreateStudyRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_study), "__call__") as call: + call.return_value = gca_study.Study() + client.create_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_study_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.CreateStudyRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_study), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gca_study.Study()) + await client.create_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_create_study_flattened(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = gca_study.Study() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_study( + parent="parent_value", study=gca_study.Study(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[0].study == gca_study.Study(name="name_value") + + +def test_create_study_flattened_error(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_study( + vizier_service.CreateStudyRequest(), + parent="parent_value", + study=gca_study.Study(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_study_flattened_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = gca_study.Study() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gca_study.Study()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_study( + parent="parent_value", study=gca_study.Study(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[0].study == gca_study.Study(name="name_value") + + +@pytest.mark.asyncio +async def test_create_study_flattened_error_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_study( + vizier_service.CreateStudyRequest(), + parent="parent_value", + study=gca_study.Study(name="name_value"), + ) + + +def test_get_study( + transport: str = "grpc", request_type=vizier_service.GetStudyRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Study( + name="name_value", + display_name="display_name_value", + state=study.Study.State.ACTIVE, + inactive_reason="inactive_reason_value", + ) + response = client.get_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.GetStudyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Study) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.state == study.Study.State.ACTIVE + assert response.inactive_reason == "inactive_reason_value" + + +def test_get_study_from_dict(): + test_get_study(request_type=dict) + + +def test_get_study_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_study), "__call__") as call: + client.get_study() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.GetStudyRequest() + + +@pytest.mark.asyncio +async def test_get_study_async( + transport: str = "grpc_asyncio", request_type=vizier_service.GetStudyRequest +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + study.Study( + name="name_value", + display_name="display_name_value", + state=study.Study.State.ACTIVE, + inactive_reason="inactive_reason_value", + ) + ) + response = await client.get_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.GetStudyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Study) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.state == study.Study.State.ACTIVE + assert response.inactive_reason == "inactive_reason_value" + + +@pytest.mark.asyncio +async def test_get_study_async_from_dict(): + await test_get_study_async(request_type=dict) + + +def test_get_study_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.GetStudyRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_study), "__call__") as call: + call.return_value = study.Study() + client.get_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_study_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.GetStudyRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_study), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Study()) + await client.get_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_study_flattened(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Study() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_study(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_get_study_flattened_error(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_study( + vizier_service.GetStudyRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_study_flattened_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Study() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Study()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_study(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_study_flattened_error_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_study( + vizier_service.GetStudyRequest(), name="name_value", + ) + + +def test_list_studies( + transport: str = "grpc", request_type=vizier_service.ListStudiesRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_studies), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = vizier_service.ListStudiesResponse( + next_page_token="next_page_token_value", + ) + response = client.list_studies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.ListStudiesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListStudiesPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_studies_from_dict(): + test_list_studies(request_type=dict) + + +def test_list_studies_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_studies), "__call__") as call: + client.list_studies() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.ListStudiesRequest() + + +@pytest.mark.asyncio +async def test_list_studies_async( + transport: str = "grpc_asyncio", request_type=vizier_service.ListStudiesRequest +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_studies), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + vizier_service.ListStudiesResponse(next_page_token="next_page_token_value",) + ) + response = await client.list_studies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.ListStudiesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListStudiesAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_studies_async_from_dict(): + await test_list_studies_async(request_type=dict) + + +def test_list_studies_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.ListStudiesRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_studies), "__call__") as call: + call.return_value = vizier_service.ListStudiesResponse() + client.list_studies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_studies_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.ListStudiesRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_studies), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + vizier_service.ListStudiesResponse() + ) + await client.list_studies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_studies_flattened(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_studies), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = vizier_service.ListStudiesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_studies(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +def test_list_studies_flattened_error(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_studies( + vizier_service.ListStudiesRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_studies_flattened_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_studies), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = vizier_service.ListStudiesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + vizier_service.ListStudiesResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_studies(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_studies_flattened_error_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_studies( + vizier_service.ListStudiesRequest(), parent="parent_value", + ) + + +def test_list_studies_pager(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_studies), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + vizier_service.ListStudiesResponse( + studies=[study.Study(), study.Study(), study.Study(),], + next_page_token="abc", + ), + vizier_service.ListStudiesResponse(studies=[], next_page_token="def",), + vizier_service.ListStudiesResponse( + studies=[study.Study(),], next_page_token="ghi", + ), + vizier_service.ListStudiesResponse( + studies=[study.Study(), study.Study(),], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_studies(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, study.Study) for i in results) + + +def test_list_studies_pages(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_studies), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + vizier_service.ListStudiesResponse( + studies=[study.Study(), study.Study(), study.Study(),], + next_page_token="abc", + ), + vizier_service.ListStudiesResponse(studies=[], next_page_token="def",), + vizier_service.ListStudiesResponse( + studies=[study.Study(),], next_page_token="ghi", + ), + vizier_service.ListStudiesResponse( + studies=[study.Study(), study.Study(),], + ), + RuntimeError, + ) + pages = list(client.list_studies(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_studies_async_pager(): + client = VizierServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_studies), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + vizier_service.ListStudiesResponse( + studies=[study.Study(), study.Study(), study.Study(),], + next_page_token="abc", + ), + vizier_service.ListStudiesResponse(studies=[], next_page_token="def",), + vizier_service.ListStudiesResponse( + studies=[study.Study(),], next_page_token="ghi", + ), + vizier_service.ListStudiesResponse( + studies=[study.Study(), study.Study(),], + ), + RuntimeError, + ) + async_pager = await client.list_studies(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, study.Study) for i in responses) + + +@pytest.mark.asyncio +async def test_list_studies_async_pages(): + client = VizierServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_studies), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + vizier_service.ListStudiesResponse( + studies=[study.Study(), study.Study(), study.Study(),], + next_page_token="abc", + ), + vizier_service.ListStudiesResponse(studies=[], next_page_token="def",), + vizier_service.ListStudiesResponse( + studies=[study.Study(),], next_page_token="ghi", + ), + vizier_service.ListStudiesResponse( + studies=[study.Study(), study.Study(),], + ), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_studies(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_delete_study( + transport: str = "grpc", request_type=vizier_service.DeleteStudyRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.DeleteStudyRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_study_from_dict(): + test_delete_study(request_type=dict) + + +def test_delete_study_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_study), "__call__") as call: + client.delete_study() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.DeleteStudyRequest() + + +@pytest.mark.asyncio +async def test_delete_study_async( + transport: str = "grpc_asyncio", request_type=vizier_service.DeleteStudyRequest +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.DeleteStudyRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_study_async_from_dict(): + await test_delete_study_async(request_type=dict) + + +def test_delete_study_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.DeleteStudyRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_study), "__call__") as call: + call.return_value = None + client.delete_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_study_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.DeleteStudyRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_study), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_delete_study_flattened(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_study(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_delete_study_flattened_error(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_study( + vizier_service.DeleteStudyRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_study_flattened_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_study(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_delete_study_flattened_error_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_study( + vizier_service.DeleteStudyRequest(), name="name_value", + ) + + +def test_lookup_study( + transport: str = "grpc", request_type=vizier_service.LookupStudyRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.lookup_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Study( + name="name_value", + display_name="display_name_value", + state=study.Study.State.ACTIVE, + inactive_reason="inactive_reason_value", + ) + response = client.lookup_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.LookupStudyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Study) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.state == study.Study.State.ACTIVE + assert response.inactive_reason == "inactive_reason_value" + + +def test_lookup_study_from_dict(): + test_lookup_study(request_type=dict) + + +def test_lookup_study_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.lookup_study), "__call__") as call: + client.lookup_study() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.LookupStudyRequest() + + +@pytest.mark.asyncio +async def test_lookup_study_async( + transport: str = "grpc_asyncio", request_type=vizier_service.LookupStudyRequest +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.lookup_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + study.Study( + name="name_value", + display_name="display_name_value", + state=study.Study.State.ACTIVE, + inactive_reason="inactive_reason_value", + ) + ) + response = await client.lookup_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.LookupStudyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Study) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + assert response.state == study.Study.State.ACTIVE + assert response.inactive_reason == "inactive_reason_value" + + +@pytest.mark.asyncio +async def test_lookup_study_async_from_dict(): + await test_lookup_study_async(request_type=dict) + + +def test_lookup_study_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.LookupStudyRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.lookup_study), "__call__") as call: + call.return_value = study.Study() + client.lookup_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_lookup_study_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.LookupStudyRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.lookup_study), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Study()) + await client.lookup_study(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_lookup_study_flattened(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.lookup_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Study() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.lookup_study(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +def test_lookup_study_flattened_error(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.lookup_study( + vizier_service.LookupStudyRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_lookup_study_flattened_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.lookup_study), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Study() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Study()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.lookup_study(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_lookup_study_flattened_error_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.lookup_study( + vizier_service.LookupStudyRequest(), parent="parent_value", + ) + + +def test_suggest_trials( + transport: str = "grpc", request_type=vizier_service.SuggestTrialsRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.suggest_trials), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.suggest_trials(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.SuggestTrialsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_suggest_trials_from_dict(): + test_suggest_trials(request_type=dict) + + +def test_suggest_trials_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.suggest_trials), "__call__") as call: + client.suggest_trials() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.SuggestTrialsRequest() + + +@pytest.mark.asyncio +async def test_suggest_trials_async( + transport: str = "grpc_asyncio", request_type=vizier_service.SuggestTrialsRequest +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.suggest_trials), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.suggest_trials(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.SuggestTrialsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_suggest_trials_async_from_dict(): + await test_suggest_trials_async(request_type=dict) + + +def test_suggest_trials_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.SuggestTrialsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.suggest_trials), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.suggest_trials(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_suggest_trials_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.SuggestTrialsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.suggest_trials), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.suggest_trials(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_create_trial( + transport: str = "grpc", request_type=vizier_service.CreateTrialRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Trial( + name="name_value", + id="id_value", + state=study.Trial.State.REQUESTED, + client_id="client_id_value", + infeasible_reason="infeasible_reason_value", + custom_job="custom_job_value", + ) + response = client.create_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.CreateTrialRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Trial) + assert response.name == "name_value" + assert response.id == "id_value" + assert response.state == study.Trial.State.REQUESTED + assert response.client_id == "client_id_value" + assert response.infeasible_reason == "infeasible_reason_value" + assert response.custom_job == "custom_job_value" + + +def test_create_trial_from_dict(): + test_create_trial(request_type=dict) + + +def test_create_trial_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_trial), "__call__") as call: + client.create_trial() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.CreateTrialRequest() + + +@pytest.mark.asyncio +async def test_create_trial_async( + transport: str = "grpc_asyncio", request_type=vizier_service.CreateTrialRequest +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + study.Trial( + name="name_value", + id="id_value", + state=study.Trial.State.REQUESTED, + client_id="client_id_value", + infeasible_reason="infeasible_reason_value", + custom_job="custom_job_value", + ) + ) + response = await client.create_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.CreateTrialRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Trial) + assert response.name == "name_value" + assert response.id == "id_value" + assert response.state == study.Trial.State.REQUESTED + assert response.client_id == "client_id_value" + assert response.infeasible_reason == "infeasible_reason_value" + assert response.custom_job == "custom_job_value" + + +@pytest.mark.asyncio +async def test_create_trial_async_from_dict(): + await test_create_trial_async(request_type=dict) + + +def test_create_trial_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.CreateTrialRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_trial), "__call__") as call: + call.return_value = study.Trial() + client.create_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_trial_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.CreateTrialRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_trial), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Trial()) + await client.create_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_create_trial_flattened(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Trial() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_trial( + parent="parent_value", trial=study.Trial(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[0].trial == study.Trial(name="name_value") + + +def test_create_trial_flattened_error(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_trial( + vizier_service.CreateTrialRequest(), + parent="parent_value", + trial=study.Trial(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_trial_flattened_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Trial() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Trial()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_trial( + parent="parent_value", trial=study.Trial(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + assert args[0].trial == study.Trial(name="name_value") + + +@pytest.mark.asyncio +async def test_create_trial_flattened_error_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_trial( + vizier_service.CreateTrialRequest(), + parent="parent_value", + trial=study.Trial(name="name_value"), + ) + + +def test_get_trial( + transport: str = "grpc", request_type=vizier_service.GetTrialRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Trial( + name="name_value", + id="id_value", + state=study.Trial.State.REQUESTED, + client_id="client_id_value", + infeasible_reason="infeasible_reason_value", + custom_job="custom_job_value", + ) + response = client.get_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.GetTrialRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Trial) + assert response.name == "name_value" + assert response.id == "id_value" + assert response.state == study.Trial.State.REQUESTED + assert response.client_id == "client_id_value" + assert response.infeasible_reason == "infeasible_reason_value" + assert response.custom_job == "custom_job_value" + + +def test_get_trial_from_dict(): + test_get_trial(request_type=dict) + + +def test_get_trial_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_trial), "__call__") as call: + client.get_trial() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.GetTrialRequest() + + +@pytest.mark.asyncio +async def test_get_trial_async( + transport: str = "grpc_asyncio", request_type=vizier_service.GetTrialRequest +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + study.Trial( + name="name_value", + id="id_value", + state=study.Trial.State.REQUESTED, + client_id="client_id_value", + infeasible_reason="infeasible_reason_value", + custom_job="custom_job_value", + ) + ) + response = await client.get_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.GetTrialRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Trial) + assert response.name == "name_value" + assert response.id == "id_value" + assert response.state == study.Trial.State.REQUESTED + assert response.client_id == "client_id_value" + assert response.infeasible_reason == "infeasible_reason_value" + assert response.custom_job == "custom_job_value" + + +@pytest.mark.asyncio +async def test_get_trial_async_from_dict(): + await test_get_trial_async(request_type=dict) + + +def test_get_trial_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.GetTrialRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_trial), "__call__") as call: + call.return_value = study.Trial() + client.get_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_trial_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.GetTrialRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_trial), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Trial()) + await client.get_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_get_trial_flattened(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Trial() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_trial(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_get_trial_flattened_error(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_trial( + vizier_service.GetTrialRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_trial_flattened_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Trial() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Trial()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_trial(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_get_trial_flattened_error_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_trial( + vizier_service.GetTrialRequest(), name="name_value", + ) + + +def test_list_trials( + transport: str = "grpc", request_type=vizier_service.ListTrialsRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_trials), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = vizier_service.ListTrialsResponse( + next_page_token="next_page_token_value", + ) + response = client.list_trials(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.ListTrialsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTrialsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_trials_from_dict(): + test_list_trials(request_type=dict) + + +def test_list_trials_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_trials), "__call__") as call: + client.list_trials() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.ListTrialsRequest() + + +@pytest.mark.asyncio +async def test_list_trials_async( + transport: str = "grpc_asyncio", request_type=vizier_service.ListTrialsRequest +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_trials), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + vizier_service.ListTrialsResponse(next_page_token="next_page_token_value",) + ) + response = await client.list_trials(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.ListTrialsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTrialsAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_trials_async_from_dict(): + await test_list_trials_async(request_type=dict) + + +def test_list_trials_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.ListTrialsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_trials), "__call__") as call: + call.return_value = vizier_service.ListTrialsResponse() + client.list_trials(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_trials_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.ListTrialsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_trials), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + vizier_service.ListTrialsResponse() + ) + await client.list_trials(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_trials_flattened(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_trials), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = vizier_service.ListTrialsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_trials(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +def test_list_trials_flattened_error(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_trials( + vizier_service.ListTrialsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_trials_flattened_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_trials), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = vizier_service.ListTrialsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + vizier_service.ListTrialsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_trials(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_trials_flattened_error_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_trials( + vizier_service.ListTrialsRequest(), parent="parent_value", + ) + + +def test_list_trials_pager(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_trials), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + vizier_service.ListTrialsResponse( + trials=[study.Trial(), study.Trial(), study.Trial(),], + next_page_token="abc", + ), + vizier_service.ListTrialsResponse(trials=[], next_page_token="def",), + vizier_service.ListTrialsResponse( + trials=[study.Trial(),], next_page_token="ghi", + ), + vizier_service.ListTrialsResponse(trials=[study.Trial(), study.Trial(),],), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_trials(request={}) + + assert pager._metadata == metadata + + results = [i for i in pager] + assert len(results) == 6 + assert all(isinstance(i, study.Trial) for i in results) + + +def test_list_trials_pages(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_trials), "__call__") as call: + # Set the response to a series of pages. + call.side_effect = ( + vizier_service.ListTrialsResponse( + trials=[study.Trial(), study.Trial(), study.Trial(),], + next_page_token="abc", + ), + vizier_service.ListTrialsResponse(trials=[], next_page_token="def",), + vizier_service.ListTrialsResponse( + trials=[study.Trial(),], next_page_token="ghi", + ), + vizier_service.ListTrialsResponse(trials=[study.Trial(), study.Trial(),],), + RuntimeError, + ) + pages = list(client.list_trials(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_trials_async_pager(): + client = VizierServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_trials), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + vizier_service.ListTrialsResponse( + trials=[study.Trial(), study.Trial(), study.Trial(),], + next_page_token="abc", + ), + vizier_service.ListTrialsResponse(trials=[], next_page_token="def",), + vizier_service.ListTrialsResponse( + trials=[study.Trial(),], next_page_token="ghi", + ), + vizier_service.ListTrialsResponse(trials=[study.Trial(), study.Trial(),],), + RuntimeError, + ) + async_pager = await client.list_trials(request={},) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, study.Trial) for i in responses) + + +@pytest.mark.asyncio +async def test_list_trials_async_pages(): + client = VizierServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_trials), "__call__", new_callable=mock.AsyncMock + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + vizier_service.ListTrialsResponse( + trials=[study.Trial(), study.Trial(), study.Trial(),], + next_page_token="abc", + ), + vizier_service.ListTrialsResponse(trials=[], next_page_token="def",), + vizier_service.ListTrialsResponse( + trials=[study.Trial(),], next_page_token="ghi", + ), + vizier_service.ListTrialsResponse(trials=[study.Trial(), study.Trial(),],), + RuntimeError, + ) + pages = [] + async for page_ in (await client.list_trials(request={})).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_add_trial_measurement( + transport: str = "grpc", request_type=vizier_service.AddTrialMeasurementRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.add_trial_measurement), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = study.Trial( + name="name_value", + id="id_value", + state=study.Trial.State.REQUESTED, + client_id="client_id_value", + infeasible_reason="infeasible_reason_value", + custom_job="custom_job_value", + ) + response = client.add_trial_measurement(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.AddTrialMeasurementRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Trial) + assert response.name == "name_value" + assert response.id == "id_value" + assert response.state == study.Trial.State.REQUESTED + assert response.client_id == "client_id_value" + assert response.infeasible_reason == "infeasible_reason_value" + assert response.custom_job == "custom_job_value" + + +def test_add_trial_measurement_from_dict(): + test_add_trial_measurement(request_type=dict) + + +def test_add_trial_measurement_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.add_trial_measurement), "__call__" + ) as call: + client.add_trial_measurement() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.AddTrialMeasurementRequest() + + +@pytest.mark.asyncio +async def test_add_trial_measurement_async( + transport: str = "grpc_asyncio", + request_type=vizier_service.AddTrialMeasurementRequest, +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.add_trial_measurement), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + study.Trial( + name="name_value", + id="id_value", + state=study.Trial.State.REQUESTED, + client_id="client_id_value", + infeasible_reason="infeasible_reason_value", + custom_job="custom_job_value", + ) + ) + response = await client.add_trial_measurement(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.AddTrialMeasurementRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Trial) + assert response.name == "name_value" + assert response.id == "id_value" + assert response.state == study.Trial.State.REQUESTED + assert response.client_id == "client_id_value" + assert response.infeasible_reason == "infeasible_reason_value" + assert response.custom_job == "custom_job_value" + + +@pytest.mark.asyncio +async def test_add_trial_measurement_async_from_dict(): + await test_add_trial_measurement_async(request_type=dict) + + +def test_add_trial_measurement_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.AddTrialMeasurementRequest() + + request.trial_name = "trial_name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.add_trial_measurement), "__call__" + ) as call: + call.return_value = study.Trial() + client.add_trial_measurement(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "trial_name=trial_name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_add_trial_measurement_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.AddTrialMeasurementRequest() + + request.trial_name = "trial_name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.add_trial_measurement), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Trial()) + await client.add_trial_measurement(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "trial_name=trial_name/value",) in kw["metadata"] + + +def test_complete_trial( + transport: str = "grpc", request_type=vizier_service.CompleteTrialRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.complete_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Trial( + name="name_value", + id="id_value", + state=study.Trial.State.REQUESTED, + client_id="client_id_value", + infeasible_reason="infeasible_reason_value", + custom_job="custom_job_value", + ) + response = client.complete_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.CompleteTrialRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Trial) + assert response.name == "name_value" + assert response.id == "id_value" + assert response.state == study.Trial.State.REQUESTED + assert response.client_id == "client_id_value" + assert response.infeasible_reason == "infeasible_reason_value" + assert response.custom_job == "custom_job_value" + + +def test_complete_trial_from_dict(): + test_complete_trial(request_type=dict) + + +def test_complete_trial_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.complete_trial), "__call__") as call: + client.complete_trial() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.CompleteTrialRequest() + + +@pytest.mark.asyncio +async def test_complete_trial_async( + transport: str = "grpc_asyncio", request_type=vizier_service.CompleteTrialRequest +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.complete_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + study.Trial( + name="name_value", + id="id_value", + state=study.Trial.State.REQUESTED, + client_id="client_id_value", + infeasible_reason="infeasible_reason_value", + custom_job="custom_job_value", + ) + ) + response = await client.complete_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.CompleteTrialRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Trial) + assert response.name == "name_value" + assert response.id == "id_value" + assert response.state == study.Trial.State.REQUESTED + assert response.client_id == "client_id_value" + assert response.infeasible_reason == "infeasible_reason_value" + assert response.custom_job == "custom_job_value" + + +@pytest.mark.asyncio +async def test_complete_trial_async_from_dict(): + await test_complete_trial_async(request_type=dict) + + +def test_complete_trial_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.CompleteTrialRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.complete_trial), "__call__") as call: + call.return_value = study.Trial() + client.complete_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_complete_trial_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.CompleteTrialRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.complete_trial), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Trial()) + await client.complete_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_delete_trial( + transport: str = "grpc", request_type=vizier_service.DeleteTrialRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.DeleteTrialRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_trial_from_dict(): + test_delete_trial(request_type=dict) + + +def test_delete_trial_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_trial), "__call__") as call: + client.delete_trial() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.DeleteTrialRequest() + + +@pytest.mark.asyncio +async def test_delete_trial_async( + transport: str = "grpc_asyncio", request_type=vizier_service.DeleteTrialRequest +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.DeleteTrialRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_trial_async_from_dict(): + await test_delete_trial_async(request_type=dict) + + +def test_delete_trial_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.DeleteTrialRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_trial), "__call__") as call: + call.return_value = None + client.delete_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_trial_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.DeleteTrialRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_trial), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_delete_trial_flattened(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_trial(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +def test_delete_trial_flattened_error(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_trial( + vizier_service.DeleteTrialRequest(), name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_trial_flattened_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_trial(name="name_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].name == "name_value" + + +@pytest.mark.asyncio +async def test_delete_trial_flattened_error_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_trial( + vizier_service.DeleteTrialRequest(), name="name_value", + ) + + +def test_check_trial_early_stopping_state( + transport: str = "grpc", + request_type=vizier_service.CheckTrialEarlyStoppingStateRequest, +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_trial_early_stopping_state), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.check_trial_early_stopping_state(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.CheckTrialEarlyStoppingStateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_check_trial_early_stopping_state_from_dict(): + test_check_trial_early_stopping_state(request_type=dict) + + +def test_check_trial_early_stopping_state_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_trial_early_stopping_state), "__call__" + ) as call: + client.check_trial_early_stopping_state() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.CheckTrialEarlyStoppingStateRequest() + + +@pytest.mark.asyncio +async def test_check_trial_early_stopping_state_async( + transport: str = "grpc_asyncio", + request_type=vizier_service.CheckTrialEarlyStoppingStateRequest, +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_trial_early_stopping_state), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + response = await client.check_trial_early_stopping_state(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.CheckTrialEarlyStoppingStateRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_check_trial_early_stopping_state_async_from_dict(): + await test_check_trial_early_stopping_state_async(request_type=dict) + + +def test_check_trial_early_stopping_state_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.CheckTrialEarlyStoppingStateRequest() + + request.trial_name = "trial_name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_trial_early_stopping_state), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.check_trial_early_stopping_state(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "trial_name=trial_name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_check_trial_early_stopping_state_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.CheckTrialEarlyStoppingStateRequest() + + request.trial_name = "trial_name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.check_trial_early_stopping_state), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.check_trial_early_stopping_state(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "trial_name=trial_name/value",) in kw["metadata"] + + +def test_stop_trial( + transport: str = "grpc", request_type=vizier_service.StopTrialRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.stop_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = study.Trial( + name="name_value", + id="id_value", + state=study.Trial.State.REQUESTED, + client_id="client_id_value", + infeasible_reason="infeasible_reason_value", + custom_job="custom_job_value", + ) + response = client.stop_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.StopTrialRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Trial) + assert response.name == "name_value" + assert response.id == "id_value" + assert response.state == study.Trial.State.REQUESTED + assert response.client_id == "client_id_value" + assert response.infeasible_reason == "infeasible_reason_value" + assert response.custom_job == "custom_job_value" + + +def test_stop_trial_from_dict(): + test_stop_trial(request_type=dict) + + +def test_stop_trial_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.stop_trial), "__call__") as call: + client.stop_trial() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.StopTrialRequest() + + +@pytest.mark.asyncio +async def test_stop_trial_async( + transport: str = "grpc_asyncio", request_type=vizier_service.StopTrialRequest +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.stop_trial), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + study.Trial( + name="name_value", + id="id_value", + state=study.Trial.State.REQUESTED, + client_id="client_id_value", + infeasible_reason="infeasible_reason_value", + custom_job="custom_job_value", + ) + ) + response = await client.stop_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.StopTrialRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, study.Trial) + assert response.name == "name_value" + assert response.id == "id_value" + assert response.state == study.Trial.State.REQUESTED + assert response.client_id == "client_id_value" + assert response.infeasible_reason == "infeasible_reason_value" + assert response.custom_job == "custom_job_value" + + +@pytest.mark.asyncio +async def test_stop_trial_async_from_dict(): + await test_stop_trial_async(request_type=dict) + + +def test_stop_trial_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.StopTrialRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.stop_trial), "__call__") as call: + call.return_value = study.Trial() + client.stop_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_stop_trial_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.StopTrialRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.stop_trial), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Trial()) + await client.stop_trial(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + + +def test_list_optimal_trials( + transport: str = "grpc", request_type=vizier_service.ListOptimalTrialsRequest +): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_optimal_trials), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = vizier_service.ListOptimalTrialsResponse() + response = client.list_optimal_trials(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.ListOptimalTrialsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, vizier_service.ListOptimalTrialsResponse) + + +def test_list_optimal_trials_from_dict(): + test_list_optimal_trials(request_type=dict) + + +def test_list_optimal_trials_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_optimal_trials), "__call__" + ) as call: + client.list_optimal_trials() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.ListOptimalTrialsRequest() + + +@pytest.mark.asyncio +async def test_list_optimal_trials_async( + transport: str = "grpc_asyncio", + request_type=vizier_service.ListOptimalTrialsRequest, +): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_optimal_trials), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + vizier_service.ListOptimalTrialsResponse() + ) + response = await client.list_optimal_trials(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == vizier_service.ListOptimalTrialsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, vizier_service.ListOptimalTrialsResponse) + + +@pytest.mark.asyncio +async def test_list_optimal_trials_async_from_dict(): + await test_list_optimal_trials_async(request_type=dict) + + +def test_list_optimal_trials_field_headers(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.ListOptimalTrialsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_optimal_trials), "__call__" + ) as call: + call.return_value = vizier_service.ListOptimalTrialsResponse() + client.list_optimal_trials(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_optimal_trials_field_headers_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = vizier_service.ListOptimalTrialsRequest() + + request.parent = "parent/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_optimal_trials), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + vizier_service.ListOptimalTrialsResponse() + ) + await client.list_optimal_trials(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + + +def test_list_optimal_trials_flattened(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_optimal_trials), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = vizier_service.ListOptimalTrialsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_optimal_trials(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +def test_list_optimal_trials_flattened_error(): + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_optimal_trials( + vizier_service.ListOptimalTrialsRequest(), parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_optimal_trials_flattened_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_optimal_trials), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = vizier_service.ListOptimalTrialsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + vizier_service.ListOptimalTrialsResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_optimal_trials(parent="parent_value",) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].parent == "parent_value" + + +@pytest.mark.asyncio +async def test_list_optimal_trials_flattened_error_async(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_optimal_trials( + vizier_service.ListOptimalTrialsRequest(), parent="parent_value", + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.VizierServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.VizierServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = VizierServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.VizierServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = VizierServiceClient( + client_options={"scopes": ["1", "2"]}, transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.VizierServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = VizierServiceClient(transport=transport) + assert client.transport is transport + + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.VizierServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.VizierServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.VizierServiceGrpcTransport, + transports.VizierServiceGrpcAsyncIOTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + assert isinstance(client.transport, transports.VizierServiceGrpcTransport,) + + +def test_vizier_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.VizierServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json", + ) + + +def test_vizier_service_base_transport(): + # Instantiate the base transport. + with mock.patch( + "google.cloud.aiplatform_v1.services.vizier_service.transports.VizierServiceTransport.__init__" + ) as Transport: + Transport.return_value = None + transport = transports.VizierServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + "create_study", + "get_study", + "list_studies", + "delete_study", + "lookup_study", + "suggest_trials", + "create_trial", + "get_trial", + "list_trials", + "add_trial_measurement", + "complete_trial", + "delete_trial", + "check_trial_early_stopping_state", + "stop_trial", + "list_optimal_trials", + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + +@requires_google_auth_gte_1_25_0 +def test_vizier_service_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1.services.vizier_service.transports.VizierServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.VizierServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_vizier_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1.services.vizier_service.transports.VizierServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.VizierServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +def test_vizier_service_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( + "google.cloud.aiplatform_v1.services.vizier_service.transports.VizierServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.VizierServiceTransport() + adc.assert_called_once() + + +@requires_google_auth_gte_1_25_0 +def test_vizier_service_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + VizierServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_vizier_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + VizierServiceClient() + adc.assert_called_once_with( + scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.VizierServiceGrpcTransport, + transports.VizierServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_vizier_service_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.VizierServiceGrpcTransport, + transports.VizierServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_vizier_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") + adc.assert_called_once_with( + scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.VizierServiceGrpcTransport, grpc_helpers), + (transports.VizierServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +def test_vizier_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.VizierServiceGrpcTransport, + transports.VizierServiceGrpcAsyncIOTransport, + ], +) +def test_vizier_service_grpc_transport_client_cert_source_for_mtls(transport_class): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds, + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_channel_creds, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls + # is used. + with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): + with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: + transport_class( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback, + ) + expected_cert, expected_key = client_cert_source_callback() + mock_ssl_cred.assert_called_once_with( + certificate_chain=expected_cert, private_key=expected_key + ) + + +def test_vizier_service_host_no_port(): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions( + api_endpoint="aiplatform.googleapis.com" + ), + ) + assert client.transport._host == "aiplatform.googleapis.com:443" + + +def test_vizier_service_host_with_port(): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions( + api_endpoint="aiplatform.googleapis.com:8000" + ), + ) + assert client.transport._host == "aiplatform.googleapis.com:8000" + + +def test_vizier_service_grpc_transport_channel(): + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.VizierServiceGrpcTransport( + host="squid.clam.whelk", channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +def test_vizier_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.VizierServiceGrpcAsyncIOTransport( + host="squid.clam.whelk", channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize( + "transport_class", + [ + transports.VizierServiceGrpcTransport, + transports.VizierServiceGrpcAsyncIOTransport, + ], +) +def test_vizier_service_transport_channel_mtls_with_client_cert_source(transport_class): + with mock.patch( + "grpc.ssl_channel_credentials", autospec=True + ) as grpc_ssl_channel_cred: + with mock.patch.object( + transport_class, "create_channel" + ) as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize( + "transport_class", + [ + transports.VizierServiceGrpcTransport, + transports.VizierServiceGrpcAsyncIOTransport, + ], +) +def test_vizier_service_transport_channel_mtls_with_adc(transport_class): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object( + transport_class, "create_channel" + ) as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_vizier_service_grpc_lro_client(): + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance(transport.operations_client, operations_v1.OperationsClient,) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_vizier_service_grpc_lro_async_client(): + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_custom_job_path(): + project = "squid" + location = "clam" + custom_job = "whelk" + expected = "projects/{project}/locations/{location}/customJobs/{custom_job}".format( + project=project, location=location, custom_job=custom_job, + ) + actual = VizierServiceClient.custom_job_path(project, location, custom_job) + assert expected == actual + + +def test_parse_custom_job_path(): + expected = { + "project": "octopus", + "location": "oyster", + "custom_job": "nudibranch", + } + path = VizierServiceClient.custom_job_path(**expected) + + # Check that the path construction is reversible. + actual = VizierServiceClient.parse_custom_job_path(path) + assert expected == actual + + +def test_study_path(): + project = "cuttlefish" + location = "mussel" + study = "winkle" + expected = "projects/{project}/locations/{location}/studies/{study}".format( + project=project, location=location, study=study, + ) + actual = VizierServiceClient.study_path(project, location, study) + assert expected == actual + + +def test_parse_study_path(): + expected = { + "project": "nautilus", + "location": "scallop", + "study": "abalone", + } + path = VizierServiceClient.study_path(**expected) + + # Check that the path construction is reversible. + actual = VizierServiceClient.parse_study_path(path) + assert expected == actual + + +def test_trial_path(): + project = "squid" + location = "clam" + study = "whelk" + trial = "octopus" + expected = "projects/{project}/locations/{location}/studies/{study}/trials/{trial}".format( + project=project, location=location, study=study, trial=trial, + ) + actual = VizierServiceClient.trial_path(project, location, study, trial) + assert expected == actual + + +def test_parse_trial_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "study": "cuttlefish", + "trial": "mussel", + } + path = VizierServiceClient.trial_path(**expected) + + # Check that the path construction is reversible. + actual = VizierServiceClient.parse_trial_path(path) + assert expected == actual + + +def test_common_billing_account_path(): + billing_account = "winkle" + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = VizierServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "nautilus", + } + path = VizierServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = VizierServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "scallop" + expected = "folders/{folder}".format(folder=folder,) + actual = VizierServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "abalone", + } + path = VizierServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = VizierServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "squid" + expected = "organizations/{organization}".format(organization=organization,) + actual = VizierServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "clam", + } + path = VizierServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = VizierServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "whelk" + expected = "projects/{project}".format(project=project,) + actual = VizierServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "octopus", + } + path = VizierServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = VizierServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "oyster" + location = "nudibranch" + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = VizierServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "cuttlefish", + "location": "mussel", + } + path = VizierServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = VizierServiceClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_withDEFAULT_CLIENT_INFO(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object( + transports.VizierServiceTransport, "_prep_wrapped_messages" + ) as prep: + client = VizierServiceClient( + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object( + transports.VizierServiceTransport, "_prep_wrapped_messages" + ) as prep: + transport_class = VizierServiceClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + ) + prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py index 475c192c60..2158facfaf 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py @@ -1707,20 +1707,18 @@ def test_parse_dataset_path(): def test_dataset_path(): project = "squid" - location = "clam" - dataset = "whelk" - expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( - project=project, location=location, dataset=dataset, + dataset = "clam" + expected = "projects/{project}/datasets/{dataset}".format( + project=project, dataset=dataset, ) - actual = MigrationServiceClient.dataset_path(project, location, dataset) + actual = MigrationServiceClient.dataset_path(project, dataset) assert expected == actual def test_parse_dataset_path(): expected = { - "project": "octopus", - "location": "oyster", - "dataset": "nudibranch", + "project": "whelk", + "dataset": "octopus", } path = MigrationServiceClient.dataset_path(**expected) @@ -1730,18 +1728,20 @@ def test_parse_dataset_path(): def test_dataset_path(): - project = "cuttlefish" - dataset = "mussel" - expected = "projects/{project}/datasets/{dataset}".format( - project=project, dataset=dataset, + project = "oyster" + location = "nudibranch" + dataset = "cuttlefish" + expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( + project=project, location=location, dataset=dataset, ) - actual = MigrationServiceClient.dataset_path(project, dataset) + actual = MigrationServiceClient.dataset_path(project, location, dataset) assert expected == actual def test_parse_dataset_path(): expected = { - "project": "winkle", + "project": "mussel", + "location": "winkle", "dataset": "nautilus", } path = MigrationServiceClient.dataset_path(**expected)