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.

ModelGetOp(model, model_name[, project, ...])

Gets a model artifact based on the model name of an existing Vertex model.

ModelUploadOp(display_name, gcp_resources, model)

Uploads a Google Cloud Vertex Model and returns a Model artifact representing the uploaded Model resource, with a tag for the particular version.

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. Note that the full model is deleted, NOT only the model version.

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.

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](https://github.com/kubeflow/pipelines/tree/master/components/google-cloud/google_cloud_pipeline_components/proto) which tracks the export Model’s long-running operation.

v1.model.ModelGetOp(model: dsl.Output[google.VertexModel], model_name: str, project: str = '{{$.pipeline_google_cloud_project_id}}', location: str = 'us-central1')

Gets a model artifact based on the model name of an existing Vertex model.

Parameters:
project: str = '{{$.pipeline_google_cloud_project_id}}'

Project from which to get the VertexModel. Defaults to the project in which the PipelineJob is run.

model_name: str

Specify the model name in one of the following formats: {model}: Fetches the default model version. {model}@{model_version_id}: Fetches the model version specified by its ID. {model}@{model_version_alias}: Fetches the model version specified by its alias.

location: str = 'us-central1'

Location from which to get the VertexModel. Defaults to us-central1.

Returns:

model: dsl.Output[google.VertexModel]

Artifact of the Vertex Model.

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] = {}, version_aliases: list[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, with a tag for the particular version. 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.

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. Example:

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.

explanation_parameters: dict[str, str] = {}

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

version_aliases: list[str] = []

User provided version aliases so that a model version can be referenced via alias (i.e. projects/{project}/locations/{location}/models/{modelId}@{version_alias} instead of auto-generated version id (i.e. projects/{project}/locations/{location}/models/{modelId}@{versionId}). The format is [a-z][a-zA-Z0-9-]{0,126}[a-z0-9] to distinguish from versionId. A default version alias will be created for the first version of the model, and there must be exactly one default version alias for a model.

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.

project: str = '{{$.pipeline_google_cloud_project_id}}'

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 version.

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.