diff --git a/docs/definition_v1/types.rst b/docs/definition_v1/types.rst new file mode 100644 index 0000000000..a1df2bce25 --- /dev/null +++ b/docs/definition_v1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Aiplatform V1 Schema Trainingjob Definition v1 API +========================================================================= + +.. automodule:: google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/definition_v1beta1/types.rst b/docs/definition_v1beta1/types.rst new file mode 100644 index 0000000000..f4fe7a5301 --- /dev/null +++ b/docs/definition_v1beta1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Aiplatform V1beta1 Schema Trainingjob Definition v1beta1 API +=================================================================================== + +.. automodule:: google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/instance_v1/types.rst b/docs/instance_v1/types.rst new file mode 100644 index 0000000000..564ab013ee --- /dev/null +++ b/docs/instance_v1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Aiplatform V1 Schema Predict Instance v1 API +=================================================================== + +.. automodule:: google.cloud.aiplatform.v1.schema.predict.instance_v1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/instance_v1beta1/types.rst b/docs/instance_v1beta1/types.rst new file mode 100644 index 0000000000..7caa088065 --- /dev/null +++ b/docs/instance_v1beta1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Aiplatform V1beta1 Schema Predict Instance v1beta1 API +============================================================================= + +.. automodule:: google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/params_v1/types.rst b/docs/params_v1/types.rst new file mode 100644 index 0000000000..956ef5224d --- /dev/null +++ b/docs/params_v1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Aiplatform V1 Schema Predict Params v1 API +================================================================= + +.. automodule:: google.cloud.aiplatform.v1.schema.predict.params_v1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/params_v1beta1/types.rst b/docs/params_v1beta1/types.rst new file mode 100644 index 0000000000..722a1d8ba0 --- /dev/null +++ b/docs/params_v1beta1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Aiplatform V1beta1 Schema Predict Params v1beta1 API +=========================================================================== + +.. automodule:: google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/prediction_v1/types.rst b/docs/prediction_v1/types.rst new file mode 100644 index 0000000000..a97faf34de --- /dev/null +++ b/docs/prediction_v1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Aiplatform V1 Schema Predict Prediction v1 API +===================================================================== + +.. automodule:: google.cloud.aiplatform.v1.schema.predict.prediction_v1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/prediction_v1beta1/types.rst b/docs/prediction_v1beta1/types.rst new file mode 100644 index 0000000000..b14182d6d7 --- /dev/null +++ b/docs/prediction_v1beta1/types.rst @@ -0,0 +1,7 @@ +Types for Google Cloud Aiplatform V1beta1 Schema Predict Prediction v1beta1 API +=============================================================================== + +.. automodule:: google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types + :members: + :undoc-members: + :show-inheritance: diff --git a/google/cloud/aiplatform_v1/__init__.py b/google/cloud/aiplatform_v1/__init__.py index 055ceb5de2..f17d902b53 100644 --- a/google/cloud/aiplatform_v1/__init__.py +++ b/google/cloud/aiplatform_v1/__init__.py @@ -362,10 +362,12 @@ from .types.model_service import UploadModelResponse from .types.operation import DeleteOperationMetadata from .types.operation import GenericOperationMetadata +from .types.pipeline_failure_policy import PipelineFailurePolicy from .types.pipeline_job import PipelineJob from .types.pipeline_job import PipelineJobDetail from .types.pipeline_job import PipelineTaskDetail from .types.pipeline_job import PipelineTaskExecutorDetail +from .types.pipeline_job import PipelineTemplateMetadata from .types.pipeline_service import CancelPipelineJobRequest from .types.pipeline_service import CancelTrainingPipelineRequest from .types.pipeline_service import CreatePipelineJobRequest @@ -829,12 +831,14 @@ "NearestNeighborSearchOperationMetadata", "NfsMount", "PauseModelDeploymentMonitoringJobRequest", + "PipelineFailurePolicy", "PipelineJob", "PipelineJobDetail", "PipelineServiceClient", "PipelineState", "PipelineTaskDetail", "PipelineTaskExecutorDetail", + "PipelineTemplateMetadata", "Port", "PredefinedSplit", "PredictRequest", diff --git a/google/cloud/aiplatform_v1/services/migration_service/client.py b/google/cloud/aiplatform_v1/services/migration_service/client.py index 99736fc796..269c1529b4 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/client.py +++ b/google/cloud/aiplatform_v1/services/migration_service/client.py @@ -192,40 +192,40 @@ def parse_annotated_dataset_path(path: str) -> Dict[str, str]: @staticmethod def dataset_path( project: str, + location: str, dataset: str, ) -> str: """Returns a fully-qualified dataset string.""" - return "projects/{project}/datasets/{dataset}".format( + 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 def dataset_path( project: str, - location: str, dataset: str, ) -> str: """Returns a fully-qualified dataset string.""" - return "projects/{project}/locations/{location}/datasets/{dataset}".format( + return "projects/{project}/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.+?)/locations/(?P.+?)/datasets/(?P.+?)$", - path, - ) + m = re.match(r"^projects/(?P.+?)/datasets/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod diff --git a/google/cloud/aiplatform_v1/types/__init__.py b/google/cloud/aiplatform_v1/types/__init__.py index 5bd19073ed..773a75b3cf 100644 --- a/google/cloud/aiplatform_v1/types/__init__.py +++ b/google/cloud/aiplatform_v1/types/__init__.py @@ -423,6 +423,7 @@ PipelineJobDetail, PipelineTaskDetail, PipelineTaskExecutorDetail, + PipelineTemplateMetadata, ) from .pipeline_service import ( CancelPipelineJobRequest, @@ -883,10 +884,12 @@ "UploadModelResponse", "DeleteOperationMetadata", "GenericOperationMetadata", + "PipelineFailurePolicy", "PipelineJob", "PipelineJobDetail", "PipelineTaskDetail", "PipelineTaskExecutorDetail", + "PipelineTemplateMetadata", "CancelPipelineJobRequest", "CancelTrainingPipelineRequest", "CreatePipelineJobRequest", diff --git a/google/cloud/aiplatform_v1/types/endpoint.py b/google/cloud/aiplatform_v1/types/endpoint.py index 1c21e85e73..22c1d6804c 100644 --- a/google/cloud/aiplatform_v1/types/endpoint.py +++ b/google/cloud/aiplatform_v1/types/endpoint.py @@ -221,10 +221,10 @@ class DeployedModel(proto.Message): This value should be 1-10 characters, and valid characters are /[0-9]/. model (str): - Required. The name of the Model that this is - the deployment of. Note that the Model may be in - a different location than the DeployedModel's - Endpoint. + Required. The resource name of the Model that + this is the deployment of. Note that the Model + may be in a different location than the + DeployedModel's Endpoint. display_name (str): The display name of the DeployedModel. If not provided upon creation, the Model's display_name is used. diff --git a/google/cloud/aiplatform_v1/types/explanation_metadata.py b/google/cloud/aiplatform_v1/types/explanation_metadata.py index c528cf94f4..5d9dcca392 100644 --- a/google/cloud/aiplatform_v1/types/explanation_metadata.py +++ b/google/cloud/aiplatform_v1/types/explanation_metadata.py @@ -69,6 +69,9 @@ class ExplanationMetadata(proto.Message): including the URI scheme, than the one given on input. The output URI will point to a location where the user only has a read access. + latent_space_source (str): + Name of the source to generate embeddings for + example based explanations. """ class InputMetadata(proto.Message): @@ -457,6 +460,10 @@ class OutputMetadata(proto.Message): proto.STRING, number=3, ) + latent_space_source = proto.Field( + proto.STRING, + number=5, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/featurestore.py b/google/cloud/aiplatform_v1/types/featurestore.py index c6cb0022a0..e88b5c17bc 100644 --- a/google/cloud/aiplatform_v1/types/featurestore.py +++ b/google/cloud/aiplatform_v1/types/featurestore.py @@ -92,12 +92,46 @@ class OnlineServingConfig(proto.Message): set to 0, the featurestore will not have an online store and cannot be used for online serving. + scaling (google.cloud.aiplatform_v1.types.Featurestore.OnlineServingConfig.Scaling): + Online serving scaling configuration. Only one of + ``fixed_node_count`` and ``scaling`` can be set. Setting one + will reset the other. """ + class Scaling(proto.Message): + r"""Online serving scaling configuration. If min_node_count and + max_node_count are set to the same value, the cluster will be + configured with the fixed number of node (no auto-scaling). + + Attributes: + min_node_count (int): + Required. The minimum number of nodes to + scale down to. Must be greater than or equal to + 1. + max_node_count (int): + The maximum number of nodes to scale up to. Must be greater + than min_node_count, and less than or equal to 10 times of + 'min_node_count'. + """ + + min_node_count = proto.Field( + proto.INT32, + number=1, + ) + max_node_count = proto.Field( + proto.INT32, + number=2, + ) + fixed_node_count = proto.Field( proto.INT32, number=2, ) + scaling = proto.Field( + proto.MESSAGE, + number=4, + message="Featurestore.OnlineServingConfig.Scaling", + ) name = proto.Field( proto.STRING, diff --git a/google/cloud/aiplatform_v1/types/featurestore_online_service.py b/google/cloud/aiplatform_v1/types/featurestore_online_service.py index 7a337359f8..0d0ab77ed3 100644 --- a/google/cloud/aiplatform_v1/types/featurestore_online_service.py +++ b/google/cloud/aiplatform_v1/types/featurestore_online_service.py @@ -236,7 +236,7 @@ class StreamingReadFeatureValuesRequest(proto.Message): class FeatureValue(proto.Message): r"""Value for a feature. - NEXT ID: 15 + (-- NEXT ID: 15 --) This message has `oneof`_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. diff --git a/google/cloud/aiplatform_v1/types/manual_batch_tuning_parameters.py b/google/cloud/aiplatform_v1/types/manual_batch_tuning_parameters.py index df542f78a7..9d1d396059 100644 --- a/google/cloud/aiplatform_v1/types/manual_batch_tuning_parameters.py +++ b/google/cloud/aiplatform_v1/types/manual_batch_tuning_parameters.py @@ -38,7 +38,7 @@ class ManualBatchTuningParameters(proto.Message): value will result in a whole batch not fitting in a machine's memory, and the whole operation will fail. - The default value is 4. + The default value is 64. """ batch_size = proto.Field( diff --git a/google/cloud/aiplatform_v1/types/model_evaluation.py b/google/cloud/aiplatform_v1/types/model_evaluation.py index 51b7f5c158..026d719282 100644 --- a/google/cloud/aiplatform_v1/types/model_evaluation.py +++ b/google/cloud/aiplatform_v1/types/model_evaluation.py @@ -37,6 +37,8 @@ class ModelEvaluation(proto.Message): name (str): Output only. The resource name of the ModelEvaluation. + display_name (str): + The display name of the ModelEvaluation. metrics_schema_uri (str): Points to a YAML file stored on Google Cloud Storage describing the @@ -92,6 +94,11 @@ class ModelEvaluation(proto.Message): [ExplanationSpec][google.cloud.aiplatform.v1.ExplanationSpec] that are used for explaining the predicted values on the evaluated data. + metadata (google.protobuf.struct_pb2.Value): + The metadata of the ModelEvaluation. For the ModelEvaluation + uploaded from Managed Pipeline, metadata contains a + structured value with keys of "pipeline_job_id", + "evaluation_dataset_type", "evaluation_dataset_path". """ class ModelEvaluationExplanationSpec(proto.Message): @@ -123,6 +130,10 @@ class ModelEvaluationExplanationSpec(proto.Message): proto.STRING, number=1, ) + display_name = proto.Field( + proto.STRING, + number=10, + ) metrics_schema_uri = proto.Field( proto.STRING, number=2, @@ -159,6 +170,11 @@ class ModelEvaluationExplanationSpec(proto.Message): number=9, message=ModelEvaluationExplanationSpec, ) + metadata = proto.Field( + proto.MESSAGE, + number=11, + message=struct_pb2.Value, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/model_monitoring.py b/google/cloud/aiplatform_v1/types/model_monitoring.py index 4987479e5b..0d0ab49d15 100644 --- a/google/cloud/aiplatform_v1/types/model_monitoring.py +++ b/google/cloud/aiplatform_v1/types/model_monitoring.py @@ -84,6 +84,8 @@ class TrainingDataset(proto.Message): "csv" The source file is a CSV file. + "jsonl" + The source file is a JSONL file. target_field (str): The target field name the model is to predict. This field will be excluded when doing diff --git a/google/cloud/aiplatform_v1/types/pipeline_failure_policy.py b/google/cloud/aiplatform_v1/types/pipeline_failure_policy.py new file mode 100644 index 0000000000..4400d72fc5 --- /dev/null +++ b/google/cloud/aiplatform_v1/types/pipeline_failure_policy.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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 + + +__protobuf__ = proto.module( + package="google.cloud.aiplatform.v1", + manifest={ + "PipelineFailurePolicy", + }, +) + + +class PipelineFailurePolicy(proto.Enum): + r"""Represents the failure policy of a pipeline. Currently, the default + of a pipeline is that the pipeline will continue to run until no + more tasks can be executed, also known as + PIPELINE_FAILURE_POLICY_FAIL_SLOW. However, if a pipeline is set to + PIPELINE_FAILURE_POLICY_FAIL_FAST, it will stop scheduling any new + tasks when a task has failed. Any scheduled tasks will continue to + completion. + """ + PIPELINE_FAILURE_POLICY_UNSPECIFIED = 0 + PIPELINE_FAILURE_POLICY_FAIL_SLOW = 1 + PIPELINE_FAILURE_POLICY_FAIL_FAST = 2 + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/pipeline_job.py b/google/cloud/aiplatform_v1/types/pipeline_job.py index cbfd7335e7..3e2152b65e 100644 --- a/google/cloud/aiplatform_v1/types/pipeline_job.py +++ b/google/cloud/aiplatform_v1/types/pipeline_job.py @@ -19,6 +19,7 @@ from google.cloud.aiplatform_v1.types import context from google.cloud.aiplatform_v1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1.types import execution as gca_execution +from google.cloud.aiplatform_v1.types import pipeline_failure_policy from google.cloud.aiplatform_v1.types import pipeline_state from google.cloud.aiplatform_v1.types import value as gca_value from google.protobuf import struct_pb2 # type: ignore @@ -30,6 +31,7 @@ package="google.cloud.aiplatform.v1", manifest={ "PipelineJob", + "PipelineTemplateMetadata", "PipelineJobDetail", "PipelineTaskDetail", "PipelineTaskExecutorDetail", @@ -109,6 +111,15 @@ class PipelineJob(proto.Message): to the GCP resources being launched, if applied, such as Vertex AI Training or Dataflow job. If left unspecified, the workload is not peered with any network. + template_uri (str): + A template uri from where the + [PipelineJob.pipeline_spec][google.cloud.aiplatform.v1.PipelineJob.pipeline_spec], + if empty, will be downloaded. + template_metadata (google.cloud.aiplatform_v1.types.PipelineTemplateMetadata): + Output only. Pipeline template metadata. Will fill up fields + if + [PipelineJob.template_uri][google.cloud.aiplatform.v1.PipelineJob.template_uri] + is from supported template registry. """ class RuntimeConfig(proto.Message): @@ -144,6 +155,14 @@ class RuntimeConfig(proto.Message): ``PipelineJob.pipeline_spec.schema_version`` 2.1.0, such as pipelines built using Kubeflow Pipelines SDK 1.9 or higher and the v2 DSL. + failure_policy (google.cloud.aiplatform_v1.types.PipelineFailurePolicy): + Represents the failure policy of a pipeline. Currently, the + default of a pipeline is that the pipeline will continue to + run until no more tasks can be executed, also known as + PIPELINE_FAILURE_POLICY_FAIL_SLOW. However, if a pipeline is + set to PIPELINE_FAILURE_POLICY_FAIL_FAST, it will stop + scheduling any new tasks when a task has failed. Any + scheduled tasks will continue to completion. """ parameters = proto.MapField( @@ -162,6 +181,11 @@ class RuntimeConfig(proto.Message): number=3, message=struct_pb2.Value, ) + failure_policy = proto.Field( + proto.ENUM, + number=4, + enum=pipeline_failure_policy.PipelineFailurePolicy, + ) name = proto.Field( proto.STRING, @@ -234,6 +258,38 @@ class RuntimeConfig(proto.Message): proto.STRING, number=18, ) + template_uri = proto.Field( + proto.STRING, + number=19, + ) + template_metadata = proto.Field( + proto.MESSAGE, + number=20, + message="PipelineTemplateMetadata", + ) + + +class PipelineTemplateMetadata(proto.Message): + r"""Pipeline template metadata if + [PipelineJob.template_uri][google.cloud.aiplatform.v1.PipelineJob.template_uri] + is from supported template registry. Currently, the only supported + registry is Artifact Registry. + + Attributes: + version (str): + The version_name in artifact registry. + + Will always be presented in output if the + [PipelineJob.template_uri][google.cloud.aiplatform.v1.PipelineJob.template_uri] + is from supported template registry. + + Format is "sha256:abcdef123456...". + """ + + version = proto.Field( + proto.STRING, + number=3, + ) class PipelineJobDetail(proto.Message): diff --git a/google/cloud/aiplatform_v1/types/pipeline_service.py b/google/cloud/aiplatform_v1/types/pipeline_service.py index 1b02ad9ce3..4e197a08e1 100644 --- a/google/cloud/aiplatform_v1/types/pipeline_service.py +++ b/google/cloud/aiplatform_v1/types/pipeline_service.py @@ -286,8 +286,8 @@ class ListPipelineJobsRequest(proto.Message): - ``labels``: Supports key-value equality and key presence. - ``template_uri``: Supports ``=``, ``!=`` comparisons, and ``:`` wildcard. - - ``template_metadata.version_name``: Supports ``=``, - ``!=`` comparisons, and ``:`` wildcard. + - ``template_metadata.version``: Supports ``=``, ``!=`` + comparisons, and ``:`` wildcard. Filter expressions can be combined together using logical operators (``AND`` & ``OR``). For example: diff --git a/google/cloud/aiplatform_v1beta1/__init__.py b/google/cloud/aiplatform_v1beta1/__init__.py index b04a7bcd87..47b70735ad 100644 --- a/google/cloud/aiplatform_v1beta1/__init__.py +++ b/google/cloud/aiplatform_v1beta1/__init__.py @@ -115,6 +115,8 @@ from .types.explanation import Attribution from .types.explanation import BlurBaselineConfig from .types.explanation import Examples +from .types.explanation import ExamplesOverride +from .types.explanation import ExamplesRestrictionsNamespace from .types.explanation import Explanation from .types.explanation import ExplanationMetadataOverride from .types.explanation import ExplanationParameters @@ -123,6 +125,8 @@ from .types.explanation import FeatureNoiseSigma from .types.explanation import IntegratedGradientsAttribution from .types.explanation import ModelExplanation +from .types.explanation import Neighbor +from .types.explanation import Presets from .types.explanation import SampledShapleyAttribution from .types.explanation import SmoothGradConfig from .types.explanation import XraiAttribution @@ -361,12 +365,16 @@ from .types.model_service import ListModelVersionsRequest from .types.model_service import ListModelVersionsResponse from .types.model_service import MergeVersionAliasesRequest +from .types.model_service import UpdateExplanationDatasetOperationMetadata +from .types.model_service import UpdateExplanationDatasetRequest +from .types.model_service import UpdateExplanationDatasetResponse from .types.model_service import UpdateModelRequest from .types.model_service import UploadModelOperationMetadata from .types.model_service import UploadModelRequest from .types.model_service import UploadModelResponse from .types.operation import DeleteOperationMetadata from .types.operation import GenericOperationMetadata +from .types.pipeline_failure_policy import PipelineFailurePolicy from .types.pipeline_job import PipelineJob from .types.pipeline_job import PipelineJobDetail from .types.pipeline_job import PipelineTaskDetail @@ -654,6 +662,8 @@ "EnvVar", "Event", "Examples", + "ExamplesOverride", + "ExamplesRestrictionsNamespace", "Execution", "ExplainRequest", "ExplainResponse", @@ -838,8 +848,10 @@ "MutateDeployedIndexRequest", "MutateDeployedIndexResponse", "NearestNeighborSearchOperationMetadata", + "Neighbor", "NfsMount", "PauseModelDeploymentMonitoringJobRequest", + "PipelineFailurePolicy", "PipelineJob", "PipelineJobDetail", "PipelineServiceClient", @@ -854,6 +866,7 @@ "PredictResponse", "PredictSchemata", "PredictionServiceClient", + "Presets", "PrivateEndpoints", "PurgeArtifactsMetadata", "PurgeArtifactsRequest", @@ -929,6 +942,9 @@ "UpdateEndpointRequest", "UpdateEntityTypeRequest", "UpdateExecutionRequest", + "UpdateExplanationDatasetOperationMetadata", + "UpdateExplanationDatasetRequest", + "UpdateExplanationDatasetResponse", "UpdateFeatureRequest", "UpdateFeaturestoreOperationMetadata", "UpdateFeaturestoreRequest", diff --git a/google/cloud/aiplatform_v1beta1/gapic_metadata.json b/google/cloud/aiplatform_v1beta1/gapic_metadata.json index 8786a28c47..777e311ce7 100644 --- a/google/cloud/aiplatform_v1beta1/gapic_metadata.json +++ b/google/cloud/aiplatform_v1beta1/gapic_metadata.json @@ -1326,6 +1326,11 @@ "merge_version_aliases" ] }, + "UpdateExplanationDataset": { + "methods": [ + "update_explanation_dataset" + ] + }, "UpdateModel": { "methods": [ "update_model" @@ -1401,6 +1406,11 @@ "merge_version_aliases" ] }, + "UpdateExplanationDataset": { + "methods": [ + "update_explanation_dataset" + ] + }, "UpdateModel": { "methods": [ "update_model" diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/model_service/async_client.py index 961278f9e0..5183fbed2e 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/async_client.py @@ -394,6 +394,17 @@ async def sample_get_model(): Required. The name of the Model resource. Format: ``projects/{project}/locations/{location}/models/{model}`` + In order to retrieve a specific version of the model, + also provide the version ID or version alias. Example: + ``projects/{project}/locations/{location}/models/{model}@2`` + or + ``projects/{project}/locations/{location}/models/{model}@golden`` + If no version ID or alias is specified, the "default" + version will be returned. The "default" version alias is + created for the first version of the model, and can be + moved to other versions later on. There will be exactly + one default version. + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -796,6 +807,120 @@ async def sample_update_model(): # Done; return the response. return response + async def update_explanation_dataset( + self, + request: Union[model_service.UpdateExplanationDatasetRequest, dict] = None, + *, + model: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> operation_async.AsyncOperation: + r"""Incrementally update the dataset used for an examples + model. + + .. code-block:: python + + from google.cloud import aiplatform_v1beta1 + + async def sample_update_explanation_dataset(): + # Create a client + client = aiplatform_v1beta1.ModelServiceAsyncClient() + + # Initialize request argument(s) + request = aiplatform_v1beta1.UpdateExplanationDatasetRequest( + model="model_value", + ) + + # Make the request + operation = client.update_explanation_dataset(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateExplanationDatasetRequest, dict]): + The request object. Request message for + [ModelService.UpdateExplanationDataset][google.cloud.aiplatform.v1beta1.ModelService.UpdateExplanationDataset]. + model (:class:`str`): + Required. The resource name of the Model to update. + Format: + ``projects/{project}/locations/{location}/models/{model}`` + + This corresponds to the ``model`` 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.api_core.operation_async.AsyncOperation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.aiplatform_v1beta1.types.UpdateExplanationDatasetResponse` + Response message of + [ModelService.UpdateExplanationDataset][google.cloud.aiplatform.v1beta1.ModelService.UpdateExplanationDataset] + operation. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([model]) + 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 = model_service.UpdateExplanationDatasetRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if model is not None: + request.model = model + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_explanation_dataset, + 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((("model", request.model),)), + ) + + # 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, + model_service.UpdateExplanationDatasetResponse, + metadata_type=model_service.UpdateExplanationDatasetOperationMetadata, + ) + + # Done; return the response. + return response + async def delete_model( self, request: Union[model_service.DeleteModelRequest, dict] = None, @@ -1218,7 +1343,11 @@ async def sample_export_model(): [ModelService.ExportModel][google.cloud.aiplatform.v1beta1.ModelService.ExportModel]. name (:class:`str`): Required. The resource name of the - Model to export. + Model to export. The resource name may + contain version id or version alias to + specify the version, if no version is + specified, the default version will be + exported. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/client.py b/google/cloud/aiplatform_v1beta1/services/model_service/client.py index 02acd097e1..1cecdc485c 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/client.py @@ -698,6 +698,17 @@ def sample_get_model(): Required. The name of the Model resource. Format: ``projects/{project}/locations/{location}/models/{model}`` + In order to retrieve a specific version of the model, + also provide the version ID or version alias. Example: + ``projects/{project}/locations/{location}/models/{model}@2`` + or + ``projects/{project}/locations/{location}/models/{model}@golden`` + If no version ID or alias is specified, the "default" + version will be returned. The "default" version alias is + created for the first version of the model, and can be + moved to other versions later on. There will be exactly + one default version. + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -1100,6 +1111,122 @@ def sample_update_model(): # Done; return the response. return response + def update_explanation_dataset( + self, + request: Union[model_service.UpdateExplanationDatasetRequest, dict] = None, + *, + model: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> gac_operation.Operation: + r"""Incrementally update the dataset used for an examples + model. + + .. code-block:: python + + from google.cloud import aiplatform_v1beta1 + + def sample_update_explanation_dataset(): + # Create a client + client = aiplatform_v1beta1.ModelServiceClient() + + # Initialize request argument(s) + request = aiplatform_v1beta1.UpdateExplanationDatasetRequest( + model="model_value", + ) + + # Make the request + operation = client.update_explanation_dataset(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.aiplatform_v1beta1.types.UpdateExplanationDatasetRequest, dict]): + The request object. Request message for + [ModelService.UpdateExplanationDataset][google.cloud.aiplatform.v1beta1.ModelService.UpdateExplanationDataset]. + model (str): + Required. The resource name of the Model to update. + Format: + ``projects/{project}/locations/{location}/models/{model}`` + + This corresponds to the ``model`` 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.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.aiplatform_v1beta1.types.UpdateExplanationDatasetResponse` + Response message of + [ModelService.UpdateExplanationDataset][google.cloud.aiplatform.v1beta1.ModelService.UpdateExplanationDataset] + operation. + + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([model]) + 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 model_service.UpdateExplanationDatasetRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, model_service.UpdateExplanationDatasetRequest): + request = model_service.UpdateExplanationDatasetRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if model is not None: + request.model = model + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.update_explanation_dataset + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("model", request.model),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Wrap the response in an operation future. + response = gac_operation.from_gapic( + response, + self._transport.operations_client, + model_service.UpdateExplanationDatasetResponse, + metadata_type=model_service.UpdateExplanationDatasetOperationMetadata, + ) + + # Done; return the response. + return response + def delete_model( self, request: Union[model_service.DeleteModelRequest, dict] = None, @@ -1522,7 +1649,11 @@ def sample_export_model(): [ModelService.ExportModel][google.cloud.aiplatform.v1beta1.ModelService.ExportModel]. name (str): Required. The resource name of the - Model to export. + Model to export. The resource name may + contain version id or version alias to + specify the version, if no version is + specified, the default version will be + exported. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this 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 232a8945bd..60718e8ef9 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/transports/base.py @@ -155,6 +155,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=5.0, client_info=client_info, ), + self.update_explanation_dataset: gapic_v1.method.wrap_method( + self.update_explanation_dataset, + default_timeout=None, + client_info=client_info, + ), self.delete_model: gapic_v1.method.wrap_method( self.delete_model, default_timeout=5.0, @@ -266,6 +271,15 @@ def update_model( ]: raise NotImplementedError() + @property + def update_explanation_dataset( + self, + ) -> Callable[ + [model_service.UpdateExplanationDatasetRequest], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], + ]: + raise NotImplementedError() + @property def delete_model( self, 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 9e7c5971a4..55aeb13351 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc.py @@ -382,6 +382,35 @@ def update_model( ) return self._stubs["update_model"] + @property + def update_explanation_dataset( + self, + ) -> Callable[ + [model_service.UpdateExplanationDatasetRequest], operations_pb2.Operation + ]: + r"""Return a callable for the update explanation dataset method over gRPC. + + Incrementally update the dataset used for an examples + model. + + Returns: + Callable[[~.UpdateExplanationDatasetRequest], + ~.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 "update_explanation_dataset" not in self._stubs: + self._stubs["update_explanation_dataset"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1beta1.ModelService/UpdateExplanationDataset", + request_serializer=model_service.UpdateExplanationDatasetRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_explanation_dataset"] + @property def delete_model( self, 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 e88c9094aa..eafeb60964 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 @@ -393,6 +393,36 @@ def update_model( ) return self._stubs["update_model"] + @property + def update_explanation_dataset( + self, + ) -> Callable[ + [model_service.UpdateExplanationDatasetRequest], + Awaitable[operations_pb2.Operation], + ]: + r"""Return a callable for the update explanation dataset method over gRPC. + + Incrementally update the dataset used for an examples + model. + + Returns: + Callable[[~.UpdateExplanationDatasetRequest], + 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 "update_explanation_dataset" not in self._stubs: + self._stubs["update_explanation_dataset"] = self.grpc_channel.unary_unary( + "/google.cloud.aiplatform.v1beta1.ModelService/UpdateExplanationDataset", + request_serializer=model_service.UpdateExplanationDatasetRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs["update_explanation_dataset"] + @property def delete_model( self, diff --git a/google/cloud/aiplatform_v1beta1/types/__init__.py b/google/cloud/aiplatform_v1beta1/types/__init__.py index be1d312971..3a46e1f5c2 100644 --- a/google/cloud/aiplatform_v1beta1/types/__init__.py +++ b/google/cloud/aiplatform_v1beta1/types/__init__.py @@ -119,6 +119,8 @@ Attribution, BlurBaselineConfig, Examples, + ExamplesOverride, + ExamplesRestrictionsNamespace, Explanation, ExplanationMetadataOverride, ExplanationParameters, @@ -127,6 +129,8 @@ FeatureNoiseSigma, IntegratedGradientsAttribution, ModelExplanation, + Neighbor, + Presets, SampledShapleyAttribution, SmoothGradConfig, XraiAttribution, @@ -414,6 +418,9 @@ ListModelVersionsRequest, ListModelVersionsResponse, MergeVersionAliasesRequest, + UpdateExplanationDatasetOperationMetadata, + UpdateExplanationDatasetRequest, + UpdateExplanationDatasetResponse, UpdateModelRequest, UploadModelOperationMetadata, UploadModelRequest, @@ -650,6 +657,8 @@ "Attribution", "BlurBaselineConfig", "Examples", + "ExamplesOverride", + "ExamplesRestrictionsNamespace", "Explanation", "ExplanationMetadataOverride", "ExplanationParameters", @@ -658,6 +667,8 @@ "FeatureNoiseSigma", "IntegratedGradientsAttribution", "ModelExplanation", + "Neighbor", + "Presets", "SampledShapleyAttribution", "SmoothGradConfig", "XraiAttribution", @@ -888,12 +899,16 @@ "ListModelVersionsRequest", "ListModelVersionsResponse", "MergeVersionAliasesRequest", + "UpdateExplanationDatasetOperationMetadata", + "UpdateExplanationDatasetRequest", + "UpdateExplanationDatasetResponse", "UpdateModelRequest", "UploadModelOperationMetadata", "UploadModelRequest", "UploadModelResponse", "DeleteOperationMetadata", "GenericOperationMetadata", + "PipelineFailurePolicy", "PipelineJob", "PipelineJobDetail", "PipelineTaskDetail", diff --git a/google/cloud/aiplatform_v1beta1/types/batch_prediction_job.py b/google/cloud/aiplatform_v1beta1/types/batch_prediction_job.py index 2b54b55692..7c0a3a02ce 100644 --- a/google/cloud/aiplatform_v1beta1/types/batch_prediction_job.py +++ b/google/cloud/aiplatform_v1beta1/types/batch_prediction_job.py @@ -64,6 +64,10 @@ class BatchPredictionJob(proto.Message): Starting this job has no impact on any existing deployments of the Model and their resources. Exactly one of model and unmanaged_container_model must be set. + + The model resource name may contain version id or version + alias to specify the version, if no version is specified, + the default version will be used. model_version_id (str): Output only. The version ID of the Model that produces the predictions via this job. diff --git a/google/cloud/aiplatform_v1beta1/types/completion_stats.py b/google/cloud/aiplatform_v1beta1/types/completion_stats.py index 5a58d6a06b..3ab6b8dc1a 100644 --- a/google/cloud/aiplatform_v1beta1/types/completion_stats.py +++ b/google/cloud/aiplatform_v1beta1/types/completion_stats.py @@ -44,6 +44,11 @@ class CompletionStats(proto.Message): Set to -1 if the number is unknown (for example, the operation failed before the total entity number could be collected). + successful_forecast_point_count (int): + Output only. The number of the successful + forecast points that are generated by the + forecasting model. This is ONLY used by the + forecasting batch prediction. """ successful_count = proto.Field( @@ -58,6 +63,10 @@ class CompletionStats(proto.Message): proto.INT64, number=3, ) + successful_forecast_point_count = proto.Field( + proto.INT64, + number=5, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/endpoint.py b/google/cloud/aiplatform_v1beta1/types/endpoint.py index 85ff783e64..fc4fabb8e0 100644 --- a/google/cloud/aiplatform_v1beta1/types/endpoint.py +++ b/google/cloud/aiplatform_v1beta1/types/endpoint.py @@ -223,10 +223,14 @@ class DeployedModel(proto.Message): This value should be 1-10 characters, and valid characters are /[0-9]/. model (str): - Required. The name of the Model that this is - the deployment of. Note that the Model may be in - a different location than the DeployedModel's - Endpoint. + Required. The resource name of the Model that + this is the deployment of. Note that the Model + may be in a different location than the + DeployedModel's Endpoint. + The resource name may contain version id or + version alias to specify the version, if no + version is specified, the default version will + be deployed. model_version_id (str): Output only. The version ID of the model that is deployed. diff --git a/google/cloud/aiplatform_v1beta1/types/explanation.py b/google/cloud/aiplatform_v1beta1/types/explanation.py index 2a81fe19ca..a276c39b41 100644 --- a/google/cloud/aiplatform_v1beta1/types/explanation.py +++ b/google/cloud/aiplatform_v1beta1/types/explanation.py @@ -26,6 +26,7 @@ "Explanation", "ModelExplanation", "Attribution", + "Neighbor", "ExplanationSpec", "ExplanationParameters", "SampledShapleyAttribution", @@ -35,8 +36,11 @@ "FeatureNoiseSigma", "BlurBaselineConfig", "Examples", + "Presets", "ExplanationSpecOverride", "ExplanationMetadataOverride", + "ExamplesOverride", + "ExamplesRestrictionsNamespace", }, ) @@ -71,6 +75,13 @@ class Explanation(proto.Message): is specified, the attributions are stored by [Attribution.output_index][google.cloud.aiplatform.v1beta1.Attribution.output_index] in the same order as they appear in the output_indices. + neighbors (Sequence[google.cloud.aiplatform_v1beta1.types.Neighbor]): + Output only. List of the nearest neighbors + for example-based explanations. + For models deployed with the examples + explanations feature enabled, the attributions + field is empty and instead the neighbors field + is populated. """ attributions = proto.RepeatedField( @@ -78,6 +89,11 @@ class Explanation(proto.Message): number=1, message="Attribution", ) + neighbors = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="Neighbor", + ) class ModelExplanation(proto.Message): @@ -268,6 +284,26 @@ class Attribution(proto.Message): ) +class Neighbor(proto.Message): + r"""Neighbors for example-based explanations. + + Attributes: + neighbor_id (str): + Output only. The neighbor id. + neighbor_distance (float): + Output only. The neighbor distance. + """ + + neighbor_id = proto.Field( + proto.STRING, + number=1, + ) + neighbor_distance = proto.Field( + proto.DOUBLE, + number=2, + ) + + class ExplanationSpec(proto.Message): r"""Specification of Model explanation. @@ -656,35 +692,97 @@ class Examples(proto.Message): r"""Example-based explainability that returns the nearest neighbors from the provided dataset. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: - gcs_source (google.cloud.aiplatform_v1beta1.types.GcsSource): - The Cloud Storage location for the input - instances. nearest_neighbor_search_config (google.protobuf.struct_pb2.Value): The configuration for the generated index, the semantics are the same as [metadata][google.cloud.aiplatform.v1beta1.Index.metadata] and should match NearestNeighborSearchConfig. + + This field is a member of `oneof`_ ``config``. + presets (google.cloud.aiplatform_v1beta1.types.Presets): + Preset config based on the desired query + speed-precision trade-off and modality + + This field is a member of `oneof`_ ``config``. + gcs_source (google.cloud.aiplatform_v1beta1.types.GcsSource): + The Cloud Storage location for the input + instances. neighbor_count (int): The number of neighbors to return. """ - gcs_source = proto.Field( - proto.MESSAGE, - number=1, - message=io.GcsSource, - ) nearest_neighbor_search_config = proto.Field( proto.MESSAGE, number=2, + oneof="config", message=struct_pb2.Value, ) + presets = proto.Field( + proto.MESSAGE, + number=4, + oneof="config", + message="Presets", + ) + gcs_source = proto.Field( + proto.MESSAGE, + number=1, + message=io.GcsSource, + ) neighbor_count = proto.Field( proto.INT32, number=3, ) +class Presets(proto.Message): + r"""Preset configuration for example-based explanations + + Attributes: + query (google.cloud.aiplatform_v1beta1.types.Presets.Query): + Preset option controlling parameters for + query speed-precision trade-off + + This field is a member of `oneof`_ ``_query``. + modality (google.cloud.aiplatform_v1beta1.types.Presets.Modality): + Preset option controlling parameters for + different modalities + """ + + class Query(proto.Enum): + r"""Preset option controlling parameters for query + speed-precision trade-off + """ + PRECISE = 0 + FAST = 1 + + class Modality(proto.Enum): + r"""Preset option controlling parameters for different modalities""" + MODALITY_UNSPECIFIED = 0 + IMAGE = 1 + TEXT = 2 + TABULAR = 3 + + query = proto.Field( + proto.ENUM, + number=1, + optional=True, + enum=Query, + ) + modality = proto.Field( + proto.ENUM, + number=2, + enum=Modality, + ) + + class ExplanationSpecOverride(proto.Message): r"""The [ExplanationSpec][google.cloud.aiplatform.v1beta1.ExplanationSpec] @@ -701,6 +799,9 @@ class ExplanationSpecOverride(proto.Message): metadata (google.cloud.aiplatform_v1beta1.types.ExplanationMetadataOverride): The metadata to be overridden. If not specified, no metadata is overridden. + examples_override (google.cloud.aiplatform_v1beta1.types.ExamplesOverride): + The example-based explanations parameter + overrides. """ parameters = proto.Field( @@ -713,6 +814,11 @@ class ExplanationSpecOverride(proto.Message): number=2, message="ExplanationMetadataOverride", ) + examples_override = proto.Field( + proto.MESSAGE, + number=3, + message="ExamplesOverride", + ) class ExplanationMetadataOverride(proto.Message): @@ -763,4 +869,81 @@ class InputMetadataOverride(proto.Message): ) +class ExamplesOverride(proto.Message): + r"""Overrides for example-based explanations. + + Attributes: + neighbor_count (int): + The number of neighbors to return. + crowding_count (int): + The number of neighbors to return that have + the same crowding tag. + restrictions (Sequence[google.cloud.aiplatform_v1beta1.types.ExamplesRestrictionsNamespace]): + Restrict the resulting nearest neighbors to + respect these constraints. + return_embeddings (bool): + If true, return the embeddings instead of + neighbors. + data_format (google.cloud.aiplatform_v1beta1.types.ExamplesOverride.DataFormat): + The format of the data being provided with + each call. + """ + + class DataFormat(proto.Enum): + r"""Data format enum.""" + DATA_FORMAT_UNSPECIFIED = 0 + INSTANCES = 1 + EMBEDDINGS = 2 + + neighbor_count = proto.Field( + proto.INT32, + number=1, + ) + crowding_count = proto.Field( + proto.INT32, + number=2, + ) + restrictions = proto.RepeatedField( + proto.MESSAGE, + number=3, + message="ExamplesRestrictionsNamespace", + ) + return_embeddings = proto.Field( + proto.BOOL, + number=4, + ) + data_format = proto.Field( + proto.ENUM, + number=5, + enum=DataFormat, + ) + + +class ExamplesRestrictionsNamespace(proto.Message): + r"""Restrictions namespace for example-based explanations + overrides. + + Attributes: + namespace_name (str): + The namespace name. + allow (Sequence[str]): + The list of allowed tags. + deny (Sequence[str]): + The list of deny tags. + """ + + namespace_name = proto.Field( + proto.STRING, + number=1, + ) + allow = proto.RepeatedField( + proto.STRING, + number=2, + ) + deny = proto.RepeatedField( + proto.STRING, + number=3, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/explanation_metadata.py b/google/cloud/aiplatform_v1beta1/types/explanation_metadata.py index 230b9b0af1..e70c882d50 100644 --- a/google/cloud/aiplatform_v1beta1/types/explanation_metadata.py +++ b/google/cloud/aiplatform_v1beta1/types/explanation_metadata.py @@ -69,6 +69,9 @@ class ExplanationMetadata(proto.Message): including the URI scheme, than the one given on input. The output URI will point to a location where the user only has a read access. + latent_space_source (str): + Name of the source to generate embeddings for + example based explanations. """ class InputMetadata(proto.Message): @@ -457,6 +460,10 @@ class OutputMetadata(proto.Message): proto.STRING, number=3, ) + latent_space_source = proto.Field( + proto.STRING, + number=5, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/featurestore_online_service.py b/google/cloud/aiplatform_v1beta1/types/featurestore_online_service.py index f6cb04de3f..b153d6be49 100644 --- a/google/cloud/aiplatform_v1beta1/types/featurestore_online_service.py +++ b/google/cloud/aiplatform_v1beta1/types/featurestore_online_service.py @@ -238,7 +238,6 @@ class StreamingReadFeatureValuesRequest(proto.Message): class FeatureValue(proto.Message): r"""Value for a feature. - NEXT ID: 15 This message has `oneof`_ fields (mutually exclusive fields). For each oneof, at most one member field can be set at the same time. diff --git a/google/cloud/aiplatform_v1beta1/types/manual_batch_tuning_parameters.py b/google/cloud/aiplatform_v1beta1/types/manual_batch_tuning_parameters.py index d1c6a65a7f..13fc2ace35 100644 --- a/google/cloud/aiplatform_v1beta1/types/manual_batch_tuning_parameters.py +++ b/google/cloud/aiplatform_v1beta1/types/manual_batch_tuning_parameters.py @@ -38,7 +38,7 @@ class ManualBatchTuningParameters(proto.Message): value will result in a whole batch not fitting in a machine's memory, and the whole operation will fail. - The default value is 4. + The default value is 64. """ batch_size = proto.Field( diff --git a/google/cloud/aiplatform_v1beta1/types/model_evaluation.py b/google/cloud/aiplatform_v1beta1/types/model_evaluation.py index 3ca2944a50..f1da0263e7 100644 --- a/google/cloud/aiplatform_v1beta1/types/model_evaluation.py +++ b/google/cloud/aiplatform_v1beta1/types/model_evaluation.py @@ -37,6 +37,8 @@ class ModelEvaluation(proto.Message): name (str): Output only. The resource name of the ModelEvaluation. + display_name (str): + The display name of the ModelEvaluation. metrics_schema_uri (str): Points to a YAML file stored on Google Cloud Storage describing the @@ -70,6 +72,11 @@ class ModelEvaluation(proto.Message): [ExplanationSpec][google.cloud.aiplatform.v1beta1.ExplanationSpec] that are used for explaining the predicted values on the evaluated data. + metadata (google.protobuf.struct_pb2.Value): + The metadata of the ModelEvaluation. For the ModelEvaluation + uploaded from Managed Pipeline, metadata contains a + structured value with keys of "pipeline_job_id", + "evaluation_dataset_type", "evaluation_dataset_path". """ class ModelEvaluationExplanationSpec(proto.Message): @@ -101,6 +108,10 @@ class ModelEvaluationExplanationSpec(proto.Message): proto.STRING, number=1, ) + display_name = proto.Field( + proto.STRING, + number=10, + ) metrics_schema_uri = proto.Field( proto.STRING, number=2, @@ -129,6 +140,11 @@ class ModelEvaluationExplanationSpec(proto.Message): number=9, message=ModelEvaluationExplanationSpec, ) + metadata = proto.Field( + proto.MESSAGE, + number=11, + message=struct_pb2.Value, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/model_monitoring.py b/google/cloud/aiplatform_v1beta1/types/model_monitoring.py index e347fe7785..8ec55cce08 100644 --- a/google/cloud/aiplatform_v1beta1/types/model_monitoring.py +++ b/google/cloud/aiplatform_v1beta1/types/model_monitoring.py @@ -84,6 +84,8 @@ class TrainingDataset(proto.Message): "csv" The source file is a CSV file. + "jsonl" + The source file is a JSONL file. target_field (str): The target field name the model is to predict. This field will be excluded when doing diff --git a/google/cloud/aiplatform_v1beta1/types/model_service.py b/google/cloud/aiplatform_v1beta1/types/model_service.py index 5aaadd0376..88560ebb84 100644 --- a/google/cloud/aiplatform_v1beta1/types/model_service.py +++ b/google/cloud/aiplatform_v1beta1/types/model_service.py @@ -15,6 +15,7 @@ # import proto # type: ignore +from google.cloud.aiplatform_v1beta1.types import explanation from google.cloud.aiplatform_v1beta1.types import io from google.cloud.aiplatform_v1beta1.types import model as gca_model from google.cloud.aiplatform_v1beta1.types import ( @@ -37,11 +38,14 @@ "ListModelVersionsRequest", "ListModelVersionsResponse", "UpdateModelRequest", + "UpdateExplanationDatasetRequest", + "UpdateExplanationDatasetOperationMetadata", "DeleteModelRequest", "DeleteModelVersionRequest", "MergeVersionAliasesRequest", "ExportModelRequest", "ExportModelOperationMetadata", + "UpdateExplanationDatasetResponse", "ExportModelResponse", "ImportModelEvaluationRequest", "GetModelEvaluationRequest", @@ -146,6 +150,17 @@ class GetModelRequest(proto.Message): name (str): Required. The name of the Model resource. Format: ``projects/{project}/locations/{location}/models/{model}`` + + In order to retrieve a specific version of the model, also + provide the version ID or version alias. Example: + ``projects/{project}/locations/{location}/models/{model}@2`` + or + ``projects/{project}/locations/{location}/models/{model}@golden`` + If no version ID or alias is specified, the "default" + version will be returned. The "default" version alias is + created for the first version of the model, and can be moved + to other versions later on. There will be exactly one + default version. """ name = proto.Field( @@ -377,6 +392,46 @@ class UpdateModelRequest(proto.Message): ) +class UpdateExplanationDatasetRequest(proto.Message): + r"""Request message for + [ModelService.UpdateExplanationDataset][google.cloud.aiplatform.v1beta1.ModelService.UpdateExplanationDataset]. + + Attributes: + model (str): + Required. The resource name of the Model to update. Format: + ``projects/{project}/locations/{location}/models/{model}`` + examples (google.cloud.aiplatform_v1beta1.types.Examples): + The example config containing the location of + the dataset. + """ + + model = proto.Field( + proto.STRING, + number=1, + ) + examples = proto.Field( + proto.MESSAGE, + number=2, + message=explanation.Examples, + ) + + +class UpdateExplanationDatasetOperationMetadata(proto.Message): + r"""Runtime operation information for + [ModelService.UpdateExplanationDataset][google.cloud.aiplatform.v1beta1.ModelService.UpdateExplanationDataset]. + + Attributes: + generic_metadata (google.cloud.aiplatform_v1beta1.types.GenericOperationMetadata): + The common part of the operation metadata. + """ + + generic_metadata = proto.Field( + proto.MESSAGE, + number=1, + message=operation.GenericOperationMetadata, + ) + + class DeleteModelRequest(proto.Message): r"""Request message for [ModelService.DeleteModel][google.cloud.aiplatform.v1beta1.ModelService.DeleteModel]. @@ -457,7 +512,10 @@ class ExportModelRequest(proto.Message): Attributes: name (str): Required. The resource name of the Model to - export. + export. The resource name may contain version id + or version alias to specify the version, if no + version is specified, the default version will + be exported. output_config (google.cloud.aiplatform_v1beta1.types.ExportModelRequest.OutputConfig): Required. The desired output location and configuration. @@ -569,6 +627,14 @@ class OutputInfo(proto.Message): ) +class UpdateExplanationDatasetResponse(proto.Message): + r"""Response message of + [ModelService.UpdateExplanationDataset][google.cloud.aiplatform.v1beta1.ModelService.UpdateExplanationDataset] + operation. + + """ + + class ExportModelResponse(proto.Message): r"""Response message of [ModelService.ExportModel][google.cloud.aiplatform.v1beta1.ModelService.ExportModel] diff --git a/google/cloud/aiplatform_v1beta1/types/pipeline_failure_policy.py b/google/cloud/aiplatform_v1beta1/types/pipeline_failure_policy.py new file mode 100644 index 0000000000..d528bce8a1 --- /dev/null +++ b/google/cloud/aiplatform_v1beta1/types/pipeline_failure_policy.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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 + + +__protobuf__ = proto.module( + package="google.cloud.aiplatform.v1beta1", + manifest={ + "PipelineFailurePolicy", + }, +) + + +class PipelineFailurePolicy(proto.Enum): + r"""Represents the failure policy of a pipeline. Currently, the default + of a pipeline is that the pipeline will continue to run until no + more tasks can be executed, also known as + PIPELINE_FAILURE_POLICY_FAIL_SLOW. However, if a pipeline is set to + PIPELINE_FAILURE_POLICY_FAIL_FAST, it will stop scheduling any new + tasks when a task has failed. Any scheduled tasks will continue to + completion. + """ + PIPELINE_FAILURE_POLICY_UNSPECIFIED = 0 + PIPELINE_FAILURE_POLICY_FAIL_SLOW = 1 + PIPELINE_FAILURE_POLICY_FAIL_FAST = 2 + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/pipeline_job.py b/google/cloud/aiplatform_v1beta1/types/pipeline_job.py index a43e876a5f..8b0e7d37a1 100644 --- a/google/cloud/aiplatform_v1beta1/types/pipeline_job.py +++ b/google/cloud/aiplatform_v1beta1/types/pipeline_job.py @@ -19,6 +19,7 @@ from google.cloud.aiplatform_v1beta1.types import context from google.cloud.aiplatform_v1beta1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1beta1.types import execution as gca_execution +from google.cloud.aiplatform_v1beta1.types import pipeline_failure_policy from google.cloud.aiplatform_v1beta1.types import pipeline_state from google.cloud.aiplatform_v1beta1.types import value as gca_value from google.protobuf import struct_pb2 # type: ignore @@ -154,6 +155,14 @@ class RuntimeConfig(proto.Message): ``PipelineJob.pipeline_spec.schema_version`` 2.1.0, such as pipelines built using Kubeflow Pipelines SDK 1.9 or higher and the v2 DSL. + failure_policy (google.cloud.aiplatform_v1beta1.types.PipelineFailurePolicy): + Represents the failure policy of a pipeline. Currently, the + default of a pipeline is that the pipeline will continue to + run until no more tasks can be executed, also known as + PIPELINE_FAILURE_POLICY_FAIL_SLOW. However, if a pipeline is + set to PIPELINE_FAILURE_POLICY_FAIL_FAST, it will stop + scheduling any new tasks when a task has failed. Any + scheduled tasks will continue to completion. """ parameters = proto.MapField( @@ -172,6 +181,11 @@ class RuntimeConfig(proto.Message): number=3, message=struct_pb2.Value, ) + failure_policy = proto.Field( + proto.ENUM, + number=4, + enum=pipeline_failure_policy.PipelineFailurePolicy, + ) name = proto.Field( proto.STRING, diff --git a/google/cloud/aiplatform_v1beta1/types/pipeline_service.py b/google/cloud/aiplatform_v1beta1/types/pipeline_service.py index f236fa402f..3a084f10b6 100644 --- a/google/cloud/aiplatform_v1beta1/types/pipeline_service.py +++ b/google/cloud/aiplatform_v1beta1/types/pipeline_service.py @@ -288,8 +288,8 @@ class ListPipelineJobsRequest(proto.Message): - ``labels``: Supports key-value equality and key presence. - ``template_uri``: Supports ``=``, ``!=`` comparisons, and ``:`` wildcard. - - ``template_metadata.version_name``: Supports ``=``, - ``!=`` comparisons, and ``:`` wildcard. + - ``template_metadata.version``: Supports ``=``, ``!=`` + comparisons, and ``:`` wildcard. Filter expressions can be combined together using logical operators (``AND`` & ``OR``). For example: diff --git a/samples/generated_samples/aiplatform_v1beta1_generated_model_service_update_explanation_dataset_async.py b/samples/generated_samples/aiplatform_v1beta1_generated_model_service_update_explanation_dataset_async.py new file mode 100644 index 0000000000..cc070a4f30 --- /dev/null +++ b/samples/generated_samples/aiplatform_v1beta1_generated_model_service_update_explanation_dataset_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateExplanationDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-aiplatform + + +# [START aiplatform_v1beta1_generated_ModelService_UpdateExplanationDataset_async] +from google.cloud import aiplatform_v1beta1 + + +async def sample_update_explanation_dataset(): + # Create a client + client = aiplatform_v1beta1.ModelServiceAsyncClient() + + # Initialize request argument(s) + request = aiplatform_v1beta1.UpdateExplanationDatasetRequest( + model="model_value", + ) + + # Make the request + operation = client.update_explanation_dataset(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END aiplatform_v1beta1_generated_ModelService_UpdateExplanationDataset_async] diff --git a/samples/generated_samples/aiplatform_v1beta1_generated_model_service_update_explanation_dataset_sync.py b/samples/generated_samples/aiplatform_v1beta1_generated_model_service_update_explanation_dataset_sync.py new file mode 100644 index 0000000000..3f17d7ca8d --- /dev/null +++ b/samples/generated_samples/aiplatform_v1beta1_generated_model_service_update_explanation_dataset_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateExplanationDataset +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-aiplatform + + +# [START aiplatform_v1beta1_generated_ModelService_UpdateExplanationDataset_sync] +from google.cloud import aiplatform_v1beta1 + + +def sample_update_explanation_dataset(): + # Create a client + client = aiplatform_v1beta1.ModelServiceClient() + + # Initialize request argument(s) + request = aiplatform_v1beta1.UpdateExplanationDatasetRequest( + model="model_value", + ) + + # Make the request + operation = client.update_explanation_dataset(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END aiplatform_v1beta1_generated_ModelService_UpdateExplanationDataset_sync] diff --git a/samples/generated_samples/snippet_metadata_aiplatform_v1beta1.json b/samples/generated_samples/snippet_metadata_aiplatform_v1beta1.json index 99cdb25b68..0d4c8a0532 100644 --- a/samples/generated_samples/snippet_metadata_aiplatform_v1beta1.json +++ b/samples/generated_samples/snippet_metadata_aiplatform_v1beta1.json @@ -20571,6 +20571,167 @@ ], "title": "aiplatform_v1beta1_generated_model_service_merge_version_aliases_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.aiplatform_v1beta1.ModelServiceAsyncClient", + "shortName": "ModelServiceAsyncClient" + }, + "fullName": "google.cloud.aiplatform_v1beta1.ModelServiceAsyncClient.update_explanation_dataset", + "method": { + "fullName": "google.cloud.aiplatform.v1beta1.ModelService.UpdateExplanationDataset", + "service": { + "fullName": "google.cloud.aiplatform.v1beta1.ModelService", + "shortName": "ModelService" + }, + "shortName": "UpdateExplanationDataset" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.aiplatform_v1beta1.types.UpdateExplanationDatasetRequest" + }, + { + "name": "model", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_explanation_dataset" + }, + "description": "Sample for UpdateExplanationDataset", + "file": "aiplatform_v1beta1_generated_model_service_update_explanation_dataset_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "aiplatform_v1beta1_generated_ModelService_UpdateExplanationDataset_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ], + "title": "aiplatform_v1beta1_generated_model_service_update_explanation_dataset_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.aiplatform_v1beta1.ModelServiceClient", + "shortName": "ModelServiceClient" + }, + "fullName": "google.cloud.aiplatform_v1beta1.ModelServiceClient.update_explanation_dataset", + "method": { + "fullName": "google.cloud.aiplatform.v1beta1.ModelService.UpdateExplanationDataset", + "service": { + "fullName": "google.cloud.aiplatform.v1beta1.ModelService", + "shortName": "ModelService" + }, + "shortName": "UpdateExplanationDataset" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.aiplatform_v1beta1.types.UpdateExplanationDatasetRequest" + }, + { + "name": "model", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_explanation_dataset" + }, + "description": "Sample for UpdateExplanationDataset", + "file": "aiplatform_v1beta1_generated_model_service_update_explanation_dataset_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "aiplatform_v1beta1_generated_ModelService_UpdateExplanationDataset_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ], + "title": "aiplatform_v1beta1_generated_model_service_update_explanation_dataset_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/tests/unit/gapic/aiplatform_v1/test_dataset_service.py b/tests/unit/gapic/aiplatform_v1/test_dataset_service.py index f46c4ec2e1..15b5143fbb 100644 --- a/tests/unit/gapic/aiplatform_v1/test_dataset_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_dataset_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1/test_endpoint_service.py b/tests/unit/gapic/aiplatform_v1/test_endpoint_service.py index 7a6b3792af..c1e7478183 100644 --- a/tests/unit/gapic/aiplatform_v1/test_endpoint_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_endpoint_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1/test_featurestore_online_serving_service.py b/tests/unit/gapic/aiplatform_v1/test_featurestore_online_serving_service.py index 906e745604..23a073890c 100644 --- a/tests/unit/gapic/aiplatform_v1/test_featurestore_online_serving_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_featurestore_online_serving_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1/test_featurestore_service.py b/tests/unit/gapic/aiplatform_v1/test_featurestore_service.py index ac236b5eb5..1a8c648044 100644 --- a/tests/unit/gapic/aiplatform_v1/test_featurestore_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_featurestore_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1/test_index_endpoint_service.py b/tests/unit/gapic/aiplatform_v1/test_index_endpoint_service.py index 3a2f967be0..19b768a38c 100644 --- a/tests/unit/gapic/aiplatform_v1/test_index_endpoint_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_index_endpoint_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1/test_index_service.py b/tests/unit/gapic/aiplatform_v1/test_index_service.py index f26c29e405..50635f9d66 100644 --- a/tests/unit/gapic/aiplatform_v1/test_index_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_index_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1/test_job_service.py b/tests/unit/gapic/aiplatform_v1/test_job_service.py index c02439e56a..658b29d607 100644 --- a/tests/unit/gapic/aiplatform_v1/test_job_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_job_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1/test_metadata_service.py b/tests/unit/gapic/aiplatform_v1/test_metadata_service.py index 150b4c8ab1..1136c8c23b 100644 --- a/tests/unit/gapic/aiplatform_v1/test_metadata_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_metadata_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1/test_migration_service.py b/tests/unit/gapic/aiplatform_v1/test_migration_service.py index 2d38e9a189..0072bf2e0c 100644 --- a/tests/unit/gapic/aiplatform_v1/test_migration_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_migration_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -1933,19 +1939,22 @@ def test_parse_annotated_dataset_path(): def test_dataset_path(): project = "cuttlefish" - dataset = "mussel" - expected = "projects/{project}/datasets/{dataset}".format( + location = "mussel" + dataset = "winkle" + 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", - "dataset": "nautilus", + "project": "nautilus", + "location": "scallop", + "dataset": "abalone", } path = MigrationServiceClient.dataset_path(**expected) @@ -1955,22 +1964,19 @@ def test_parse_dataset_path(): def test_dataset_path(): - project = "scallop" - location = "abalone" - dataset = "squid" - expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( + project = "squid" + dataset = "clam" + expected = "projects/{project}/datasets/{dataset}".format( project=project, - location=location, 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": "clam", - "location": "whelk", + "project": "whelk", "dataset": "octopus", } path = MigrationServiceClient.dataset_path(**expected) diff --git a/tests/unit/gapic/aiplatform_v1/test_model_service.py b/tests/unit/gapic/aiplatform_v1/test_model_service.py index a02df4c752..aa6029b483 100644 --- a/tests/unit/gapic/aiplatform_v1/test_model_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_model_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -2384,6 +2390,7 @@ def test_import_model_evaluation(request_type, transport: str = "grpc"): # Designate an appropriate return value for the call. call.return_value = gca_model_evaluation.ModelEvaluation( name="name_value", + display_name="display_name_value", metrics_schema_uri="metrics_schema_uri_value", slice_dimensions=["slice_dimensions_value"], data_item_schema_uri="data_item_schema_uri_value", @@ -2399,6 +2406,7 @@ def test_import_model_evaluation(request_type, transport: str = "grpc"): # Establish that the response is the type that we expect. assert isinstance(response, gca_model_evaluation.ModelEvaluation) assert response.name == "name_value" + assert response.display_name == "display_name_value" assert response.metrics_schema_uri == "metrics_schema_uri_value" assert response.slice_dimensions == ["slice_dimensions_value"] assert response.data_item_schema_uri == "data_item_schema_uri_value" @@ -2445,6 +2453,7 @@ async def test_import_model_evaluation_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_model_evaluation.ModelEvaluation( name="name_value", + display_name="display_name_value", metrics_schema_uri="metrics_schema_uri_value", slice_dimensions=["slice_dimensions_value"], data_item_schema_uri="data_item_schema_uri_value", @@ -2461,6 +2470,7 @@ async def test_import_model_evaluation_async( # Establish that the response is the type that we expect. assert isinstance(response, gca_model_evaluation.ModelEvaluation) assert response.name == "name_value" + assert response.display_name == "display_name_value" assert response.metrics_schema_uri == "metrics_schema_uri_value" assert response.slice_dimensions == ["slice_dimensions_value"] assert response.data_item_schema_uri == "data_item_schema_uri_value" @@ -2657,6 +2667,7 @@ def test_get_model_evaluation(request_type, transport: str = "grpc"): # Designate an appropriate return value for the call. call.return_value = model_evaluation.ModelEvaluation( name="name_value", + display_name="display_name_value", metrics_schema_uri="metrics_schema_uri_value", slice_dimensions=["slice_dimensions_value"], data_item_schema_uri="data_item_schema_uri_value", @@ -2672,6 +2683,7 @@ def test_get_model_evaluation(request_type, transport: str = "grpc"): # Establish that the response is the type that we expect. assert isinstance(response, model_evaluation.ModelEvaluation) assert response.name == "name_value" + assert response.display_name == "display_name_value" assert response.metrics_schema_uri == "metrics_schema_uri_value" assert response.slice_dimensions == ["slice_dimensions_value"] assert response.data_item_schema_uri == "data_item_schema_uri_value" @@ -2718,6 +2730,7 @@ async def test_get_model_evaluation_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_evaluation.ModelEvaluation( name="name_value", + display_name="display_name_value", metrics_schema_uri="metrics_schema_uri_value", slice_dimensions=["slice_dimensions_value"], data_item_schema_uri="data_item_schema_uri_value", @@ -2734,6 +2747,7 @@ async def test_get_model_evaluation_async( # Establish that the response is the type that we expect. assert isinstance(response, model_evaluation.ModelEvaluation) assert response.name == "name_value" + assert response.display_name == "display_name_value" assert response.metrics_schema_uri == "metrics_schema_uri_value" assert response.slice_dimensions == ["slice_dimensions_value"] assert response.data_item_schema_uri == "data_item_schema_uri_value" diff --git a/tests/unit/gapic/aiplatform_v1/test_pipeline_service.py b/tests/unit/gapic/aiplatform_v1/test_pipeline_service.py index 86a01f4d50..c809b80ed2 100644 --- a/tests/unit/gapic/aiplatform_v1/test_pipeline_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_pipeline_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -52,6 +58,7 @@ from google.cloud.aiplatform_v1.types import io from google.cloud.aiplatform_v1.types import model from google.cloud.aiplatform_v1.types import operation as gca_operation +from google.cloud.aiplatform_v1.types import pipeline_failure_policy from google.cloud.aiplatform_v1.types import pipeline_job from google.cloud.aiplatform_v1.types import pipeline_job as gca_pipeline_job from google.cloud.aiplatform_v1.types import pipeline_service @@ -2163,6 +2170,7 @@ def test_create_pipeline_job(request_type, transport: str = "grpc"): state=pipeline_state.PipelineState.PIPELINE_STATE_QUEUED, service_account="service_account_value", network="network_value", + template_uri="template_uri_value", ) response = client.create_pipeline_job(request) @@ -2178,6 +2186,7 @@ def test_create_pipeline_job(request_type, transport: str = "grpc"): assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED assert response.service_account == "service_account_value" assert response.network == "network_value" + assert response.template_uri == "template_uri_value" def test_create_pipeline_job_empty_call(): @@ -2224,6 +2233,7 @@ async def test_create_pipeline_job_async( state=pipeline_state.PipelineState.PIPELINE_STATE_QUEUED, service_account="service_account_value", network="network_value", + template_uri="template_uri_value", ) ) response = await client.create_pipeline_job(request) @@ -2240,6 +2250,7 @@ async def test_create_pipeline_job_async( assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED assert response.service_account == "service_account_value" assert response.network == "network_value" + assert response.template_uri == "template_uri_value" @pytest.mark.asyncio @@ -2444,6 +2455,7 @@ def test_get_pipeline_job(request_type, transport: str = "grpc"): state=pipeline_state.PipelineState.PIPELINE_STATE_QUEUED, service_account="service_account_value", network="network_value", + template_uri="template_uri_value", ) response = client.get_pipeline_job(request) @@ -2459,6 +2471,7 @@ def test_get_pipeline_job(request_type, transport: str = "grpc"): assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED assert response.service_account == "service_account_value" assert response.network == "network_value" + assert response.template_uri == "template_uri_value" def test_get_pipeline_job_empty_call(): @@ -2500,6 +2513,7 @@ async def test_get_pipeline_job_async( state=pipeline_state.PipelineState.PIPELINE_STATE_QUEUED, service_account="service_account_value", network="network_value", + template_uri="template_uri_value", ) ) response = await client.get_pipeline_job(request) @@ -2516,6 +2530,7 @@ async def test_get_pipeline_job_async( assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED assert response.service_account == "service_account_value" assert response.network == "network_value" + assert response.template_uri == "template_uri_value" @pytest.mark.asyncio diff --git a/tests/unit/gapic/aiplatform_v1/test_prediction_service.py b/tests/unit/gapic/aiplatform_v1/test_prediction_service.py index 2f1813de9f..a6c3c1d5d4 100644 --- a/tests/unit/gapic/aiplatform_v1/test_prediction_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_prediction_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1/test_specialist_pool_service.py b/tests/unit/gapic/aiplatform_v1/test_specialist_pool_service.py index 16ac1df1ea..000f24e24a 100644 --- a/tests/unit/gapic/aiplatform_v1/test_specialist_pool_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_specialist_pool_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1/test_tensorboard_service.py b/tests/unit/gapic/aiplatform_v1/test_tensorboard_service.py index 5eb0930a18..7d620f095c 100644 --- a/tests/unit/gapic/aiplatform_v1/test_tensorboard_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_tensorboard_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1/test_vizier_service.py b/tests/unit/gapic/aiplatform_v1/test_vizier_service.py index 0c9bd53d79..ede60e5893 100644 --- a/tests/unit/gapic/aiplatform_v1/test_vizier_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_vizier_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_dataset_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_dataset_service.py index 469624d9b5..b38db766a0 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_dataset_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_dataset_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_endpoint_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_endpoint_service.py index 6900f5853c..10a51e6d92 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_endpoint_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_endpoint_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_online_serving_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_online_serving_service.py index b216ab128b..c3d96f8657 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_online_serving_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_online_serving_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_service.py index b29bba1435..30ebffc04b 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_index_endpoint_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_index_endpoint_service.py index 41485dea9c..75373a6806 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_index_endpoint_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_index_endpoint_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_index_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_index_service.py index f163aaa75a..c41fe6afff 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_index_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_index_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_job_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_job_service.py index c615e37c59..68a99c25fa 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_job_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_job_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_metadata_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_metadata_service.py index 3a97bca5c0..001a8bfbc8 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_metadata_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_metadata_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py index 49fd9ca313..129ca60552 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_model_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_model_service.py index 0ca4ae225d..53085570b0 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_model_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_model_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -2356,6 +2362,247 @@ async def test_update_model_flattened_error_async(): ) +@pytest.mark.parametrize( + "request_type", + [ + model_service.UpdateExplanationDatasetRequest, + dict, + ], +) +def test_update_explanation_dataset(request_type, transport: str = "grpc"): + client = ModelServiceClient( + 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.update_explanation_dataset), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/spam") + response = client.update_explanation_dataset(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == model_service.UpdateExplanationDatasetRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_explanation_dataset_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 = ModelServiceClient( + 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.update_explanation_dataset), "__call__" + ) as call: + client.update_explanation_dataset() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == model_service.UpdateExplanationDatasetRequest() + + +@pytest.mark.asyncio +async def test_update_explanation_dataset_async( + transport: str = "grpc_asyncio", + request_type=model_service.UpdateExplanationDatasetRequest, +): + client = ModelServiceAsyncClient( + 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.update_explanation_dataset), "__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.update_explanation_dataset(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == model_service.UpdateExplanationDatasetRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_explanation_dataset_async_from_dict(): + await test_update_explanation_dataset_async(request_type=dict) + + +def test_update_explanation_dataset_field_headers(): + client = ModelServiceClient( + 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 = model_service.UpdateExplanationDatasetRequest() + + request.model = "model_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_explanation_dataset), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_explanation_dataset(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", + "model=model_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_explanation_dataset_field_headers_async(): + client = ModelServiceAsyncClient( + 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 = model_service.UpdateExplanationDatasetRequest() + + request.model = "model_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_explanation_dataset), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + await client.update_explanation_dataset(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", + "model=model_value", + ) in kw["metadata"] + + +def test_update_explanation_dataset_flattened(): + client = ModelServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_explanation_dataset), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_explanation_dataset( + model="model_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] + arg = args[0].model + mock_val = "model_value" + assert arg == mock_val + + +def test_update_explanation_dataset_flattened_error(): + client = ModelServiceClient( + 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.update_explanation_dataset( + model_service.UpdateExplanationDatasetRequest(), + model="model_value", + ) + + +@pytest.mark.asyncio +async def test_update_explanation_dataset_flattened_async(): + client = ModelServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_explanation_dataset), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name="operations/op") + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_explanation_dataset( + model="model_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].model + mock_val = "model_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_explanation_dataset_flattened_error_async(): + client = ModelServiceAsyncClient( + 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.update_explanation_dataset( + model_service.UpdateExplanationDatasetRequest(), + model="model_value", + ) + + @pytest.mark.parametrize( "request_type", [ @@ -3416,6 +3663,7 @@ def test_import_model_evaluation(request_type, transport: str = "grpc"): # Designate an appropriate return value for the call. call.return_value = gca_model_evaluation.ModelEvaluation( name="name_value", + display_name="display_name_value", metrics_schema_uri="metrics_schema_uri_value", slice_dimensions=["slice_dimensions_value"], ) @@ -3429,6 +3677,7 @@ def test_import_model_evaluation(request_type, transport: str = "grpc"): # Establish that the response is the type that we expect. assert isinstance(response, gca_model_evaluation.ModelEvaluation) assert response.name == "name_value" + assert response.display_name == "display_name_value" assert response.metrics_schema_uri == "metrics_schema_uri_value" assert response.slice_dimensions == ["slice_dimensions_value"] @@ -3473,6 +3722,7 @@ async def test_import_model_evaluation_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_model_evaluation.ModelEvaluation( name="name_value", + display_name="display_name_value", metrics_schema_uri="metrics_schema_uri_value", slice_dimensions=["slice_dimensions_value"], ) @@ -3487,6 +3737,7 @@ async def test_import_model_evaluation_async( # Establish that the response is the type that we expect. assert isinstance(response, gca_model_evaluation.ModelEvaluation) assert response.name == "name_value" + assert response.display_name == "display_name_value" assert response.metrics_schema_uri == "metrics_schema_uri_value" assert response.slice_dimensions == ["slice_dimensions_value"] @@ -3681,6 +3932,7 @@ def test_get_model_evaluation(request_type, transport: str = "grpc"): # Designate an appropriate return value for the call. call.return_value = model_evaluation.ModelEvaluation( name="name_value", + display_name="display_name_value", metrics_schema_uri="metrics_schema_uri_value", slice_dimensions=["slice_dimensions_value"], ) @@ -3694,6 +3946,7 @@ def test_get_model_evaluation(request_type, transport: str = "grpc"): # Establish that the response is the type that we expect. assert isinstance(response, model_evaluation.ModelEvaluation) assert response.name == "name_value" + assert response.display_name == "display_name_value" assert response.metrics_schema_uri == "metrics_schema_uri_value" assert response.slice_dimensions == ["slice_dimensions_value"] @@ -3738,6 +3991,7 @@ async def test_get_model_evaluation_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_evaluation.ModelEvaluation( name="name_value", + display_name="display_name_value", metrics_schema_uri="metrics_schema_uri_value", slice_dimensions=["slice_dimensions_value"], ) @@ -3752,6 +4006,7 @@ async def test_get_model_evaluation_async( # Establish that the response is the type that we expect. assert isinstance(response, model_evaluation.ModelEvaluation) assert response.name == "name_value" + assert response.display_name == "display_name_value" assert response.metrics_schema_uri == "metrics_schema_uri_value" assert response.slice_dimensions == ["slice_dimensions_value"] @@ -5196,6 +5451,7 @@ def test_model_service_base_transport(): "list_models", "list_model_versions", "update_model", + "update_explanation_dataset", "delete_model", "delete_model_version", "merge_version_aliases", diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_pipeline_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_pipeline_service.py index 19d37fae67..3712934a17 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_pipeline_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_pipeline_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -54,6 +60,7 @@ from google.cloud.aiplatform_v1beta1.types import io from google.cloud.aiplatform_v1beta1.types import model from google.cloud.aiplatform_v1beta1.types import operation as gca_operation +from google.cloud.aiplatform_v1beta1.types import pipeline_failure_policy from google.cloud.aiplatform_v1beta1.types import pipeline_job from google.cloud.aiplatform_v1beta1.types import pipeline_job as gca_pipeline_job from google.cloud.aiplatform_v1beta1.types import pipeline_service diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_prediction_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_prediction_service.py index 987d023874..d6bf05ed42 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_prediction_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_prediction_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_specialist_pool_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_specialist_pool_service.py index cb2d05022d..cf4d765de9 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_specialist_pool_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_specialist_pool_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_tensorboard_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_tensorboard_service.py index 712168fc3a..0763993f1a 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_tensorboard_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_tensorboard_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_vizier_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_vizier_service.py index a73602e3e0..819f46fb17 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_vizier_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_vizier_service.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio