@@ -26,27 +26,27 @@ def _get_nodes_dict(function_dict):
2626
2727def _get_edge_from_dict (target , key , value_dict , nodes_mapping_dict ):
2828 if len (value_dict ['attributes' ]) == 1 :
29- return {'tn' : target , 'th' : key , "sn " : nodes_mapping_dict [value_dict [' uuid' ]], 'sh' : value_dict [' attributes' ][0 ][1 ]}
29+ return {"target" : target , "targetPort" : key , "source " : nodes_mapping_dict [value_dict [" uuid" ]], "sourcePort" : value_dict [" attributes" ][0 ][1 ]}
3030 else :
31- return {'tn' : target , 'th' : key , "sn " : nodes_mapping_dict [value_dict [' uuid' ]], 'sh' : None }
31+ return {"target" : target , "targetPort" : key , "source " : nodes_mapping_dict [value_dict [" uuid" ]], "sourcePort" : None }
3232
3333
3434def _get_edges_and_extend_nodes (flow_dict , nodes_mapping_dict , nodes_dict ):
3535 edges_lst = []
36- for job in flow_dict [' jobs' ]:
37- for k , v in job [' function_kwargs' ].items ():
38- if isinstance (v , dict ) and ' @module' in v and ' @class' in v and ' @version' in v :
36+ for job in flow_dict [" jobs" ]:
37+ for k , v in job [" function_kwargs" ].items ():
38+ if isinstance (v , dict ) and " @module" in v and " @class" in v and " @version" in v :
3939 edges_lst .append (_get_edge_from_dict (
4040 target = nodes_mapping_dict [job ["uuid" ]],
4141 key = k ,
4242 value_dict = v ,
4343 nodes_mapping_dict = nodes_mapping_dict ,
4444 ))
45- elif isinstance (v , dict ) and any ([isinstance (el , dict ) and ' @module' in el and ' @class' in el and ' @version' in el for el in v .values ()]):
45+ elif isinstance (v , dict ) and any ([isinstance (el , dict ) and " @module" in el and " @class" in el and " @version" in el for el in v .values ()]):
4646 node_dict_index = len (nodes_dict )
4747 nodes_dict [node_dict_index ] = get_dict
4848 for kt , vt in v .items ():
49- if isinstance (vt , dict ) and ' @module' in vt and ' @class' in vt and ' @version' in vt :
49+ if isinstance (vt , dict ) and " @module" in vt and " @class" in vt and " @version" in vt :
5050 edges_lst .append (_get_edge_from_dict (
5151 target = node_dict_index ,
5252 key = kt ,
@@ -59,13 +59,13 @@ def _get_edges_and_extend_nodes(flow_dict, nodes_mapping_dict, nodes_dict):
5959 nodes_dict [node_index ] = vt
6060 else :
6161 node_index = {str (tv ): tk for tk , tv in nodes_dict .items ()}[str (vt )]
62- edges_lst .append ({'tn' : node_dict_index , 'th' : kt , "sn " : node_index , 'sh' : None })
63- edges_lst .append ({'tn' : nodes_mapping_dict [job ["uuid" ]], 'th' : k , "sn " : node_dict_index , 'sh' : None })
64- elif isinstance (v , list ) and any ([isinstance (el , dict ) and ' @module' in el and ' @class' in el and ' @version' in el for el in v ]):
62+ edges_lst .append ({"target" : node_dict_index , "targetPort" : kt , "source " : node_index , "sourcePort" : None })
63+ edges_lst .append ({"target" : nodes_mapping_dict [job ["uuid" ]], "targetPort" : k , "source " : node_dict_index , "sourcePort" : None })
64+ elif isinstance (v , list ) and any ([isinstance (el , dict ) and " @module" in el and " @class" in el and " @version" in el for el in v ]):
6565 node_list_index = len (nodes_dict )
6666 nodes_dict [node_list_index ] = get_list
6767 for kt , vt in enumerate (v ):
68- if isinstance (vt , dict ) and ' @module' in vt and ' @class' in vt and ' @version' in vt :
68+ if isinstance (vt , dict ) and " @module" in vt and " @class" in vt and " @version" in vt :
6969 edges_lst .append (_get_edge_from_dict (
7070 target = node_list_index ,
7171 key = str (kt ),
@@ -78,15 +78,15 @@ def _get_edges_and_extend_nodes(flow_dict, nodes_mapping_dict, nodes_dict):
7878 nodes_dict [node_index ] = vt
7979 else :
8080 node_index = {str (tv ): tk for tk , tv in nodes_dict .items ()}[str (vt )]
81- edges_lst .append ({'tn' : node_list_index , 'th' : kt , "sn " : node_index , 'sh' : None })
82- edges_lst .append ({'tn' : nodes_mapping_dict [job ["uuid" ]], 'th' : k , "sn " : node_list_index , 'sh' : None })
81+ edges_lst .append ({"target" : node_list_index , "targetPort" : kt , "source " : node_index , "sourcePort" : None })
82+ edges_lst .append ({"target" : nodes_mapping_dict [job ["uuid" ]], "targetPort" : k , "source " : node_list_index , "sourcePort" : None })
8383 else :
8484 if v not in nodes_dict .values ():
8585 node_index = len (nodes_dict )
8686 nodes_dict [node_index ] = v
8787 else :
8888 node_index = {tv : tk for tk , tv in nodes_dict .items ()}[v ]
89- edges_lst .append ({'tn' : nodes_mapping_dict [job ["uuid" ]], 'th' : k , "sn " : node_index , 'sh' : None })
89+ edges_lst .append ({"target" : nodes_mapping_dict [job ["uuid" ]], "targetPort" : k , "source " : node_index , "sourcePort" : None })
9090 return edges_lst , nodes_dict
9191
9292
@@ -99,7 +99,7 @@ def _resort_total_lst(total_dict, nodes_dict):
9999 for ind in sorted (total_dict .keys ()):
100100 connect = total_dict [ind ]
101101 if ind not in ordered_lst :
102- source_lst = [sd ["sn " ] for sd in connect .values ()]
102+ source_lst = [sd ["source " ] for sd in connect .values ()]
103103 if all ([s in ordered_lst or s in nodes_without_dep_lst for s in source_lst ]):
104104 ordered_lst .append (ind )
105105 total_new_dict [ind ] = connect
@@ -109,11 +109,11 @@ def _resort_total_lst(total_dict, nodes_dict):
109109def _group_edges (edges_lst ):
110110 total_dict = {}
111111 for ed_major in edges_lst :
112- target_id = ed_major ["tn " ]
112+ target_id = ed_major ["target " ]
113113 tmp_lst = []
114114 if target_id not in total_dict .keys ():
115115 for ed in edges_lst :
116- if target_id == ed ["tn " ]:
116+ if target_id == ed ["target " ]:
117117 tmp_lst .append (ed )
118118 total_dict [target_id ] = get_kwargs (lst = tmp_lst )
119119 return total_dict
@@ -139,8 +139,8 @@ def get_attr_helper(obj, source_handle):
139139 else :
140140 fn = job (method = v )
141141 kwargs = {
142- kw : input_dict [vw ['sn' ]] if vw ['sn' ] in input_dict else get_attr_helper (
143- obj = memory_dict [vw ['sn' ]], source_handle = vw ['sh' ])
142+ kw : input_dict [vw ["source" ]] if vw ["source" ] in input_dict else get_attr_helper (
143+ obj = memory_dict [vw ["source" ]], source_handle = vw ["sourcePort" ])
144144 for kw , vw in total_dict [k ].items ()
145145 }
146146 memory_dict [k ] = fn (** kwargs )
@@ -160,15 +160,15 @@ def load_workflow_json(file_name):
160160
161161 edges_new_lst = []
162162 for edge in content ["edges" ]:
163- if edge ['sh' ] is None :
163+ if edge ["sourcePort" ] is None :
164164 edges_new_lst .append (edge )
165165 else :
166166 edges_new_lst .append (
167167 {
168- 'tn' : edge ['tn' ],
169- 'th' : edge ['th' ],
170- 'sn' : edge ['sn' ],
171- 'sh' : str (edge ['sh' ]),
168+ "target" : edge ["target" ],
169+ "targetPort" : edge ["targetPort" ],
170+ "source" : edge ["source" ],
171+ "sourcePort" : str (edge ["sourcePort" ]),
172172 }
173173 )
174174
0 commit comments