google_cloud_pipeline_components.v1.model module

Core modules for AI Platform Pipeline Components.

google_cloud_pipeline_components.v1.model.ModelExportOp(model: google.VertexModel, export_format_id: str, artifact_destination: str = '', image_destination: str = '')

model_export Exports a trained, exportable, Model to a location specified by the user. A Model is considered to be exportable if it has at least one supported export format. For more details, see https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.models/export.

Args:
model (google.VertexModel):

Required. The model to be exported.

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.

artifact_destination (Optional[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.

image_destination (Optional[str]):

The Google Container Registry or Artifact Registry URI where the Model container image will be copied to. 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:
output_info (str):

Details of the completed export with output destination paths to the artifacts or container image.

google_cloud_pipeline_components.v1.model.ModelUploadOp(project: str, display_name: str, location: str = 'us-central1', description: str = '', unmanaged_container_model: google.UnmanagedContainerModel = None, explanation_metadata: dict = '{}', explanation_parameters: dict = '{}', encryption_spec_key_name: str = '', labels: dict = '{}')

model_upload Uploads a model and returns a Model representing the uploaded Model resource. For more details, see https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.models/upload.

Args:
project (str):

Required. Project to upload this model to.

location (Optional[str]):

Optional location to upload this model to. If not set, default to us-central1.

display_name (str):

Required. The display name of the Model. The name can be up to 128 characters long and can be consist of any UTF-8 characters.

description (Optional[str]):

The description of the model.

unmanaged_container_model (Optional[google.UnmanagedContainerModel]):

Optional. The unmanaged container model to be uploaded.

The model can be passed from an upstream step, or imported via an importer node. ```

from kfp.v2.components import importer_node from google_cloud_pipeline_components.types import artifact_types

importer_spec = importer_node.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 (Optional[dict]):

Metadata describing the Model’s input and output for explanation. Both explanation_metadata and explanation_parameters must be passed together when used.

For more details, see https://cloud.google.com/vertex-ai/docs/reference/rest/v1/ExplanationSpec#explanationmetadata.

explanation_parameters (Optional[dict]):

Parameters to configure explaining for Model’s predictions.

For more details, see https://cloud.google.com/vertex-ai/docs/reference/rest/v1/ExplanationSpec#explanationmetadata.

encryption_spec_key_name (Optional[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 (Optional[dict]):

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 (google.VertexModel):

Artifact tracking the created model.

gcp_resources (str):

Serialized gcp_resources proto tracking the upload model’s long running operation.

For more details, see https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/proto/README.md.