Skip to content

Commit 7178a2c

Browse files
committed
fix jobflow
1 parent 9643178 commit 7178a2c

File tree

1 file changed

+21
-21
lines changed
  • python_workflow_definition/src/python_workflow_definition

1 file changed

+21
-21
lines changed

python_workflow_definition/src/python_workflow_definition/jobflow.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,27 @@ def _get_nodes_dict(function_dict):
2626

2727
def _get_edge_from_dict(target, key, value_dict, nodes_mapping_dict):
2828
if len(value_dict['attributes']) == 1:
29-
return {'tn': target, 'th': key, "source": 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, "source": 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

3434
def _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, "source": node_index, 'sh': None})
63-
edges_lst.append({'tn': nodes_mapping_dict[job["uuid"]], 'th': k, "source": 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, "source": node_index, 'sh': None})
82-
edges_lst.append({'tn': nodes_mapping_dict[job["uuid"]], 'th': k, "source": 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, "source": 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

@@ -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

Comments
 (0)