AutoML Video Intelligence 的某些方法会返回长时间运行的操作。这些方法是异步执行的;当方法返回响应时,操作可能尚未完成。
获取操作状态
您可以通过操作名称,检查长时间运行任务的状态(将数据项导入数据集或训练模型)。
REST
在使用任何请求数据之前,请先进行以下替换:
- project-number:您的项目编号
- location-id:例如 us-central1。
- operation id:在开始操作时的响应中提供,例如“分类”:
VCN123....
和“对象跟踪”:VOT123....
HTTP 方法和网址:
GET https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id
如需发送请求,请选择以下方式之一:
curl
执行以下命令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-number" \
"https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id"
PowerShell
执行以下命令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-number" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id" | Select-Object -Expand Content
- 模型名称:
projects/project-number/locations/location-id/models/model-id
- 模型 ID:
model-id
取消操作
您可以利用操作 ID 取消长时间运行的操作。无法保证成功取消。
REST
在使用任何请求数据之前,请先进行以下替换:
- operation id:在开始操作时的响应中提供,例如“分类”:
VCN123....
和“对象跟踪”:VOT123....
- 注意:
- project-number:您的 GCP 项目 ID
- location-id:在其中添加注解的 Cloud 区域。支持的云区域为:
us-east1
、us-west1
、europe-west1
、asia-east1
。如果未指定区域,系统将根据视频文件位置确定区域。
HTTP 方法和网址:
POST https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id:cancel
如需发送您的请求,请展开以下选项之一:
您应该会收到一个成功的状态代码 (2xx) 和一个空响应。