使用“标签”选项时,模板无法在GoogleCloudDataflow上进行解析

时间:2018-03-08 15:31:37

标签: python google-cloud-dataflow apache-beam

我有一个Dataflow项目,我设置了这样的GoogleCloudOptions:

google_cloud_options = options.view_as(GoogleCloudOptions)
google_cloud_options.project = my_settings.gcp_project_name
google_cloud_options.job_name = "{}-{}".format(my_settings.gcp_job_name, datetime.datetime.now().strftime("%y-%m-%d-%H-%M"))
google_cloud_options.staging_location = 'gs://some/staging'
google_cloud_options.temp_location = 'gs://some/temp'
google_cloud_options.template_location = 'gs://some/templates/some_template'
google_cloud_options.labels = ["dum=dum", "run=run"]

googleapiclient.errors.HttpError: <HttpError 400 when requesting https://dataflow.googleapis.com/v1b3/projects/some_project/templates:launch?alt=json&gcsPath=gs%3A%2F%2Fsome%2Ftemplates%2Fsome_template returned "Unable to parse template file 'gs://some/templates/some_template'.">

那失败了。

google_cloud_options = options.view_as(GoogleCloudOptions)
google_cloud_options.project = my_settings.gcp_project_name
google_cloud_options.job_name = "{}-{}".format(my_settings.gcp_job_name, datetime.datetime.now().strftime("%y-%m-%d-%H-%M"))
google_cloud_options.staging_location = 'gs://some/staging'
google_cloud_options.temp_location = 'gs://some/temp'
google_cloud_options.labels = ["dum=dum", "run=run"]

这实际上运行了,为什么呢?理想情况下,我希望模板化版本能够运行,我需要弄清楚如何使模板正确编译和解析。

google_cloud_options = options.view_as(GoogleCloudOptions)
google_cloud_options.project = my_settings.gcp_project_name
google_cloud_options.job_name = "{}-{}".format(my_settings.gcp_job_name, datetime.datetime.now().strftime("%y-%m-%d-%H-%M"))
google_cloud_options.staging_location = 'gs://some/staging'
google_cloud_options.temp_location = 'gs://some/temp'
google_cloud_options.template_location = 'gs://some/templates/some_template'

这也是如此。

所以对我而言,似乎将templates选项与template_location选项一起添加会导致Dataflow失败。

1 个答案:

答案 0 :(得分:0)

这似乎是一个json序列化兼容性问题。后端无法识别序列化标签图。

我正在努力查看是否可以修复它,但可能需要相当多的推出。 作为缓解措施,短期内您可以在模板文件中进行以下替换(应该有2次)。 FROM:

ORDER BY

TO:

"labels": {"foo" : "bar"}

看看它是否有效。很抱歉给您带来不便。