本文整理汇总了Python中dispel4py.workflow_graph.WorkflowGraph.flatten方法的典型用法代码示例。如果您正苦于以下问题:Python WorkflowGraph.flatten方法的具体用法?Python WorkflowGraph.flatten怎么用?Python WorkflowGraph.flatten使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dispel4py.workflow_graph.WorkflowGraph
的用法示例。
在下文中一共展示了WorkflowGraph.flatten方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testComposite
# 需要导入模块: from dispel4py.workflow_graph import WorkflowGraph [as 别名]
# 或者: from dispel4py.workflow_graph.WorkflowGraph import flatten [as 别名]
def testComposite():
comp = CompositePE()
cons1 = TestOneInOneOut()
cons2 = TestOneInOneOut()
comp.connect(cons1, "output", cons2, "input")
comp._map_input("comp_input", cons1, "input")
comp._map_output("comp_output", cons2, "output")
prod = TestProducer()
cons = TestOneInOneOut()
graph = WorkflowGraph()
graph.connect(prod, "output", comp, "comp_input")
graph.connect(comp, "comp_output", cons, "input")
graph.flatten()
results = simple_process.process_and_return(graph, {prod: 10})
tools.eq_({cons.id: {"output": list(range(1, 11))}}, results)
示例2: testCreateChain
# 需要导入模块: from dispel4py.workflow_graph import WorkflowGraph [as 别名]
# 或者: from dispel4py.workflow_graph.WorkflowGraph import flatten [as 别名]
def testCreateChain():
def add(a, b):
return a + b
def mult(a, b):
return a * b
def is_odd(a):
return a % 2 == 1
c = [(add, {"b": 1}), (mult, {"b": 3}), is_odd]
chain = create_iterative_chain(c)
prod = TestProducer()
graph = WorkflowGraph()
graph.connect(prod, "output", chain, "input")
graph.flatten()
results = simple_process.process_and_return(graph, {prod: 2})
for key, value in results.items():
tools.eq_({"output": [False, True]}, value)
示例3: testCompositeWithCreateParams
# 需要导入模块: from dispel4py.workflow_graph import WorkflowGraph [as 别名]
# 或者: from dispel4py.workflow_graph.WorkflowGraph import flatten [as 别名]
def testCompositeWithCreateParams():
cons1 = TestOneInOneOut()
cons2 = TestOneInOneOut()
def create_graph(graph, connections):
for i in range(connections):
graph.connect(cons1, "output", cons2, "input")
comp = CompositePE(create_graph, {"connections": 2})
comp._map_input("comp_input", cons1, "input")
comp._map_output("comp_output", cons2, "output")
prod = TestProducer()
cons = TestOneInOneOut()
graph = WorkflowGraph()
graph.connect(prod, "output", comp, "comp_input")
graph.connect(comp, "comp_output", cons, "input")
graph.flatten()
results = simple_process.process_and_return(graph, {prod: 10})
expected = []
for i in range(1, 11):
expected += [i, i]
tools.eq_({cons.id: {"output": expected}}, results)
示例4: Source
# 需要导入模块: from dispel4py.workflow_graph import WorkflowGraph [as 别名]
# 或者: from dispel4py.workflow_graph.WorkflowGraph import flatten [as 别名]
sc = Source()
sc.name='PE_source'
squaref=SimpleFunctionPE(square,{'prov_cluster':'mycluster'})
#squaref=SimpleFunctionPE(square)
divf=Div()
divf.name='PE_div'
#processes=[squaref,divf]
#chain = create_iterative_chain(processes, FunctionPE_class=SimpleFunctionPE)
#Initialise the graph
graph = WorkflowGraph()
#Common way of composing the graph
graph.connect(sc,'output',squaref,'input')
graph.connect(squaref,'output',divf,'input')
#graph.connect(divf,'output',squaref,'input')
# Alternatively with pipeline array
#Create pipelines from functions
#graph.connect(sc,'output',chain,'input')
graph.flatten()
#Prepare Input
input_data = {"PE_source": [{"input": [25]}]}