File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
python_workflow_definition/src/python_workflow_definition Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 1+ from collections import Counter
12from inspect import isfunction
23from importlib import import_module
34from typing import Any
@@ -217,12 +218,19 @@ def load_workflow_json(file_name: str) -> Workflow:
217218 {}
218219 ) # Type is actually more restrictive, must be jsonifyable object
219220 nodes : dict [int , Function ] = {}
221+ total_counter_dict = Counter ([n ["value" ] for n in content [NODES_LABEL ] if n ["type" ] == "function" ])
222+ counter_dict = {k : - 1 for k in total_counter_dict .keys ()}
220223 wf = Workflow (file_name .split ("." )[0 ])
221224 for node_dict in content [NODES_LABEL ]:
222225 if node_dict ["type" ] == "function" :
223226 fnc = import_from_string (node_dict ["value" ])
227+ if total_counter_dict [node_dict ["value" ]] > 1 :
228+ counter_dict [node_dict ["value" ]] += 1
229+ name = fnc .__name__ + "_" + str (counter_dict [node_dict ["value" ]])
230+ else :
231+ name = fnc .__name__
224232 n = function_node (
225- fnc , output_labels = fnc . __name__ # Strictly force single-output
233+ fnc , output_labels = name # Strictly force single-output
226234 )
227235 nodes [node_dict ["id" ]] = n
228236 wf .add_child (n )
You can’t perform that action at this time.
0 commit comments