python - 只有在另一个管道在谷歌数据流上完成后才执行管道

标签 python google-cloud-dataflow apache-beam

我想在依赖于另一个管道输出的谷歌数据流上运行一个管道。现在我只是在本地使用 DirectRunner 依次运行两条管道:

with beam.Pipeline(options=pipeline_options) as p:
    (p
     | beam.io.ReadFromText(known_args.input)
     | SomeTransform()
     | beam.io.WriteToText('temp'))

with beam.Pipeline(options=pipeline_options) as p:
    (p
     | beam.io.ReadFromText('temp*')
     | AnotherTransform()
     | beam.io.WriteToText(known_args.output))

我的问题如下:

  • DataflowRunner 是否保证仅在第一个管道完成后才启动第二个管道?
  • 是否有一种首选方法可以依次运行两个管道?
  • 还有推荐的方法将这些管道分成不同的文件以便更好地测试它们吗?

最佳答案

Does the DataflowRunner guarantee that the second is only started after the first pipeline completed?

不,Dataflow 只是执行管道。它没有管理依赖管道执行的功能。

更新:澄清一下,Apache Beam 确实提供了一种等待管道完成执行的机制。请参阅 PipelineResult 类的 waitUntilFinish() 方法。引用:PipelineResult.waitUntilFinish() .

Is there a preferred method to run two pipelines consequetively after each other?

考虑使用 Apache Airflow 等工具来管理相关管道。您甚至可以实现一个简单的 bash 脚本,在另一个管道完成后部署一个管道。

Also is there a recommended way to separate those pipelines into different files in order to test them better?

是的,单独的文件。这只是良好的代码组织,不一定更适合测试。

关于python - 只有在另一个管道在谷歌数据流上完成后才执行管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49191548/

相关文章:

python - 从 sys.stdin 获取输入,非阻塞

java - 使用 DataFlow (Apache Beam) 将 ISO-8859-1 加载到 BigQuery 时出现问题

google-bigquery - Apache 光束 : Transform an objects having a list of objects to multiple TableRows to write to BigQuery

Python Mysql 类错误

python - 尝试使用 pip install pandas 时给出双重要求

java - 节点间通信

python - 从 Beam 管道连接 google cloud sql postgres 实例

google-cloud-dataflow - 如何解决 apache_beam.internal.clients.dataflow.dataflow_v1b3_messages.TypeValueValuesEnum 类上的酸洗错误?

python - 编码和解码 .gif 文件以与 pyglet 一起使用并使用 pyinstaller 制作成 .exe

google-cloud-dataflow - 访问 Cloud DataFlow 中的 Cloud Pub/Sub 消息属性