Model

Manage models via Vertex AI Model Registry.

Components:

ModelDeleteOp(model, gcp_resources)

Deletes a Google Cloud Vertex Model.

ModelExportOp(model, export_format_id, ...)

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

ModelUploadOp(project, display_name, ...[, ...])

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 a Google Cloud Vertex Model.

See the Model 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 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.

artifact_destination: str = ''

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.

image_destination: str = ''

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(project: str, 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 = '')

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

See Model upload method for more information.

Parameters
project: str

Project to upload this Model to.

location: str = 'us-central1'

Optional location to upload this Model to. If not set, defaults to us-central1.

display_name: str

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.

description: str = ''

The description of the Model. More information.

parent_model: dsl.Input[google.VertexModel] = None

An artifact of a model which to upload a new version to. Only specify this field when uploading a new version. More information.

unmanaged_container_model: dsl.Input[google.UnmanagedContainerModel] = None

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'
      }
  })

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.

explanation_parameters: dict[str, str] = {}

Parameters to configure explaining for Model’s predictions. More information.

encryption_spec_key_name: str = ''

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.

labels: dict[str, str] = {}

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.

Returns

model: dsl.Output[google.VertexModel]

Artifact tracking the created Model.

gcp_resources: dsl.OutputPath(str)

Serialized JSON of gcp_resources proto which tracks the upload Model’s long-running operation.