我想在将一个文件放到云存储中后启动数据流作业,然后启动一个云功能来触发它。但是我不知道如何使用Python启动datadlow作业? ?
const kickOffDataflow = (input, output) => {
var jobName = CONFIG.DATAFLOW_JOB_NAME;
var templatePath = CONFIG.TEMPLETE_FILE_PATH;
var request = {
projectId: "test",
requestBody: {
jobName: jobName,
parameters: {
configFile: input,
outputFile: output,
mode: "cluster_test"
},
environment: {
zone: "europe-west1-b"
}
},
gcsPath: templatePath
}
console.log("Start to create " + jobName + " dataflow job");
return google.auth.getClient({
scopes: ['https://www.googleapis.com/auth/cloud-platform']
}).then(auth => {
request.auth = auth;
return dataflow.projects.templates.launch(request);
}).catch(error => {
console.error(error);
throw error;
});
}
答案 0 :(得分:1)
看看Dataflow Cloud Composer Example。它描述了如何在新文件到达GCS存储桶中时将Cloud Composer与Cloud Functions结合使用以触发基于Python的Dataflow作业。