gpt4 book ai didi

python - Vertex AI 预定笔记本不起作用,但手动工作

转载 作者:行者123 更新时间:2023-12-05 05:42:46 25 4
gpt4 key购买 nike

有一个预定的笔记本,它使用 BigQuery 客户端和具有所有者权限的服务帐户。当我手动运行单元格时,它会更新 BQ 表。 BQ 和 Vertex AI 都有一个项目。

我发现了一个类似的问题,但是 bucket 文件夹中没有输出: Google Cloud Vertex AI Notebook Scheduled Runs Aren't Running Code?

在计划部分,此笔记本停留在正在初始化: The endlesly initializing notebook is 'a_test_marketplace_update_1650393238920'

这是笔记本: First part of notebook

Second part of notebook

更新:我尝试一个一个地安排单元格,但所有卡住的尝试都无法通过 BigQuery:

os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'dialogflow-293713-f89fd8f4ed2d.json'

bigquery_client = bigquery.Client()

QUERY = f"""
INSERT `dialogflow-293713.chats.Ежедневная сводка маркетплейса` (date, effectiveness, operatorWorkload)
VALUES({period}, {effectiveness}, {redirectedToSales}, {operatorWorkload})
"""

Query_Results = bigquery_client.query(QUERY)

最佳答案

这种授权方式奏效了!

from google.cloud import bigquery
from google.oauth2 import service_account
import json


raw_credential = { "dictionary. copy the dict elements of your credential.json file" }

service_account_info = json.loads(json.dumps(raw_credential))
credentials = service_account.Credentials.from_service_account_info(service_account_info)

client = bigquery.Client(credentials=credentials)
query = """ Your Query """
df = client.query(query).to_dataframe()
#see some results. remove if its not needed.
print(df.head())

# OPTIONAL: If you want to move data to a google cloud storage bucket
from google.cloud import storage

client = storage.Client()
bucket_name = 'my-bucket-id'
bucket = client.get_bucket(bucket_name)
# if folder `output` does not exist it will be created. You can use the name as you want.
bucket.blob("output/output.csv").upload_from_string(df.to_csv(), 'text/csv')

已解决 this thread 中的问题跟踪器.

关于python - Vertex AI 预定笔记本不起作用,但手动工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71952492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com