[英]Download GCS object to your Vertex AI notebook in GCP
如果你有一個 gs:// blob,你如何使用 python 客戶端庫將該文件從 GCS 下載到 GCP 中的 Vertex AI notebook?
要將 GCS 文件下載到 Vertex AI 筆記本,請參考以下 python 代碼:
from google.cloud import storage
def download_blob(bucket_name, source_blob_name, destination_file_name):
"""Downloads a blob from the bucket."""
# bucket_name = "your-bucket-name"
# The ID of your GCS object
# source_blob_name = "storage-object-name"
# destination_file_name = "/path/to/file"
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(source_blob_name)
blob.download_to_filename(destination_file_name)
print(
"Downloaded storage object {} from bucket {} to file {}.".format(
source_blob_name, bucket_name, destination_file_name
)
)
或者,如果要將 GCS 文件下載到 jupyter 目錄,可以使用以下命令:
:gsutil cp gs://BUCKET_NAME/OBJECT_NAME JUPYTER_LOCATION
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.