Skip to content

Commit d96a2a7

Browse files
committed
Update version to 0.1.0
1 parent b63e48a commit d96a2a7

File tree

3 files changed

+57
-23
lines changed

3 files changed

+57
-23
lines changed

.github/workflows/pipeline.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- name: Test
2222
shell: bash -l {0}
2323
run: |
24+
conda install -c conda-forge -y aiida-workgraph=0.5.2
2425
sudo apt-get install -y $(cat apt.txt)
2526
conda env create -n preprocessing -f source/envs/preprocessing.yaml -y
2627
conda env create -n processing -f source/envs/processing.yaml -y
@@ -44,6 +45,7 @@ jobs:
4445
- name: Test
4546
shell: bash -l {0}
4647
run: |
48+
conda install -c conda-forge -y jobflow=0.1.19
4749
sudo apt-get install -y $(cat apt.txt)
4850
conda env create -n preprocessing -f source/envs/preprocessing.yaml -y
4951
conda env create -n processing -f source/envs/processing.yaml -y
@@ -66,9 +68,34 @@ jobs:
6668
- name: Test
6769
shell: bash -l {0}
6870
run: |
71+
conda install -c conda-forge -y pyiron_base=0.11.11
6972
sudo apt-get install -y $(cat apt.txt)
7073
conda env create -n preprocessing -f source/envs/preprocessing.yaml -y
7174
conda env create -n processing -f source/envs/processing.yaml -y
7275
conda env create -n postprocessing -f source/envs/postprocessing.yaml -y
7376
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
7477
python test_with_pyiron.py
78+
79+
cwl:
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v4
83+
- name: Conda config
84+
run: echo -e "channels:\n - conda-forge\n" > .condarc
85+
- uses: conda-incubator/setup-miniconda@v3
86+
with:
87+
python-version: "3.12"
88+
miniforge-version: latest
89+
condarc-file: .condarc
90+
environment-file: environment.yml
91+
- name: Test
92+
shell: bash -l {0}
93+
run: |
94+
conda install -c conda-forge -y cwltool=3.1.20250110105449
95+
sudo apt-get install -y $(cat apt.txt)
96+
conda env create -n preprocessing -f source/envs/preprocessing.yaml -y
97+
conda env create -n processing -f source/envs/processing.yaml -y
98+
conda env create -n postprocessing -f source/envs/postprocessing.yaml -y
99+
echo -e 'from python_workflow_definition.cwl import write_workflow\n\n\nif __name__ == "__main__":\n with open("workflow.json") as f:\n content = json.load(f)\n node_lst = []\n for n in content["nodes"]:\n if "name" in n and n["name"] == "source_directory":\n n["value"] = os.path.abspath(n["value"])\n node_lst.append(n)\n content["nodes"] = node_lst\n with open("workflow.json", "w") as f:\n json.dump(content, f)\n write_workflow(file_name="workflow.json")' > test_with_cwl.py
100+
python test_with_cwl.py
101+
cwltool workflow.cwl workflow.yml

workflow.json

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
{
2+
"version": "0.1.0",
23
"nodes": [
3-
{"id": 0, "function": "workflow.generate_mesh"},
4-
{"id": 1, "function": "workflow.convert_to_xdmf"},
5-
{"id": 2, "function": "workflow.poisson"},
6-
{"id": 3, "function": "workflow.plot_over_line"},
7-
{"id": 4, "function": "workflow.substitute_macros"},
8-
{"id": 5, "function": "workflow.compile_paper"},
9-
{"id": 6, "value": 2.0}
4+
{"id": 0, "type": "function", "value": "workflow.generate_mesh"},
5+
{"id": 1, "type": "function", "value": "workflow.convert_to_xdmf"},
6+
{"id": 2, "type": "function", "value": "workflow.poisson"},
7+
{"id": 3, "type": "function", "value": "workflow.plot_over_line"},
8+
{"id": 4, "type": "function", "value": "workflow.substitute_macros"},
9+
{"id": 5, "type": "function", "value": "workflow.compile_paper"},
10+
{"id": 6, "type": "input", "value": 2.0, "name": "domain_size"},
11+
{"id": 7, "type": "input", "value": "source", "name": "source_directory"},
12+
{"id": 8, "type": "output", "name": "result"}
1013
],
1114
"edges": [
1215
{"target": 0, "targetPort": "domain_size", "source": 6, "sourcePort": null},
16+
{"target": 0, "targetPort": "source_directory", "source": 7, "sourcePort": null},
1317
{"target": 1, "targetPort": "gmsh_output_file", "source": 0, "sourcePort": null},
1418
{"target": 2, "targetPort": "meshio_output_xdmf", "source": 1, "sourcePort": "xdmf_file"},
1519
{"target": 2, "targetPort": "meshio_output_h5", "source": 1, "sourcePort": "h5_file"},
20+
{"target": 2, "targetPort": "source_directory", "source": 7, "sourcePort": null},
1621
{"target": 3, "targetPort": "poisson_output_pvd_file", "source": 2, "sourcePort": "pvd_file"},
1722
{"target": 3, "targetPort": "poisson_output_vtu_file", "source": 2, "sourcePort": "vtu_file"},
23+
{"target": 3, "targetPort": "source_directory", "source": 7, "sourcePort": null},
1824
{"target": 4, "targetPort": "pvbatch_output_file", "source": 3, "sourcePort": null},
1925
{"target": 4, "targetPort": "ndofs", "source": 2, "sourcePort": "numdofs"},
2026
{"target": 4, "targetPort": "domain_size", "source": 6, "sourcePort": null},
27+
{"target": 4, "targetPort": "source_directory", "source": 7, "sourcePort": null},
2128
{"target": 5, "targetPort": "macros_tex", "source": 4, "sourcePort": null},
22-
{"target": 5, "targetPort": "plot_file", "source": 3, "sourcePort": null}
29+
{"target": 5, "targetPort": "plot_file", "source": 3, "sourcePort": null},
30+
{"target": 5, "targetPort": "source_directory", "source": 7, "sourcePort": null},
31+
{"target": 8, "targetPort": null, "source": 5, "sourcePort": null}
2332
]
2433
}

