Skip to content

Commit 5c311c8

Browse files
authored
Initial commit
0 parents  commit 5c311c8

File tree

5 files changed

+118
-0
lines changed

5 files changed

+118
-0
lines changed

.github/workflows/pipeline.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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: Test
22+
shell: bash -l {0}
23+
run: |
24+
verdi presto --profile-name pwd
25+
echo -e 'from aiida import load_profile\nload_profile()\n\nfrom python_workflow_definition.aiida import load_workflow_json\n\n\nif __name__ == "__main__":\n workgraph = load_workflow_json(file_name="workflow.json")\n workgraph.run()' > test_with_aiida.py
26+
python test_with_aiida.py
27+
28+
jobflow:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
- name: Conda config
33+
run: echo -e "channels:\n - conda-forge\n" > .condarc
34+
- uses: conda-incubator/setup-miniconda@v3
35+
with:
36+
python-version: "3.12"
37+
miniforge-version: latest
38+
condarc-file: .condarc
39+
environment-file: environment.yml
40+
- name: Test
41+
shell: bash -l {0}
42+
run: |
43+
echo -e 'from jobflow.managers.local import run_locally\nfrom python_workflow_definition.jobflow import load_workflow_json\n\n\nif __name__ == "__main__":\n flow = load_workflow_json(file_name="workflow.json")\n print(run_locally(flow))' > test_with_jobflow.py
44+
python test_with_jobflow.py
45+
46+
pyiron:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
- name: Conda config
51+
run: echo -e "channels:\n - conda-forge\n" > .condarc
52+
- uses: conda-incubator/setup-miniconda@v3
53+
with:
54+
python-version: "3.12"
55+
miniforge-version: latest
56+
condarc-file: .condarc
57+
environment-file: environment.yml
58+
- name: Test
59+
shell: bash -l {0}
60+
run: |
61+
echo -e 'from python_workflow_definition.pyiron_base import load_workflow_json\n\n\nif __name__ == "__main__":\n delayed_object_lst = load_workflow_json(file_name="workflow.json")\n print(delayed_object_lst[-1].pull())' > test_with_pyiron.py
62+
python test_with_pyiron.py

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
Template repository for publishing an interoperable workflow based on the Python Workflow Definition.
5+
6+
## Content
7+
The minimal workflow consists of three files:
8+
9+
| File | Explanation |
10+
|-------------------|---------------------------------------------------------|
11+
| `environment.yml` | Conda environment for software dependencies |
12+
| `workflow.py` | Python functions representing the nodes of the workflow |
13+
| `workflow.json` | Workflow graph consisting of nodes and edges |
14+
15+
Additional optional files for the publication of the workflow:
16+
17+
| File | Explanation |
18+
|----------------------------------|------------------------------------------|
19+
| `README.md` | Readme file to introduce the workflow |
20+
| `.github/workflows/pipeline.yml` | Github Actions to test the workflow |
21+
22+
## Publish your workflow
23+
You can publish your workflow in five simple steps:
24+
* Fork the repository and clone your fork locally.
25+
* Export your workflow to the Python Workflow Definition using the `python_workflow_definition` Python package, by calling the `write_workflow_json()` function.
26+
* Replace the `environment.yml`, `workflow.py` and `workflow.json` in your local folder with the files for your workflow. In addition, you can add additional files if they are required and update the `README.md` to explain your workflow.
27+
* Commit the files locally using `git add -A` and `git commit -m "add my workflow"`
28+
* Push your workflow to Github `git push`
29+
30+

environment.yml

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

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)