diff --git a/README.md b/README.md index a2f70ea..b3688ce 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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) @@ -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} ], diff --git a/aiida_simple.ipynb b/aiida_simple.ipynb index 8bdbebb..6968ad6 100644 --- a/aiida_simple.ipynb +++ b/aiida_simple.ipynb @@ -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 }, @@ -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 }, diff --git a/book/simple.md b/book/simple.md index 41ae7bc..8514a9a 100644 --- a/book/simple.md +++ b/book/simple.md @@ -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: @@ -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) @@ -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} ], diff --git a/jobflow_simple.ipynb b/jobflow_simple.ipynb index 2bcaa7e..7614eec 100644 --- a/jobflow_simple.ipynb +++ b/jobflow_simple.ipynb @@ -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 }, @@ -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 }, @@ -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 }, diff --git a/pyiron_base_simple.ipynb b/pyiron_base_simple.ipynb index f4c6f7d..2b34f9a 100644 --- a/pyiron_base_simple.ipynb +++ b/pyiron_base_simple.ipynb @@ -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 }, @@ -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 }, @@ -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 }, diff --git a/simple_workflow.py b/simple_workflow.py index afc4d72..3a12993 100644 --- a/simple_workflow.py +++ b/simple_workflow.py @@ -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 \ No newline at end of file +def get_sum(x, y): + return x + y diff --git a/workflow_simple.json b/workflow_simple.json index 7e3bdcc..3e19d16 100644 --- a/workflow_simple.json +++ b/workflow_simple.json @@ -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} ],