workflow.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
from conda_subprocess import check_output
33
import shutil
44

5-
source_directory = os.path.join(os.path.dirname(os.path.abspath(__file__)), "source")
65

7-
8-
def generate_mesh(domain_size: float = 2.0) -> str:
6+
def generate_mesh(domain_size: float, source_directory: str) -> str:
97
stage_name = "preprocessing"
108
gmsh_output_file_name = "square.msh"
119
source_file_name ="unit_square.geo"
1210
os.makedirs(stage_name, exist_ok=True)
13-
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name)
11+
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name, source_directory=source_directory)
1412
_ = check_output(
1513
[
1614
"gmsh", "-2", "-setnumber", "domain_size", str(domain_size),
@@ -40,13 +38,13 @@ def convert_to_xdmf(gmsh_output_file : str) -> dict:
4038
}
4139

4240

43-
def poisson(meshio_output_xdmf: str, meshio_output_h5: str) -> dict:
41+
def poisson(meshio_output_xdmf: str, meshio_output_h5: str, source_directory: str) -> dict:
4442
stage_name = "processing"
4543
poisson_output_pvd_file_name = "poisson.pvd"
4644
poisson_output_numdofs_file_name = "numdofs.txt"
4745
source_file_name = "poisson.py"
4846
os.makedirs(stage_name, exist_ok=True)
49-
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name)
47+
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name, source_directory=source_directory)
5048
_copy_file(stage_name=stage_name, source_file=meshio_output_xdmf)
5149
_copy_file(stage_name=stage_name, source_file=meshio_output_h5)
5250
_ = check_output(
@@ -65,12 +63,12 @@ def poisson(meshio_output_xdmf: str, meshio_output_h5: str) -> dict:
6563
}
6664

6765

68-
def plot_over_line(poisson_output_pvd_file: str, poisson_output_vtu_file: str) -> str:
66+
def plot_over_line(poisson_output_pvd_file: str, poisson_output_vtu_file: str, source_directory: str) -> str:
6967
stage_name = "postprocessing"
7068
pvbatch_output_file_name = "plotoverline.csv"
7169
source_file_name = "postprocessing.py"
7270
os.makedirs(stage_name, exist_ok=True)
73-
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name)
71+
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name, source_directory=source_directory)
7472
_copy_file(stage_name=stage_name, source_file=poisson_output_pvd_file)
7573
_copy_file(stage_name=stage_name, source_file=poisson_output_vtu_file)
7674
_ = check_output(
@@ -82,14 +80,14 @@ def plot_over_line(poisson_output_pvd_file: str, poisson_output_vtu_file: str) -
8280
return os.path.abspath(os.path.join("postprocessing", pvbatch_output_file_name))
8381

8482

85-
def substitute_macros(pvbatch_output_file: str, ndofs: int, domain_size: float = 2.0) -> str:
83+
def substitute_macros(pvbatch_output_file: str, ndofs: int, domain_size: float, source_directory: str) -> str:
8684
stage_name = "postprocessing"
8785
source_file_name = "prepare_paper_macros.py"
8886
template_file_name = "macros.tex.template"
8987
macros_output_file_name = "macros.tex"
9088
os.makedirs(stage_name, exist_ok=True)
91-
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name)
92-
_copy_file_from_source(stage_name=stage_name, source_file_name=template_file_name)
89+
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name, source_directory=source_directory)
90+
_copy_file_from_source(stage_name=stage_name, source_file_name=template_file_name, source_directory=source_directory)
9391
_copy_file(stage_name=stage_name, source_file=pvbatch_output_file)
9492
_ = check_output(
9593
[
@@ -104,12 +102,12 @@ def substitute_macros(pvbatch_output_file: str, ndofs: int, domain_size: float =
104102
return os.path.abspath(os.path.join(stage_name, macros_output_file_name))
105103

106104

107-
def compile_paper(macros_tex: str, plot_file: str) -> str:
105+
def compile_paper(macros_tex: str, plot_file: str, source_directory: str) -> str:
108106
stage_name = "postprocessing"
109107
paper_output = "paper.pdf"
110108
source_file_name = "paper.tex"
111109
os.makedirs(stage_name, exist_ok=True)
112-
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name)
110+
_copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name, source_directory=source_directory)
113111
_copy_file(stage_name=stage_name, source_file=macros_tex)
114112
_copy_file(stage_name=stage_name, source_file=plot_file)
115113
_ = check_output(
@@ -126,12 +124,12 @@ def _poisson_collect_output(numdofs_file: str) -> int:
126124
return int(f.read())
127125

128126

129-
def _copy_file(stage_name, source_file):
127+
def _copy_file(stage_name: str, source_file: str):
130128
input_file = os.path.join(os.path.abspath(stage_name), os.path.basename(source_file))
131129
if input_file != source_file:
132130
shutil.copyfile(source_file, input_file)
133131

134132

135-
def _copy_file_from_source(stage_name, source_file_name):
133+
def _copy_file_from_source(stage_name: str, source_file_name: str, source_directory: str):
136134
source_file = os.path.join(source_directory, source_file_name)
137135
shutil.copyfile(source_file, os.path.join(stage_name, source_file_name))

0 commit comments

Comments
 (0)