airflow.providers.google.cloud.hooks.vertex_ai.model_service

This module contains a Google Cloud Vertex AI hook.

Module Contents

Classes

ModelServiceHook

Hook for Google Cloud Vertex AI Endpoint Service APIs.

class airflow.providers.google.cloud.hooks.vertex_ai.model_service.ModelServiceHook(**kwargs)[source]

Bases: airflow.providers.google.common.hooks.base_google.GoogleBaseHook

Hook for Google Cloud Vertex AI Endpoint Service APIs.

get_model_service_client(region=None)[source]

Return ModelServiceClient object.

static extract_model_id(obj)[source]

Return unique id of the model.

wait_for_operation(operation, timeout=None)[source]

Wait for long-lasting operation to complete.

delete_model(project_id, region, model, retry=DEFAULT, timeout=None, metadata=())[source]

Delete a Model.

Parameters
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • region (str) – Required. The ID of the Google Cloud region that the service belongs to.

  • model (str) – Required. The name of the Model resource to be deleted.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Designation of what errors, if any, should be retried.

  • timeout (float | None) – The timeout for this request.

  • metadata (Sequence[tuple[str, str]]) – Strings which should be sent along with the request as metadata.

export_model(project_id, region, model, output_config, retry=DEFAULT, timeout=None, metadata=())[source]

Export a trained, exportable Model to a location specified by the user.

Parameters
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • region (str) – Required. The ID of the Google Cloud region that the service belongs to.

  • model (str) – Required. The resource name of the Model to export.

  • output_config (google.cloud.aiplatform_v1.types.model_service.ExportModelRequest.OutputConfig | dict) – Required. The desired output location and configuration.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Designation of what errors, if any, should be retried.

  • timeout (float | None) – The timeout for this request.

  • metadata (Sequence[tuple[str, str]]) – Strings which should be sent along with the request as metadata.

list_models(project_id, region, filter=None, page_size=None, page_token=None, read_mask=None, order_by=None, retry=DEFAULT, timeout=None, metadata=())[source]

List Models in a Location.

Parameters
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • region (str) – Required. The ID of the Google Cloud region that the service belongs to.

  • filter (str | None) – An expression for filtering the results of the request. For field names both snake_case and camelCase are supported. - model supports = and !=. model represents the Model ID, i.e. the last segment of the Model’s [resource name][google.cloud.aiplatform.v1.Model.name]. - display_name supports = and != - labels supports general map functions that is: – labels.key=value - key:value equality – `labels.key:* or labels:key - key existence – A key including a space must be quoted. labels."a key".

  • page_size (int | None) – The standard list page size.

  • page_token (str | None) – The standard list page token. Typically obtained via [ListModelsResponse.next_page_token][google.cloud.aiplatform.v1.ListModelsResponse.next_page_token] of the previous [ModelService.ListModels][google.cloud.aiplatform.v1.ModelService.ListModels] call.

  • read_mask (str | None) – Mask specifying which fields to read.

  • order_by (str | None) – A comma-separated list of fields to order by, sorted in ascending order. Use “desc” after a field name for descending.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Designation of what errors, if any, should be retried.

  • timeout (float | None) – The timeout for this request.

  • metadata (Sequence[tuple[str, str]]) – Strings which should be sent along with the request as metadata.

upload_model(project_id, region, model, retry=DEFAULT, timeout=None, metadata=())[source]

Upload a Model artifact into Vertex AI.

Parameters
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • region (str) – Required. The ID of the Google Cloud region that the service belongs to.

  • model (google.cloud.aiplatform_v1.types.Model | dict) – Required. The Model to create.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Designation of what errors, if any, should be retried.

  • timeout (float | None) – The timeout for this request.

  • metadata (Sequence[tuple[str, str]]) – Strings which should be sent along with the request as metadata.

list_model_versions(region, project_id, model_id, retry=DEFAULT, timeout=None, metadata=())[source]

List all versions of the existing Model.

Parameters
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • region (str) – Required. The ID of the Google Cloud region that the service belongs to.

  • model_id (str) – Required. The ID of the Model to output versions for.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Designation of what errors, if any, should be retried.

  • timeout (float | None) – The timeout for this request.

  • metadata (Sequence[tuple[str, str]]) – Strings which should be sent along with the request as metadata.

delete_model_version(region, project_id, model_id, retry=DEFAULT, timeout=None, metadata=())[source]

Delete version of the Model. The version could not be deleted if this version is default.

Parameters
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • region (str) – Required. The ID of the Google Cloud region that the service belongs to.

  • model_id (str) – Required. The ID of the Model in which to delete version.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Designation of what errors, if any, should be retried.

  • timeout (float | None) – The timeout for this request.

  • metadata (Sequence[tuple[str, str]]) – Strings which should be sent along with the request as metadata.

get_model(region, project_id, model_id, retry=DEFAULT, timeout=None, metadata=())[source]

Retrieve Model of specific name and version. If version is not specified, the default is retrieved.

Parameters
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • region (str) – Required. The ID of the Google Cloud region that the service belongs to.

  • model_id (str) – Required. The ID of the Model to retrieve.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Designation of what errors, if any, should be retried.

  • timeout (float | None) – The timeout for this request.

  • metadata (Sequence[tuple[str, str]]) – Strings which should be sent along with the request as metadata.

set_version_as_default(region, model_id, project_id, retry=DEFAULT, timeout=None, metadata=())[source]

Set current version of the Model as default.

Parameters
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • region (str) – Required. The ID of the Google Cloud region that the service belongs to.

  • model_id (str) – Required. The ID of the Model to set as default.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Designation of what errors, if any, should be retried.

  • timeout (float | None) – The timeout for this request.

  • metadata (Sequence[tuple[str, str]]) – Strings which should be sent along with the request as metadata.

add_version_aliases(region, model_id, project_id, version_aliases, retry=DEFAULT, timeout=None, metadata=())[source]

Add list of version aliases to specific version of Model.

Parameters
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • region (str) – Required. The ID of the Google Cloud region that the service belongs to.

  • model_id (str) – Required. The ID of the Model to add aliases to.

  • version_aliases (Sequence[str]) – Required. List of version aliases to be added for specific version.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Designation of what errors, if any, should be retried.

  • timeout (float | None) – The timeout for this request.

  • metadata (Sequence[tuple[str, str]]) – Strings which should be sent along with the request as metadata.

delete_version_aliases(region, model_id, project_id, version_aliases, retry=DEFAULT, timeout=None, metadata=())[source]

Delete list of version aliases of specific version of Model.

Parameters
  • project_id (str) – Required. The ID of the Google Cloud project that the service belongs to.

  • region (str) – Required. The ID of the Google Cloud region that the service belongs to.

  • model_id (str) – Required. The ID of the Model to delete aliases from.

  • version_aliases (Sequence[str]) – Required. List of version aliases to be deleted from specific version.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Designation of what errors, if any, should be retried.

  • timeout (float | None) – The timeout for this request.

  • metadata (Sequence[tuple[str, str]]) – Strings which should be sent along with the request as metadata.

Was this entry helpful?