代码之家  ›  专栏  ›  技术社区  ›  Jermell Beane

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

  •  0
  • Jermell Beane  · 技术社区  · 7 年前

    我有一个数据流项目,我将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'
    

    这也适用。

    因此,在我看来,似乎将labels选项与template\u location选项一起添加会导致数据流失败。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Zhou Yunqing    7 年前

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

    我正在努力,看看它是否可以在我们这边修复,但它可能需要相当多的时间才能推出。 作为一种缓解措施,短期内您可以在模板文件中执行以下替换操作(应该有两次)。 发件人:

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

    收件人:

    "labels": [{"key" : "foo"}, {"value" : "bar"}]
    

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