本文整理汇总了Python中dispel4py.workflow_graph.WorkflowGraph.partition_pes方法的典型用法代码示例。如果您正苦于以下问题:Python WorkflowGraph.partition_pes方法的具体用法?Python WorkflowGraph.partition_pes怎么用?Python WorkflowGraph.partition_pes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dispel4py.workflow_graph.WorkflowGraph
的用法示例。
在下文中一共展示了WorkflowGraph.partition_pes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_partitioned
# 需要导入模块: from dispel4py.workflow_graph import WorkflowGraph [as 别名]
# 或者: from dispel4py.workflow_graph.WorkflowGraph import partition_pes [as 别名]
def create_partitioned(workflow_all):
processes_all, inputmappings_all, outputmappings_all = \
assign_and_connect(workflow_all, len(workflow_all.graph.nodes()))
proc_to_pe_all = {v[0]: k for k, v in processes_all.items()}
partitions = get_partitions(workflow_all)
external_connections = []
pe_to_partition = {}
partition_pes = []
for i in range(len(partitions)):
for pe in partitions[i]:
pe_to_partition[pe.id] = i
for index in range(len(partitions)):
result_mappings = {}
part = partitions[index]
partition_id = index
component_ids = [pe.id for pe in part]
workflow = copy.deepcopy(workflow_all)
graph = workflow.graph
for node in graph.nodes():
if node.getContainedObject().id not in component_ids:
graph.remove_node(node)
processes, inputmappings, outputmappings = \
assign_and_connect(workflow, len(graph.nodes()))
proc_to_pe = {}
for node in graph.nodes():
pe = node.getContainedObject()
proc_to_pe[processes[pe.id][0]] = pe
for node in graph.nodes():
pe = node.getContainedObject()
pe.rank = index
proc_all = processes_all[pe.id][0]
for output_name in outputmappings_all[proc_all]:
for dest_input, comm_all in\
outputmappings_all[proc_all][output_name]:
dest = proc_to_pe_all[comm_all.destinations[0]]
if dest not in processes:
# it's an external connection
external_connections.append((comm_all,
partition_id,
pe.id,
output_name,
pe_to_partition[dest],
dest, dest_input))
try:
result_mappings[pe.id].append(output_name)
except:
result_mappings[pe.id] = [output_name]
partition_pe = SimpleProcessingPE(inputmappings,
outputmappings,
proc_to_pe)
# use number of processes if specified in graph
try:
partition_pe.numprocesses = workflow_all.numprocesses[partition_id]
except:
# use default assignment of processes
pass
partition_pe.workflow = workflow
partition_pe.partition_id = partition_id
if result_mappings:
partition_pe.result_mappings = result_mappings
partition_pe.map_inputs = _map_inputs_to_pes
partition_pe.map_outputs = _map_outputs_from_pes
partition_pes.append(partition_pe)
# print 'EXTERNAL CONNECTIONS : %s' % external_connections
ubergraph = WorkflowGraph()
ubergraph.pe_to_partition = pe_to_partition
ubergraph.partition_pes = partition_pes
# sort the external connections so that nodes are added in the same order
# if doing this in multiple processes in parallel this is important
for comm, source_partition, source_id, source_output, dest_partition, \
dest_id, dest_input in sorted(external_connections):
partition_pes[source_partition]._add_output((source_id, source_output))
partition_pes[dest_partition]._add_input((dest_id, dest_input),
grouping=comm.name)
ubergraph.connect(partition_pes[source_partition],
(source_id, source_output),
partition_pes[dest_partition],
(dest_id, dest_input))
return ubergraph