本文整理汇总了Python中google.cloud.dataflow.pipeline.Pipeline.visit方法的典型用法代码示例。如果您正苦于以下问题:Python Pipeline.visit方法的具体用法?Python Pipeline.visit怎么用?Python Pipeline.visit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google.cloud.dataflow.pipeline.Pipeline
的用法示例。
在下文中一共展示了Pipeline.visit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_visit_node_sub_graph
# 需要导入模块: from google.cloud.dataflow.pipeline import Pipeline [as 别名]
# 或者: from google.cloud.dataflow.pipeline.Pipeline import visit [as 别名]
def test_visit_node_sub_graph(self):
pipeline = Pipeline('DirectPipelineRunner')
pcoll1 = pipeline | Create('pcoll', [1, 2, 3])
pcoll2 = pcoll1 | FlatMap('do1', lambda x: [x + 1])
pcoll3 = pcoll2 | FlatMap('do2', lambda x: [x + 1])
pcoll4 = pcoll2 | FlatMap('do3', lambda x: [x + 1])
visitor = PipelineTest.Visitor(visited=[])
pipeline.visit(visitor, node=pcoll3)
self.assertFalse(pcoll4 in visitor.visited)
self.assertEqual(set([pcoll1, pcoll2, pcoll3]), set(visitor.visited))
示例2: test_visit_entire_graph
# 需要导入模块: from google.cloud.dataflow.pipeline import Pipeline [as 别名]
# 或者: from google.cloud.dataflow.pipeline.Pipeline import visit [as 别名]
def test_visit_entire_graph(self):
pipeline = Pipeline(DirectPipelineRunner())
pcoll1 = pipeline | Create('pcoll', [1, 2, 3])
pcoll2 = pcoll1 | FlatMap('do1', lambda x: [x + 1])
pcoll3 = pcoll2 | FlatMap('do2', lambda x: [x + 1])
pcoll4 = pcoll2 | FlatMap('do3', lambda x: [x + 1])
transform = PipelineTest.CustomTransform()
pcoll5 = pcoll4 | transform
visitor = PipelineTest.Visitor(visited=[])
pipeline.visit(visitor)
self.assertEqual(set([pcoll1, pcoll2, pcoll3, pcoll4, pcoll5]),
set(visitor.visited))
self.assertEqual(set(visitor.enter_composite),
set(visitor.leave_composite))
self.assertEqual(2, len(visitor.enter_composite))
self.assertEqual(visitor.enter_composite[1].transform, transform)
self.assertEqual(visitor.leave_composite[0].transform, transform)