@@ -17,41 +17,32 @@ different workflow engines to enable interoperability.
1717As a first example we define two Python functions which add multiple inputs:
1818``` python
1919def add_x_and_y (x , y ):
20- z = x + y
21- return x, y, z
22-
23- def add_x_and_y_and_z (x , y , z ):
24- w = x + y + z
25- return w
20+ return x + y
21+
22+ def get_prod_and_div (x : float , y : float ) -> dict :
23+ return {" prod" : x * y, " div" : x / y}
2624```
2725These two Python functions are combined in the following example workflow:
2826``` python
29- x, y, z = add_x_and_y (x = 1 , y = 2 )
30- w = add_x_and_y_and_z (x = x , y = y, z = z )
27+ tmp_dict = get_prod_and_div (x = 1 , y = 2 )
28+ result = add_x_and_y (x = tmp_dict[ " prod " ] , y = tmp_dict[ " div " ] )
3129```
3230For the workflow representation of these Python functions the Python functions are stored in the [ simple_workflow.py] ( simple_workflow.py )
3331Python module. The connection of the Python functions are stored in the [ workflow_simple.json] ( workflow_simple.json )
3432JSON file:
3533```
3634{
3735 "nodes": [
38- {"id": 0, "function": "simple_workflow.add_x_and_y_and_z "},
36+ {"id": 0, "function": "simple_workflow.get_prod_and_div "},
3937 {"id": 1, "function": "simple_workflow.add_x_and_y"},
40- {"id": 2, "function": "simple_workflow.add_x_and_y"},
41- {"id": 3, "function": "simple_workflow.add_x_and_y"},
42- {"id": 4, "value": 1},
43- {"id": 5, "value": 2}
38+ {"id": 2, "value": 1},
39+ {"id": 3, "value": 2}
4440 ],
4541 "edges": [
46- {"target": 0, "targetPort": "x", "source": 1, "sourcePort": "x"},
47- {"target": 1, "targetPort": "x", "source": 4, "sourcePort": null},
48- {"target": 1, "targetPort": "y", "source": 5, "sourcePort": null},
49- {"target": 0, "targetPort": "y", "source": 2, "sourcePort": "y"},
50- {"target": 2, "targetPort": "x", "source": 4, "sourcePort": null},
51- {"target": 2, "targetPort": "y", "source": 5, "sourcePort": null},
52- {"target": 0, "targetPort": "z", "source": 3, "sourcePort": "z"},
53- {"target": 3, "targetPort": "x", "source": 4, "sourcePort": null},
54- {"target": 3, "targetPort": "y", "source": 5, "sourcePort": null}
42+ {"target": 0, "targetPort": "x", "source": 2, "sourcePort": null},
43+ {"target": 0, "targetPort": "y", "source": 3, "sourcePort": null},
44+ {"target": 1, "targetPort": "x", "source": 0, "sourcePort": "prod"},
45+ {"target": 1, "targetPort": "y", "source": 0, "sourcePort": "div"}
5546 ]
5647}
5748```
0 commit comments