Skip to content

Commit 97bac14

Browse files
committed
initial commit
0 parents  commit 97bac14

File tree

8 files changed

+121
-0
lines changed

8 files changed

+121
-0
lines changed

.ci_support/aiida.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from python_workflow_definition.aiida import load_workflow_json
2+
from aiida import load_profile
3+
4+
5+
if __name__ == "__main__":
6+
load_profile()
7+
workgraph = load_workflow_json(file_name='workflow.json')
8+
workgraph.run()

.ci_support/jobflow.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from jobflow.managers.local import run_locally
2+
from python_workflow_definition.jobflow import load_workflow_json
3+
4+
5+
if __name__ == "__main__":
6+
flow = load_workflow_json(file_name="workflow.json")
7+
print(run_locally(flow))

.ci_support/pyiron.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from python_workflow_definition.pyiron_base import load_workflow_json
2+
3+
4+
if __name__ == "__main__":
5+
delayed_object_lst = load_workflow_json(file_name="workflow.json")
6+
print(delayed_object_lst[-1].pull())

.github/workflows/pipeline.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
8+
jobs:
9+
aiida:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Conda config
14+
run: echo -e "channels:\n - conda-forge\n" > .condarc
15+
- uses: conda-incubator/setup-miniconda@v3
16+
with:
17+
python-version: "3.12"
18+
miniforge-version: latest
19+
condarc-file: .condarc
20+
environment-file: environment.yml
21+
- name: Installation and setup
22+
shell: bash -l {0}
23+
run: |
24+
pip install python-workflow-definition
25+
verdi presto --profile-name pwd
26+
- name: Tests
27+
shell: bash -l {0}
28+
run: python .ci_support/aiida.py
29+
30+
jobflow:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Conda config
35+
run: echo -e "channels:\n - conda-forge\n" > .condarc
36+
- uses: conda-incubator/setup-miniconda@v3
37+
with:
38+
python-version: "3.12"
39+
miniforge-version: latest
40+
condarc-file: .condarc
41+
environment-file: environment.yml
42+
- name: Installation and setup
43+
shell: bash -l {0}
44+
run: pip install python-workflow-definition
45+
- name: Tests
46+
shell: bash -l {0}
47+
run: python .ci_support/jobflow.py
48+
49+
pyiron:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
- name: Conda config
54+
run: echo -e "channels:\n - conda-forge\n" > .condarc
55+
- uses: conda-incubator/setup-miniconda@v3
56+
with:
57+
python-version: "3.12"
58+
miniforge-version: latest
59+
condarc-file: .condarc
60+
environment-file: environment.yml
61+
- name: Installation and setup
62+
shell: bash -l {0}
63+
run: pip install python-workflow-definition
64+
- name: Tests
65+
shell: bash -l {0}
66+
run: python .ci_support/pyiron.py

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Arithmetic Example Workflow
2+
[![Pipeline](https://github.com/pythonworkflow/example-workflow/actions/workflows/pipeline.yml/badge.svg)](https://github.com/pythonworkflow/example-workflow/actions/workflows/pipeline.yml)
3+
4+
Demonstration for publishing an interoperable workflow based on the Python Workflow Definition. The minimal workflow consists of three files:
5+
6+
| File | Explanation |
7+
|-----------------|---------------------------------------------------------|
8+
| environment.yml | Conda environment for software dependencies |
9+
| workflow.py | Python functions representing the nodes of the workflow |
10+
| workflow.json | Workflow graph consisting of nodes and edges |

environment.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
channels:
2+
- conda-forge
3+
dependencies:
4+
- python =3.12

workflow.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"nodes": [
3+
{"id": 0, "function": "workflow.get_prod_and_div"},
4+
{"id": 1, "function": "workflow.get_sum"},
5+
{"id": 2, "value": 1},
6+
{"id": 3, "value": 2}
7+
],
8+
"edges": [
9+
{"target": 0, "targetPort": "x", "source": 2, "sourcePort": null},
10+
{"target": 0, "targetPort": "y", "source": 3, "sourcePort": null},
11+
{"target": 1, "targetPort": "x", "source": 0, "sourcePort": "prod"},
12+
{"target": 1, "targetPort": "y", "source": 0, "sourcePort": "div"}
13+
]
14+
}

workflow.py

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

0 commit comments

Comments
 (0)