Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 如何知道批处理云预测何时结束_Google Cloud Platform_Gcp Ai Platform Notebook_Gcp Ai Platform Training - Fatal编程技术网

Google cloud platform 如何知道批处理云预测何时结束

Google cloud platform 如何知道批处理云预测何时结束,google-cloud-platform,gcp-ai-platform-notebook,gcp-ai-platform-training,Google Cloud Platform,Gcp Ai Platform Notebook,Gcp Ai Platform Training,我正在做一个应用程序,接收一些数据,处理它,然后创建一个预测ai批处理作业。在预测完成后,我应该将它们全部合并到上一个文件中。批处理预测写入一个bucket,我们调用是gs://predictions 目前,我有一个云函数,每当写入gs://predictions时都会触发它。然而,批处理预测作业将数据流式传输到文件中,当需要进行大量预测时,会多次更新此类文件。这意味着我的云函数在我只想在作业完成时调用时多次被触发 为了克服这个问题,现在调用云函数,然后检查作业是否完成。如果是,则处理该文件;如

我正在做一个应用程序,接收一些数据,处理它,然后创建一个预测ai批处理作业。在预测完成后,我应该将它们全部合并到上一个文件中。批处理预测写入一个bucket,我们调用是
gs://predictions

目前,我有一个云函数,每当写入
gs://predictions
时都会触发它。然而,批处理预测作业将数据流式传输到文件中,当需要进行大量预测时,会多次更新此类文件。这意味着我的云函数在我只想在作业完成时调用时多次被触发

为了克服这个问题,现在调用云函数,然后检查作业是否完成。如果是,则处理该文件;如果没有,就让它溜走吧。当然,这会带来很多不必要的处理(和不必要的代码!):-(

在这方面,什么能真正帮助我:批处理作业完成后是否能以某种方式写入Pub/Sub?或者更好,它是否能使用webhook,以便在完成后自己调用我的云函数? 我试图查看这些文件,但什么也找不到

是否有其他建议的解决方案?

您可以使用此自定义筛选器对日志进行检查和筛选:

resource.type="ml_job"
textPayload="Job completed successfully."
然后,当批处理作业完成时,将打印日志跟踪并将消息发布到PubSub主题中。

请参阅文档 为了获得AI平台作业状态,您可以使用GCP提供的RESTAPI,请参阅作业

获取请求正文:

{
  "jobId": string,
  "createTime": string,
  "startTime": string,
  "endTime": string,
  "state": enum (State),  # This Field is what will tell you status of job
  "errorMessage": string,
  "labels": {
    string: string,
    ...
  },
  "etag": string,

  // Union field input can be only one of the following:
  "trainingInput": {
    object (TrainingInput)
  },
  "predictionInput": {
    object (PredictionInput)
  }
  // End of list of possible types for union field input.

  // Union field output can be only one of the following:
  "trainingOutput": {
    object (TrainingOutput)
  },
  "predictionOutput": {
    object (PredictionOutput)
  }
  // End of list of possible types for union field output.
}
状态字段为枚举

Enums
STATE_UNSPECIFIED   The job state is unspecified.
QUEUED              The job has been just created and processing has not yet begun.
PREPARING           The service is preparing to run the job.
RUNNING             The job is in progress.
SUCCEEDED           The job completed successfully.
FAILED              The job failed. errorMessage should contain the details of the failure.
CANCELLING          The job is being cancelled. errorMessage should describe the reason for the cancellation.
CANCELLED           The job has been cancelled. errorMessage should describe the reason for the cancellation.
注意:所有这些都可以通过python或任何其他选择的语言来完成。

附带问题:您的批处理机器类型是什么?输入和输出文件的大小(最大的文件输入和最大的文件输出)是的,我最终选择了这个解决方案:-D。工作完成后,你无法设置一个钩子,甚至无法设置一个PubSub主题来获取警告,这感觉真的很奇怪。设置一个水槽似乎是额外的工作,可能会带来未来的问题,但好吧。更有效的工具即将出现;)请继续关注!是的,你看,问题是:你怎么能有一个云函数来使用这样一个作业的输出?无服务器函数通过触发器工作,因此轮询实际上不是一个选项。这也会导致计算的浪费(时间和机器资源),当这正是您试图用无服务器设计解决的问题时,这是毫无意义的。正如我在问题中所说的,这是第一种方法,但是,它被证明是低效的,有时会产生错误的结果(即状态尚未更新,但工作已经完成)。