mirror of
https://github.com/GoogleCloudPlatform/vertex-ai-samples.git
synced 2026-09-26 14:42:04 +00:00
Add extra # character. This enables users to uncomment the whole cell, versus picking just the right lines to uncomment.
14 KiB
14 KiB
In [ ]:
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.In [ ]:
# Install the packages
! pip3 install --upgrade --quiet google-cloud-aiplatformIn [ ]:
# # Automatically restart kernel after installs so that your environment can access the new packages
# import IPython
# app = IPython.Application.instance()
# app.kernel.do_shutdown(True)In [ ]:
PROJECT_ID = "[your-project-id]" # @param {type:"string"}
# Set the project id
! gcloud config set project {PROJECT_ID}In [1]:
REGION = "us-central1" # @param {type: "string"}In [2]:
# ! gcloud auth loginIn [3]:
# from google.colab import auth
# auth.authenticate_user()In [ ]:
BUCKET_URI = f"gs://your-bucket-name-{PROJECT_ID}-unique" # @param {type:"string"}In [ ]:
! gsutil mb -l {REGION} -p {PROJECT_ID} {BUCKET_URI}In [ ]:
from google.cloud import aiplatformIn [ ]:
aiplatform.init(project=PROJECT_ID, location=REGION, staging_bucket=BUCKET_URI)In [1]:
import os
# Delete endpoint resource
# e.g. `endpoint.delete()`
# Delete model resource
# e.g. `model.delete()`
# Delete Cloud Storage objects that were created
delete_bucket = False
if delete_bucket or os.getenv("IS_TESTING"):
! gsutil -m rm -r $BUCKET_URI
Run in Colab
View on GitHub