[英]Porting custom job from GCP AI Platform to Vertex AI - how to get state and logs of job?
I am porting custom job training from gcp AI Platform to Vertex AI.我正在将自定义工作培训从 gcp AI 平台移植到 Vertex AI。 I am able to start a job, but can't find how to to get the status and how to stream the logs to my local client.我可以开始工作,但找不到如何获取状态以及如何将日志流式传输到我的本地客户端。
For AI Platform I was using this to get the state:对于 AI Platform,我使用它来获取状态:
from google.oauth2 import service_account
from googleapiclient import discovery
scopes = ['https://www.googleapis.com/auth/cloud-platform']
credentials = service_account.Credentials.from_service_account_file(keyFile, scopes=scopes)
ml_apis = discovery.build("ml","v1", credentials=credentials, cache_discovery=False)
x = ml_apis.projects().jobs().get(name="projects/%myproject%/jobs/"+job_id).execute() # execute http request
return x['state']
And this to stream the logs:这可以流式传输日志:
cmd = 'gcloud ai-platform jobs stream-logs ' + job_id
This does not work for Vertex AI job.这不适用于 Vertex AI 作业。 What is the replacement code?什么是替换代码?
Can you try this command for streaming logs :您可以尝试使用此命令获取流式日志吗:
gcloud ai custom-jobs stream-logs 123 --region=europe-west4
123 is the ID of the custom job for this case, you can add glcoud wide flags such as --format as well. 123 是这种情况下自定义作业的ID ,您也可以添加 glcoud 宽标志,例如 --format 。
You can visit this link for more details about this command and additional flags available.您可以访问此链接以获取有关此命令和其他可用标志的更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.