Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ different workflow engines to enable interoperability.
### Simple Example
As a first example we define two Python functions which add multiple inputs:
```python
def add_x_and_y(x, y):
def get_sum(x, y):
return x + y

def get_prod_and_div(x: float, y: float) -> dict:
Expand All @@ -25,7 +25,7 @@ def get_prod_and_div(x: float, y: float) -> dict:
These two Python functions are combined in the following example workflow:
```python
tmp_dict = get_prod_and_div(x=1, y=2)
result = add_x_and_y(x=tmp_dict["prod"], y=tmp_dict["div"])
result = get_sum(x=tmp_dict["prod"], y=tmp_dict["div"])
```
For the workflow representation of these Python functions the Python functions are stored in the [simple_workflow.py](simple_workflow.py)
Python module. The connection of the Python functions are stored in the [workflow_simple.json](workflow_simple.json)
Expand All @@ -34,7 +34,7 @@ JSON file:
{
"nodes": [
{"id": 0, "function": "simple_workflow.get_prod_and_div"},
{"id": 1, "function": "simple_workflow.add_x_and_y"},
{"id": 1, "function": "simple_workflow.get_sum"},
{"id": 2, "value": 1},
{"id": 3, "value": 2}
],
Expand Down
16 changes: 14 additions & 2 deletions aiida_simple.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@
},
{
"cell_type": "code",
"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)",
"source": [
"from simple_workflow import (\n",
" get_sum as _get_sum,\n",
" get_prod_and_div as _get_prod_and_div,\n",
")"
],
"metadata": {
"trusted": true
},
Expand All @@ -69,7 +74,14 @@
},
{
"cell_type": "code",
"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)",
"source": [
"get_sum_task = wg.add_task(\n",
" _get_sum,\n",
" name=\"get_sum\",\n",
" x=get_prod_and_div_task.outputs.prod,\n",
" y=get_prod_and_div_task.outputs.div,\n",
")"
],
"metadata": {
"trusted": true
},
Expand Down
6 changes: 3 additions & 3 deletions book/simple.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Simple Workflow
As a first example we define two Python functions which add multiple inputs:
```python
def add_x_and_y(x, y):
def get_sum(x, y):
return x + y

def get_prod_and_div(x: float, y: float) -> dict:
Expand All @@ -10,7 +10,7 @@ def get_prod_and_div(x: float, y: float) -> dict:
These two Python functions are combined in the following example workflow:
```python
tmp_dict = get_prod_and_div(x=1, y=2)
result = add_x_and_y(x=tmp_dict["prod"], y=tmp_dict["div"])
result = get_sum(x=tmp_dict["prod"], y=tmp_dict["div"])
```
For the workflow representation of these Python functions the Python functions are stored in the [simple_workflow.py](simple_workflow.py)
Python module. The connection of the Python functions are stored in the [workflow_simple.json](workflow_simple.json)
Expand All @@ -19,7 +19,7 @@ JSON file:
{
"nodes": [
{"id": 0, "function": "simple_workflow.get_prod_and_div"},
{"id": 1, "function": "simple_workflow.add_x_and_y"},
{"id": 1, "function": "simple_workflow.get_sum"},
{"id": 2, "value": 1},
{"id": 3, "value": 2}
],
Expand Down
14 changes: 11 additions & 3 deletions jobflow_simple.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@
{
"id": "fb847d49-7bf9-4839-9b99-c116d1b0e9ee",
"cell_type": "code",
"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)",
"source": [
"from simple_workflow import (\n",
" get_sum as _get_sum,\n",
" get_prod_and_div as _get_prod_and_div,\n",
")"
],
"metadata": {
"trusted": true
},
Expand All @@ -82,7 +87,10 @@
{
"id": "07598344-0f75-433b-8902-bea21a42088c",
"cell_type": "code",
"source": "add_x_and_y = job(_add_x_and_y)\nget_prod_and_div = job(_get_prod_and_div, data=[\"prod\", \"div\"])",
"source": [
"get_sum = job(_get_sum)\n",
"get_prod_and_div = job(_get_prod_and_div, data=[\"prod\", \"div\"])"
],
"metadata": {
"trusted": true
},
Expand All @@ -102,7 +110,7 @@
{
"id": "2b88a30a-e26b-4802-89b7-79ca08cc0af9",
"cell_type": "code",
"source": "w = add_x_and_y(x=obj.output.prod, y=obj.output.div)",
"source": "w = get_sum(x=obj.output.prod, y=obj.output.div)",
"metadata": {
"trusted": true
},
Expand Down
14 changes: 11 additions & 3 deletions pyiron_base_simple.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@
{
"id": "fb847d49-7bf9-4839-9b99-c116d1b0e9ee",
"cell_type": "code",
"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)",
"source": [
"from simple_workflow import (\n",
" get_sum as _get_sum,\n",
" get_prod_and_div as _get_prod_and_div,\n",
")"
],
"metadata": {
"trusted": true
},
Expand All @@ -76,7 +81,10 @@
{
"id": "07598344-0f75-433b-8902-bea21a42088c",
"cell_type": "code",
"source": "add_x_and_y = job(_add_x_and_y)\nget_prod_and_div = job(_get_prod_and_div, output_key_lst=[\"prod\", \"div\"])",
"source": [
"get_sum = job(_get_sum)\n",
"get_prod_and_div = job(_get_prod_and_div, output_key_lst=[\"prod\", \"div\"])"
],
"metadata": {
"trusted": true
},
Expand All @@ -96,7 +104,7 @@
{
"id": "a5e5ca63-2906-47c9-bac6-adebf8643cba",
"cell_type": "code",
"source": "w = add_x_and_y(x=obj.output.prod, y=obj.output.div)",
"source": "w = get_sum(x=obj.output.prod, y=obj.output.div)",
"metadata": {
"trusted": true
},
Expand Down
5 changes: 2 additions & 3 deletions simple_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ def get_prod_and_div(x, y):
return {"prod": x * y, "div": x / y}


def add_x_and_y(x, y):
w = x + y
return w
def get_sum(x, y):
return x + y
2 changes: 1 addition & 1 deletion workflow_simple.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"nodes": [
{"id": 0, "function": "simple_workflow.get_prod_and_div"},
{"id": 1, "function": "simple_workflow.add_x_and_y"},
{"id": 1, "function": "simple_workflow.get_sum"},
{"id": 2, "value": 1},
{"id": 3, "value": 2}
],
Expand Down
Loading