Skip to content

Commit 74734d8

Browse files
authored
Rename add_x_and_y`() to get_sum() (#69)
1 parent 020de38 commit 74734d8

File tree

7 files changed

+45
-18
lines changed

7 files changed

+45
-18
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ different workflow engines to enable interoperability.
1616
### Simple Example
1717
As a first example we define two Python functions which add multiple inputs:
1818
```python
19-
def add_x_and_y(x, y):
19+
def get_sum(x, y):
2020
return x + y
2121

2222
def get_prod_and_div(x: float, y: float) -> dict:
@@ -25,7 +25,7 @@ def get_prod_and_div(x: float, y: float) -> dict:
2525
These two Python functions are combined in the following example workflow:
2626
```python
2727
tmp_dict = get_prod_and_div(x=1, y=2)
28-
result = add_x_and_y(x=tmp_dict["prod"], y=tmp_dict["div"])
28+
result = get_sum(x=tmp_dict["prod"], y=tmp_dict["div"])
2929
```
3030
For the workflow representation of these Python functions the Python functions are stored in the [simple_workflow.py](simple_workflow.py)
3131
Python module. The connection of the Python functions are stored in the [workflow_simple.json](workflow_simple.json)
@@ -34,7 +34,7 @@ JSON file:
3434
{
3535
"nodes": [
3636
{"id": 0, "function": "simple_workflow.get_prod_and_div"},
37-
{"id": 1, "function": "simple_workflow.add_x_and_y"},
37+
{"id": 1, "function": "simple_workflow.get_sum"},
3838
{"id": 2, "value": 1},
3939
{"id": 3, "value": 2}
4040
],

aiida_simple.ipynb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@
4242
},
4343
{
4444
"cell_type": "code",
45-
"source": "from simple_workflow import (\n add_x_and_y as _add_x_and_y,\n get_prod_and_div as _get_prod_and_div,\n)",
45+
"source": [
46+
"from simple_workflow import (\n",
47+
" get_sum as _get_sum,\n",
48+
" get_prod_and_div as _get_prod_and_div,\n",
49+
")"
50+
],
4651
"metadata": {
4752
"trusted": true
4853
},
@@ -69,7 +74,14 @@
6974
},
7075
{
7176
"cell_type": "code",
72-
"source": "add_x_and_y_task = wg.add_task(\n _add_x_and_y,\n name=\"add_x_and_y\",\n x=get_prod_and_div_task.outputs.prod,\n y=get_prod_and_div_task.outputs.div,\n)",
77+
"source": [
78+
"get_sum_task = wg.add_task(\n",
79+
" _get_sum,\n",
80+
" name=\"get_sum\",\n",
81+
" x=get_prod_and_div_task.outputs.prod,\n",
82+
" y=get_prod_and_div_task.outputs.div,\n",
83+
")"
84+
],
7385
"metadata": {
7486
"trusted": true
7587
},

book/simple.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Simple Workflow
22
As a first example we define two Python functions which add multiple inputs:
33
```python
4-
def add_x_and_y(x, y):
4+
def get_sum(x, y):
55
return x + y
66

77
def get_prod_and_div(x: float, y: float) -> dict:
@@ -10,7 +10,7 @@ def get_prod_and_div(x: float, y: float) -> dict:
1010
These two Python functions are combined in the following example workflow:
1111
```python
1212
tmp_dict = get_prod_and_div(x=1, y=2)
13-
result = add_x_and_y(x=tmp_dict["prod"], y=tmp_dict["div"])
13+
result = get_sum(x=tmp_dict["prod"], y=tmp_dict["div"])
1414
```
1515
For the workflow representation of these Python functions the Python functions are stored in the [simple_workflow.py](simple_workflow.py)
1616
Python module. The connection of the Python functions are stored in the [workflow_simple.json](workflow_simple.json)
@@ -19,7 +19,7 @@ JSON file:
1919
{
2020
"nodes": [
2121
{"id": 0, "function": "simple_workflow.get_prod_and_div"},
22-
{"id": 1, "function": "simple_workflow.add_x_and_y"},
22+
{"id": 1, "function": "simple_workflow.get_sum"},
2323
{"id": 2, "value": 1},
2424
{"id": 3, "value": 2}
2525
],

jobflow_simple.ipynb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@
6262
{
6363
"id": "fb847d49-7bf9-4839-9b99-c116d1b0e9ee",
6464
"cell_type": "code",
65-
"source": "from simple_workflow import (\n add_x_and_y as _add_x_and_y, \n get_prod_and_div as _get_prod_and_div,\n)",
65+
"source": [
66+
"from simple_workflow import (\n",
67+
" get_sum as _get_sum,\n",
68+
" get_prod_and_div as _get_prod_and_div,\n",
69+
")"
70+
],
6671
"metadata": {
6772
"trusted": true
6873
},
@@ -82,7 +87,10 @@
8287
{
8388
"id": "07598344-0f75-433b-8902-bea21a42088c",
8489
"cell_type": "code",
85-
"source": "add_x_and_y = job(_add_x_and_y)\nget_prod_and_div = job(_get_prod_and_div, data=[\"prod\", \"div\"])",
90+
"source": [
91+
"get_sum = job(_get_sum)\n",
92+
"get_prod_and_div = job(_get_prod_and_div, data=[\"prod\", \"div\"])"
93+
],
8694
"metadata": {
8795
"trusted": true
8896
},
@@ -102,7 +110,7 @@
102110
{
103111
"id": "2b88a30a-e26b-4802-89b7-79ca08cc0af9",
104112
"cell_type": "code",
105-
"source": "w = add_x_and_y(x=obj.output.prod, y=obj.output.div)",
113+
"source": "w = get_sum(x=obj.output.prod, y=obj.output.div)",
106114
"metadata": {
107115
"trusted": true
108116
},

pyiron_base_simple.ipynb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@
5656
{
5757
"id": "fb847d49-7bf9-4839-9b99-c116d1b0e9ee",
5858
"cell_type": "code",
59-
"source": "from simple_workflow import (\n add_x_and_y as _add_x_and_y, \n get_prod_and_div as _get_prod_and_div,\n)",
59+
"source": [
60+
"from simple_workflow import (\n",
61+
" get_sum as _get_sum,\n",
62+
" get_prod_and_div as _get_prod_and_div,\n",
63+
")"
64+
],
6065
"metadata": {
6166
"trusted": true
6267
},
@@ -76,7 +81,10 @@
7681
{
7782
"id": "07598344-0f75-433b-8902-bea21a42088c",
7883
"cell_type": "code",
79-
"source": "add_x_and_y = job(_add_x_and_y)\nget_prod_and_div = job(_get_prod_and_div, output_key_lst=[\"prod\", \"div\"])",
84+
"source": [
85+
"get_sum = job(_get_sum)\n",
86+
"get_prod_and_div = job(_get_prod_and_div, output_key_lst=[\"prod\", \"div\"])"
87+
],
8088
"metadata": {
8189
"trusted": true
8290
},
@@ -96,7 +104,7 @@
96104
{
97105
"id": "a5e5ca63-2906-47c9-bac6-adebf8643cba",
98106
"cell_type": "code",
99-
"source": "w = add_x_and_y(x=obj.output.prod, y=obj.output.div)",
107+
"source": "w = get_sum(x=obj.output.prod, y=obj.output.div)",
100108
"metadata": {
101109
"trusted": true
102110
},

simple_workflow.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ def get_prod_and_div(x, y):
22
return {"prod": x * y, "div": x / y}
33

44

5-
def add_x_and_y(x, y):
6-
w = x + y
7-
return w
5+
def get_sum(x, y):
6+
return x + y

workflow_simple.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"nodes": [
33
{"id": 0, "function": "simple_workflow.get_prod_and_div"},
4-
{"id": 1, "function": "simple_workflow.add_x_and_y"},
4+
{"id": 1, "function": "simple_workflow.get_sum"},
55
{"id": 2, "value": 1},
66
{"id": 3, "value": 2}
77
],

0 commit comments

Comments
 (0)