Skip to content

Latest commit

 

History

History
70 lines (55 loc) · 4.21 KB

aiplatform_notes.md

File metadata and controls

70 lines (55 loc) · 4.21 KB

ga4

Interacting with Vertex AI

Many Vertex AI resources can be viewed and monitored directly in the GCP Console. Vertex AI resources are primarily created, and modified with the Vertex AI API.

The API is accessible from:

There are levels:

  • high-level aiplatform
    • The Vertex AI SDK, publically available features. Easiest to use, concise, and designed to simplify common tasks in workflows.
  • low-level aiplatform.gapic
    • auto-generated from Google's sevice proto files. GAPIC stands for Google API CodeGen.

There are versions for aiplatform.gapic:

  • aiplatform_v1: stable,
    • all the production features of the platform
  • aiplatform_v1beta1: latest preview features.
    • includes additional features of the platform in beta phase

Python

The Google Cloud Python Client has a library for Vertex AI called aiplatform which is called the Vertex AI SDK for Python.

The notebooks in this repository primarily use the Python client aiplatform. There is occasional use of aiplatform.gapic, aiplatform_v1 and aiplatform_v1beta1.

Install the Vertex AI Python Client

pip install google-cloud-aiplatform

Example of All Client Versions/Layers with Python Client

This example shows the process of listing all models for a Vertex AI Model Registry in a project in a region:

PROJECT = 'statmike-mlops-349915'
REGION = 'us-central1'

# List all models for project in region with: aiplatform
from google.cloud import aiplatform
aiplatform.init(project = PROJECT, location = REGION)
model_list = aiplatform.Model.list()

# List all models for project in region with: aiplatform.gapic
from google.cloud import aiplatform
model_client_gapic = aiplatform.gapic.ModelServiceClient(client_options = {"api_endpoint": f"{REGION}-aiplatform.googleapis.com"})
model_list = list(model_client_gapic.list_models(parent = f'projects/{PROJECT}/locations/{REGION}'))

# List all models for project in region with: aiplatform_v1
from google.cloud import aiplatform_v1
model_client_v1 = aiplatform_v1.ModelServiceClient(client_options = {"api_endpoint": f"{REGION}-aiplatform.googleapis.com"})
model_list = list(model_client_v1.list_models(parent = f'projects/{PROJECT}/locations/{REGION}'))

# List all models for project in region with: aiplatform_v1beta1
from google.cloud import aiplatform_v1beta1
model_client_v1beta1 = aiplatform_v1beta1.ModelServiceClient(client_options = {"api_endpoint": f"{REGION}-aiplatform.googleapis.com"})
model_list = list(model_client_v1beta1.list_models(parent = f'projects/{PROJECT}/locations/{REGION}'))