Model

Manage models via Vertex AI Model Registry.

Components:

ModelDeleteOp(model, gcp_resources)

[Deletes](https://cloud.google.com/vertex- ai/docs/reference/rest/v1/projects.locations.models/delete) a Google Cloud Vertex Model.

ModelExportOp(model, export_format_id, ...)

Exports a Google Cloud Vertex Model to a user-specified location.

ModelUploadOp(display_name, gcp_resources, model)

Uploads a Google Cloud Vertex Model and returns a Model artifact representing the uploaded Model resource.

v1.model.ModelDeleteOp(model: dsl.Input[google.VertexModel], gcp_resources: dsl.OutputPath(str))

[Deletes](https://cloud.google.com/vertex- ai/docs/reference/rest/v1/projects.locations.models/delete) a Google Cloud Vertex Model.

See the [Model delete](https://cloud.google.com/vertex- ai/docs/reference/rest/v1/projects.locations.models/delete) method for more information.

Parameters
model: dsl.Input[google.VertexModel]

The name of the Model resource to be deleted. Format: projects/{project}/locations/{location}/models/{model}. More information.

Returns

``gcp_resources: dsl.OutputPath(str)``
          Serialized JSON of `gcp_resources` [proto](https://github.com/kubeflow/pipelines/tree/master/components/google-cloud/google_cloud_pipeline_components/proto) which tracks the delete Model's long-running operation.
v1.model.ModelExportOp(model: dsl.Input[google.VertexModel], export_format_id: str, output_info: dsl.OutputPath(), gcp_resources: dsl.OutputPath(str), artifact_destination: str = '', image_destination: str = '')

Exports a Google Cloud Vertex Model to a user-specified location.

The Model must be exportable. A Model is considered to be exportable if it has at least one supported export format.

See the Model export method for more information.

Parameters
model: dsl.Input[google.VertexModel]

The Model to export.

export_format_id: str

The ID of the format in which the Model must be

exported. Each Model lists the export formats it supports. If no value is provided here, then the first from the list of the Model’s supported formats is used by default. More information. :param artifact_destination: The Cloud Storage location where the Model artifact is to be written to. Under the directory given as the destination a new one with name "model-export-<model-display-name>-<timestamp-of-export-call>", where timestamp is in YYYY-MM-DDThh:mm:ss.sssZ ISO-8601 format, will be created. Inside, the Model and any of its supporting files will be written. This field should only be set when, in [Model.supported_export_formats], the value for the key given in export_format_id contains ARTIFACT. More information. :param image_destination: The Google Container Registry or Artifact Registry URI where the Model container image will be copied to. More information.

Accepted forms:

  -  Google Container Registry path. For example: `gcr.io/projectId/imageName:tag`.
  -  Artifact Registry path.

For example:

  `us-central1-docker.pkg.dev/projectId/repoName/imageName:tag`.

This field should only be set when, in [Model.supported_export_formats], the value for the key given in `export_format_id` contains `IMAGE`.
Returns

``info: dsl.OutputPath()``
          Details of the completed export with output destination paths to

the artifacts or container image. gcp_resources: Serialized JSON of gcp_resources proto which tracks the export Model’s long-running operation.

v1.model.ModelUploadOp(display_name: str, gcp_resources: dsl.OutputPath(str), model: dsl.Output[google.VertexModel], location: str = 'us-central1', description: str = '', parent_model: dsl.Input[google.VertexModel] = None, unmanaged_container_model: dsl.Input[google.UnmanagedContainerModel] = None, explanation_metadata: dict[str, str] = {}, explanation_parameters: dict[str, str] = {}, labels: dict[str, str] = {}, encryption_spec_key_name: str = '', project: str = '{{$.pipeline_google_cloud_project_id}}')

Uploads a Google Cloud Vertex Model and returns a Model artifact representing the uploaded Model resource.

See Model upload method for more information.

Parameters
location: str = 'us-central1'

Optional location to upload this Model to. If

not set, defaults to us-central1. :param display_name: The display name of the Model. The name can be up to 128 characters long and can be consist of any UTF-8 characters. More information. :param description: The description of the Model. More information. :param parent_model: An artifact of a model which to upload a new version to. Only specify this field when uploading a new version. More information. :param unmanaged_container_model: The unmanaged container model to be uploaded. The Model can be passed from an upstream step or imported via a KFP dsl.importer.

:Examples:
  ::

    from kfp import dsl
    from google_cloud_pipeline_components.types import artifact_types

    importer_spec = dsl.importer(
      artifact_uri='gs://managed-pipeline-gcpc-e2e-test/automl-tabular/model',
      artifact_class=artifact_types.UnmanagedContainerModel,
      metadata={
        'containerSpec': { 'imageUri':
          'us-docker.pkg.dev/vertex-ai/automl-tabular/prediction-server:prod'
          }
      })
Parameters
explanation_metadata: dict[str, str] = {}

Metadata describing the Model’s

input and output for explanation. Both explanation_metadata and explanation_parameters must be passed together when used. More information. :param explanation_parameters: Parameters to configure explaining for Model’s predictions. More information. :param encryption_spec_key_name: Customer-managed encryption key spec for a Model. If set, this Model and all sub-resources of this Model will be secured by this key. Has the form: projects/my-project/locations/my-location/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. :param labels: The labels with user-defined metadata to organize your model. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels. :param project: Project to upload this Model to. Defaults to the project in which the PipelineJob is run.

Returns

``model: dsl.Output[google.VertexModel]``
          Artifact tracking the created Model.
``gcp_resources: dsl.OutputPath(str)``
          Serialized JSON of `gcp_resources` [proto](https://github.com/kubeflow/pipelines/tree/master/components/google-cloud/google_cloud_pipeline_components/proto) which tracks the upload Model's long-running operation.