Dataprep:工作完成事件

时间:2018-03-08 19:17:47

标签: google-cloud-platform google-cloud-dataprep

我们正在考虑在自动时间表上使用Dataprep以便进行争论。将GCS .gz文件夹加载到Big Query中。

挑战在于:如何处理源.gz文件一旦被处理后转移到冷存储中?

我无法找到Dataprep生成的事件,我们可以连接到该事件以执行归档任务。如果Dataprep可以自己归档源文件,那将是理想的。

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

我不相信直接从Dataprep完成工作时会有通知的方法。您可以做的是轮询基础数据流作业。您可以安排脚本在计划的dataprep作业运行时运行。这是一个简单的例子:

#!/bin/bash

# list running dataflow jobs, filter so that only the one with the "dataprep" string in its name is actually listed and keep its id
id=$(gcloud dataflow jobs list --status=active --filter="name:dataprep" | sed -n 2p | cut -f 1 -d " ")
# loop until the state of the job changes to done
until [ $(gcloud dataflow jobs describe $id | grep currentState | head -1 | awk '{print $2}') == "JOB_STATE_DONE" ]
do
# sleep so that you reduce API calls
sleep 5m
done
# send to cold storage, e.g. gsutil mv ...
echo "done"

这里的问题是,上面假设您只运行一个dataprep作业。如果您安排许多并发的dataprep作业,脚本会更复杂。