【问题标题】:How to run a Python Google Cloud Dataflow job with a custom Docker image?如何使用自定义 Docker 映像运行 Python Google Cloud Dataflow 作业?
【发布时间】:2020-02-23 14:26:43
【问题描述】:

我想使用自定义 Docker 映像运行 Python Google Cloud Dataflow 作业。

根据文档,这应该是可能的:https://beam.apache.org/documentation/runtime/environments/#testing-customized-images

为了尝试这个功能,我已经使用此公共 repo https://github.com/swartchris8/beam_wordcount_with_docker 中的文档中的命令行选项设置了基本字数示例管道

我可以使用 apachebeam/python3.6_sdk 图像在本地使用 PortableRunner 运行字数统计作业,但使用 Dataflow 我无法做到这一点。

我尽可能密切关注 PortableRunner 的文档,我的参数是:

python -m wordcount --input wordcount.py \
--output counts \
--runner=PortableRunner \
--job_endpoint=embed \
--environment_config=apachebeam/python3.6_sdk

对于数据流:

python -m wordcount --input wordcount.py \
--output gs://healx-pubmed-ingestion-tmp/test/wordcount/count/count \\
--runner=DataflowRunner \
--project=healx-pubmed-ingestion \
--job_name=dataflow-wordcount-docker \
--temp_location=gs://healx-pubmed-ingestion-tmp/test/wordcount/tmp \
--experiment=beam_fn_api \
--sdk_location=/Users/chris/beam/sdks/python/container/py36/build/target/apache-beam.tar.gz \
--worker_harness_container_image=apachebeam/python3.6_sdk \
--region europe-west1 \
--zone europe-west1-c

有关完整的详细信息,请参阅链接的 repo。

我在这里做错了什么,还是 Dataflow 中的 Python 作业不支持此功能?

【问题讨论】:

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


    【解决方案1】:

    您应该能够将自定义容器与带有 --experiment=--use_runner_v2 的 Dataflow 一起使用,该容器很快就会默认启用。示例命令行可能如下所示:

    pip install apache-beam[gcp]==2.24.0
    python -m apache_beam.examples.wordcount \
    --output gs://healx-pubmed-ingestion-tmp/test/wordcount/ \
    --runner=DataflowRunner \
    --project=healx-pubmed-ingestion \
    --region europe-west1 \
    --temp_location=gs://healx-pubmed-ingestion-tmp/test/wordcount/tmp \
    --worker_harness_container_image=apache/beam_python3.6_sdk:2.24.0 \
    --experiment=use_runner_v2
                               
    

    要自定义容器,请按照https://beam.apache.org/documentation/runtime/environments/#customizing-container-images 上的说明进行操作。

    【讨论】:

      【解决方案2】:

      不幸的是,Dataflow 目前使用自己的(不兼容的)工作容器,但正在积极解决此问题。

      【讨论】:

      • 添加了另一个答案。
      猜你喜欢
      • 1970-01-01
      • 2019-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-27
      • 2021-12-02
      • 1970-01-01
      • 2018-01-03
      相关资源
      最近更新 更多