当前位置: 首页>>代码示例>>Python>>正文


Python Pipeline.visit方法代码示例

本文整理汇总了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))
开发者ID:CSberger,项目名称:DataflowPythonSDK,代码行数:13,代码来源:pipeline_test.py

示例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)
开发者ID:CSberger,项目名称:DataflowPythonSDK,代码行数:21,代码来源:pipeline_test.py


注:本文中的google.cloud.dataflow.pipeline.Pipeline.visit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。