@@ -108,12 +108,15 @@ def write_workflow_json(graph_as_dict: dict, file_name: str = "workflow.json"):
108108 remap_dict [k ] = cache_mapping_dict [str (v )]
109109
110110 item_node_lst = [
111- e [SOURCE_LABEL ] for e in edges_lst
112- if e [TARGET_LABEL ] in pyiron_workflow_modules .keys () and e [TARGET_PORT_LABEL ] == "item"
111+ e [SOURCE_LABEL ]
112+ for e in edges_lst
113+ if e [TARGET_LABEL ] in pyiron_workflow_modules .keys ()
114+ and e [TARGET_PORT_LABEL ] == "item"
113115 ]
114116
115117 values_from_dict_lst = [
116- k for k , v in nodes_dict .items ()
118+ k
119+ for k , v in nodes_dict .items ()
117120 if isfunction (v ) and v .__name__ == "get_values_from_dict"
118121 ]
119122
@@ -123,16 +126,24 @@ def write_workflow_json(graph_as_dict: dict, file_name: str = "workflow.json"):
123126 remap_get_list_dict [e [SOURCE_LABEL ]] = e [TARGET_LABEL ]
124127
125128 nodes_remaining_dict = {
126- k : v for k , v in nodes_dict .items ()
127- if k not in pyiron_workflow_modules .keys () and k not in remap_dict .keys () and k not in item_node_lst and k not in remap_get_list_dict .values ()
129+ k : v
130+ for k , v in nodes_dict .items ()
131+ if k not in pyiron_workflow_modules .keys ()
132+ and k not in remap_dict .keys ()
133+ and k not in item_node_lst
134+ and k not in remap_get_list_dict .values ()
128135 }
129136
130137 nodes_store_lst = []
131138 nodes_final_order_dict = {}
132139 for k , [i , v ] in enumerate (nodes_remaining_dict .items ()):
133140 if i in remap_get_list_dict :
134141 nodes_store_lst .append (
135- {"id" : k , "type" : "function" , "value" : "python_workflow_definition.shared.get_list" }
142+ {
143+ "id" : k ,
144+ "type" : "function" ,
145+ "value" : "python_workflow_definition.shared.get_list" ,
146+ }
136147 )
137148 elif isfunction (v ):
138149 mod = v .__module__
@@ -148,15 +159,15 @@ def write_workflow_json(graph_as_dict: dict, file_name: str = "workflow.json"):
148159 nodes_final_order_dict [i ] = k
149160
150161 remap_get_list_remove_edges = [
151- edge for edge in edges_lst
152- if edge [TARGET_LABEL ] in remap_get_list_dict .values ()
162+ edge for edge in edges_lst if edge [TARGET_LABEL ] in remap_get_list_dict .values ()
153163 ]
154164
155165 edge_get_list_updated_lst = []
156166 for edge in edges_lst :
157167 if edge [SOURCE_LABEL ] in remap_get_list_dict .values ():
158168 connected_edge = [
159- edge_con for edge_con in remap_get_list_remove_edges
169+ edge_con
170+ for edge_con in remap_get_list_remove_edges
160171 if edge_con [TARGET_LABEL ] == edge [SOURCE_LABEL ]
161172 ][- 1 ]
162173 edge_updated = {
@@ -207,7 +218,9 @@ def write_workflow_json(graph_as_dict: dict, file_name: str = "workflow.json"):
207218 {
208219 SOURCE_LABEL : nodes_final_order_dict [source ],
209220 SOURCE_PORT_LABEL : sourcehandle ,
210- TARGET_LABEL : nodes_final_order_dict [source_dict [k ][- 1 ][TARGET_LABEL ]],
221+ TARGET_LABEL : nodes_final_order_dict [
222+ source_dict [k ][- 1 ][TARGET_LABEL ]
223+ ],
211224 TARGET_PORT_LABEL : source_dict [k ][- 1 ][TARGET_PORT_LABEL ][2 :],
212225 }
213226 )
@@ -216,47 +229,62 @@ def write_workflow_json(graph_as_dict: dict, file_name: str = "workflow.json"):
216229 {
217230 SOURCE_LABEL : nodes_final_order_dict [source ],
218231 SOURCE_PORT_LABEL : sourcehandle ,
219- TARGET_LABEL : nodes_final_order_dict [source_dict [k ][- 1 ][TARGET_LABEL ]],
232+ TARGET_LABEL : nodes_final_order_dict [
233+ source_dict [k ][- 1 ][TARGET_LABEL ]
234+ ],
220235 TARGET_PORT_LABEL : source_dict [k ][- 1 ][TARGET_PORT_LABEL ],
221236 }
222237 )
223238
224239 nodes_to_skip = nodes_to_delete + list (pyiron_workflow_modules .keys ())
225240 for edge in edge_get_list_updated_lst :
226241 if (
227- edge [TARGET_LABEL ] not in nodes_to_skip
228- and edge [SOURCE_LABEL ] not in nodes_to_skip
242+ edge [TARGET_LABEL ] not in nodes_to_skip
243+ and edge [SOURCE_LABEL ] not in nodes_to_skip
229244 ):
230245 source_node = nodes_remaining_dict [edge [SOURCE_LABEL ]]
231- if isfunction (source_node ) and source_node .__name__ == edge [SOURCE_PORT_LABEL ]:
232- edge_new_lst .append ({
233- TARGET_LABEL : nodes_final_order_dict [edge [TARGET_LABEL ]],
234- TARGET_PORT_LABEL : edge [TARGET_PORT_LABEL ],
235- SOURCE_LABEL : nodes_final_order_dict [edge [SOURCE_LABEL ]],
236- SOURCE_PORT_LABEL : None ,
237- })
238- elif isfunction (source_node ) and source_node .__name__ == "get_dict" and edge [SOURCE_PORT_LABEL ] == "dict" :
239- edge_new_lst .append ({
240- TARGET_LABEL : nodes_final_order_dict [edge [TARGET_LABEL ]],
241- TARGET_PORT_LABEL : edge [TARGET_PORT_LABEL ],
242- SOURCE_LABEL : nodes_final_order_dict [edge [SOURCE_LABEL ]],
243- SOURCE_PORT_LABEL : None ,
244- })
246+ if (
247+ isfunction (source_node )
248+ and source_node .__name__ == edge [SOURCE_PORT_LABEL ]
249+ ):
250+ edge_new_lst .append (
251+ {
252+ TARGET_LABEL : nodes_final_order_dict [edge [TARGET_LABEL ]],
253+ TARGET_PORT_LABEL : edge [TARGET_PORT_LABEL ],
254+ SOURCE_LABEL : nodes_final_order_dict [edge [SOURCE_LABEL ]],
255+ SOURCE_PORT_LABEL : None ,
256+ }
257+ )
258+ elif (
259+ isfunction (source_node )
260+ and source_node .__name__ == "get_dict"
261+ and edge [SOURCE_PORT_LABEL ] == "dict"
262+ ):
263+ edge_new_lst .append (
264+ {
265+ TARGET_LABEL : nodes_final_order_dict [edge [TARGET_LABEL ]],
266+ TARGET_PORT_LABEL : edge [TARGET_PORT_LABEL ],
267+ SOURCE_LABEL : nodes_final_order_dict [edge [SOURCE_LABEL ]],
268+ SOURCE_PORT_LABEL : None ,
269+ }
270+ )
245271 else :
246- edge_new_lst .append ({
247- TARGET_LABEL : nodes_final_order_dict [edge [TARGET_LABEL ]],
248- TARGET_PORT_LABEL : edge [TARGET_PORT_LABEL ],
249- SOURCE_LABEL : nodes_final_order_dict [edge [SOURCE_LABEL ]],
250- SOURCE_PORT_LABEL : edge [SOURCE_PORT_LABEL ],
251- })
272+ edge_new_lst .append (
273+ {
274+ TARGET_LABEL : nodes_final_order_dict [edge [TARGET_LABEL ]],
275+ TARGET_PORT_LABEL : edge [TARGET_PORT_LABEL ],
276+ SOURCE_LABEL : nodes_final_order_dict [edge [SOURCE_LABEL ]],
277+ SOURCE_PORT_LABEL : edge [SOURCE_PORT_LABEL ],
278+ }
279+ )
252280
253281 PythonWorkflowDefinitionWorkflow (
254282 ** set_result_node (
255283 workflow_dict = update_node_names (
256284 workflow_dict = {
257285 VERSION_LABEL : VERSION_NUMBER ,
258286 NODES_LABEL : nodes_store_lst ,
259- EDGES_LABEL : edge_updated_lst ,
287+ EDGES_LABEL : edge_new_lst ,
260288 }
261289 )
262290 )
0 commit comments