【发布时间】:2019-04-02 16:04:03
【问题描述】:
我正在使用 Python SDK for Apache Beam 在 Google DataFlow 上运行特征提取管道。我需要运行多个转换,所有这些转换都希望项目按键分组。
基于对question 的回答,DataFlow 无法自动发现和重用像 GroupBy 这样的重复转换,所以我希望先运行 GroupBy,然后将结果 PCollection 提供给其他转换(参见下面的示例代码)。
我想知道这是否应该在 DataFlow 中有效地工作。如果没有,Python SDK 中推荐的解决方法是什么?有没有一种有效的方法让多个 Map 或 Write 转换获取相同 GroupBy 的结果?就我而言,我观察到 DataFlow 在利用率为 5% 时扩展到最大工作人员数量,并且在此 question 中描述的 GroupBy 之后的步骤中没有取得任何进展。
示例代码。为简单起见,仅显示了 2 个转换。
# Group by key once.
items_by_key = raw_items | GroupByKey()
# Write groupped items to a file.
(items_by_key | FlatMap(format_item) | WriteToText(path))
# Run another transformation over the same group.
features = (items_by_key | Map(extract_features))
【问题讨论】:
标签: google-cloud-platform google-cloud-dataflow apache-beam