【问题标题】:How to start up dataflow job with Python Code如何使用 Python 代码启动数据流作业
【发布时间】:2019-02-07 14:36:08
【问题描述】:

一旦我将一个文件放到云存储中,我想启动数据流作业。我启动一个云功能来触发它。但我不知道如何用 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;
});

}

【问题讨论】:

  • 请展示您尝试过的内容以及您不知道如何继续的地方。
  • 你可以看到,我有node.js的代码,它工作,但我不知道如何用python重写,我的老板需要我们改变python
  • 那么你应该改写你的问题以明确这一点。请注意,为您编程的请求很可能得不到答复。

标签: python-3.x google-cloud-platform google-cloud-functions google-cloud-dataflow


【解决方案1】:

看看Dataflow Cloud Composer Example。它描述了如何将 Cloud Composer 与 Cloud Functions 结合使用,以在新文件到达 GCS 存储桶时触发基于 Python 的 Dataflow 作业。

【讨论】:

    猜你喜欢
    • 2021-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多