Skip to content

Commit b6c8a2a

Browse files
authored
Update to pyiron_base 0.9.7 with delayed execution (BAMresearch#81)
* Update pyiron_base to 0.9.6 * Use conda to manage environments * Update main.yml * Update README.md * Update workflow.py * Update workflow.py * Update main.yml * Update workflow.py
1 parent 870d70f commit b6c8a2a

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,13 @@ jobs:
294294
- name: run-workflow
295295
shell: bash -l {0}
296296
run: |
297-
conda install conda_subprocess=0.0.1 pyiron_base=0.8.0
297+
conda install conda_subprocess=0.0.4 pyiron_base=0.9.7
298298
cd $GITHUB_WORKSPACE/exemplary_workflow/pyiron
299299
python workflow.py
300300
- name: upload-paper-artifact
301301
uses: actions/upload-artifact@v2
302302
with:
303303
name: paper
304-
path: ./exemplary_workflow/pyiron/workflow/tectonic_hdf5/tectonic/paper.pdf
304+
path: ./exemplary_workflow/pyiron/paper.pdf
305305
retention-days: 1
306306
if-no-files-found: error

exemplary_workflow/pyiron/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The recommended way of installing `pyiron_base` is via conda, because it also en
77

88
You can then install `pyiron_base` with
99
```sh
10-
mamba create -c conda-forge -n pyiron_base pyiron_base=0.7.11 conda_subprocess=0.0.1
10+
mamba create -c conda-forge -n pyiron_base pyiron_base=0.9.7 conda_subprocess=0.0.4
1111
```
1212

1313
## Running the exemplary workflow
Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import shutil
23
from pyiron_base import Project
34

45
# input parameter
@@ -13,64 +14,82 @@
1314
"processing": "../source/envs/processing.yaml",
1415
"postprocessing": "../source/envs/postprocessing.yaml"
1516
}.items():
16-
pr.conda_environment.create(env_name=k, env_file=v)
17+
pr.conda_environment.create(env_name=k, env_file=v, global_installation=False)
1718

1819

1920
# Preprocessing
2021
## generate mesh
2122
gmsh = pr.wrap_executable(
22-
job_name="gmsh",
2323
executable_str=f"gmsh -2 -setnumber domain_size {domain_size} unit_square.geo -o square.msh",
2424
conda_environment_path=pr.conda_environment.preprocessing,
2525
input_file_lst=["../source/unit_square.geo"],
26-
execute_job=True,
26+
delayed=True,
27+
output_file_lst=["square.msh"],
2728
)
2829

2930
## convert mesh to xdmf
3031
meshio = pr.wrap_executable(
31-
job_name="meshio",
3232
executable_str="meshio convert square.msh square.xdmf",
3333
conda_environment_path=pr.conda_environment.preprocessing,
3434
input_file_lst=[gmsh.files.square_msh],
35-
execute_job=True,
35+
delayed=True,
36+
output_file_lst=["square.xdmf", "square.h5"],
3637
)
3738

3839

3940
# Processing
4041
## poisson
42+
def collect_output(working_directory):
43+
with open(os.path.join(working_directory, "numdofs.txt"), "r") as f:
44+
return {"numdofs": int(f.read())}
45+
4146
poisson = pr.wrap_executable(
42-
job_name="poisson",
4347
executable_str="python poisson.py --mesh square.xdmf --degree 2 --outputfile poisson.pvd --num-dofs numdofs.txt",
4448
conda_environment_path=pr.conda_environment.processing,
4549
input_file_lst=["../source/poisson.py", meshio.files.square_xdmf, meshio.files.square_h5],
46-
execute_job=True,
50+
delayed=True,
51+
collect_output_funct=collect_output,
52+
output_key_lst=["numdofs"],
53+
output_file_lst=["poisson.pvd", "poisson000000.vtu"],
4754
)
4855

4956

5057
# Postprocessing
5158
## plot over line
5259
pvbatch = pr.wrap_executable(
53-
job_name="pvbatch",
5460
executable_str="pvbatch postprocessing.py poisson.pvd plotoverline.csv",
5561
conda_environment_path=pr.conda_environment.postprocessing,
5662
input_file_lst=["../source/postprocessing.py", poisson.files.poisson_pvd, poisson.files.poisson000000_vtu],
57-
execute_job=True,
63+
delayed=True,
64+
output_file_lst=["plotoverline.csv"],
5865
)
5966

6067
## substitute macros
68+
def write_input(input_dict, working_directory):
69+
script_name = os.path.join(working_directory, "macros.sh")
70+
with open(script_name, "w") as f:
71+
f.writelines(f"python prepare_paper_macros.py --macro-template-file macros.tex.template --plot-data-path plotoverline.csv --domain-size {domain_size} --num-dofs {input_dict["numdofs"]} --output-macro-file macros.tex")
72+
os.chmod(script_name, 0o744)
73+
6174
macros = pr.wrap_executable(
62-
job_name="macros",
63-
executable_str=f"python prepare_paper_macros.py --macro-template-file macros.tex.template --plot-data-path plotoverline.csv --domain-size {domain_size} --num-dofs {int(poisson.output['stdout'].split()[-1])} --output-macro-file macros.tex",
75+
input_dict={"numdofs": poisson.output.numdofs},
76+
write_input_funct=write_input,
77+
executable_str="./macros.sh",
6478
conda_environment_path=pr.conda_environment.postprocessing,
6579
input_file_lst=["../source/macros.tex.template", "../source/prepare_paper_macros.py", pvbatch.files.plotoverline_csv],
66-
execute_job=True,
80+
delayed=True,
81+
output_file_lst=["macros.tex"],
6782
)
6883

6984
## compile paper
7085
tectonic = pr.wrap_executable(
71-
job_name="tectonic",
7286
executable_str="tectonic paper.tex",
7387
conda_environment_path=pr.conda_environment.postprocessing,
7488
input_file_lst=["../source/paper.tex", macros.files.macros_tex, pvbatch.files.plotoverline_csv],
75-
execute_job=True,
89+
delayed=True,
90+
output_file_lst=["paper.pdf"],
7691
)
92+
93+
# Execute Workflow Graph and copy output
94+
result = tectonic.pull()
95+
shutil.copyfile(str(result.files.paper_pdf), "paper.pdf")

0 commit comments

Comments
 (0)