我想在依赖于另一个管道输出的谷歌数据流上运行一个管道。现在我只是在本地使用 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/