diff --git a/example_workflows/nfdi/aiida.ipynb b/example_workflows/nfdi/aiida.ipynb index d8b5ab7..05a2f85 100644 --- a/example_workflows/nfdi/aiida.ipynb +++ b/example_workflows/nfdi/aiida.ipynb @@ -1,363 +1 @@ -{ - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12.8", - "mimetype": "text/x-python", - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "pygments_lexer": "ipython3", - "nbconvert_exporter": "python", - "file_extension": ".py" - } - }, - "nbformat_minor": 5, - "nbformat": 4, - "cells": [ - { - "id": "106ded66-d202-46ac-82b0-2755ca309bdd", - "cell_type": "markdown", - "source": "# Aiida\n\nhttps://github.com/BAMresearch/NFDI4IngScientificWorkflowRequirements", - "metadata": {} - }, - { - "id": "11e09b78-cb72-465f-9c8b-5b77f0aa729c", - "cell_type": "markdown", - "source": "## Define workflow with aiida", - "metadata": {} - }, - { - "id": "89c02460-b543-442c-a27e-f1757dc2262e", - "cell_type": "code", - "source": "from python_workflow_definition.aiida import write_workflow_json\n\nfrom aiida_workgraph import WorkGraph, task\nfrom aiida import orm, load_profile\nload_profile()", - "metadata": { - "trusted": true - }, - "outputs": [ - { - "execution_count": 1, - "output_type": "execute_result", - "data": { - "text/plain": "Profile" - }, - "metadata": {} - } - ], - "execution_count": 1 - }, - { - "metadata": {}, - "cell_type": "code", - "outputs": [], - "execution_count": null, - "source": [ - "from workflow import (\n", - " generate_mesh,\n", - " convert_to_xdmf as _convert_to_xdmf,\n", - " poisson as _poisson,\n", - " plot_over_line,\n", - " substitute_macros,\n", - " compile_paper,\n", - ")" - ], - "id": "6dac225a1ce86b25" - }, - { - "metadata": {}, - "cell_type": "code", - "outputs": [], - "execution_count": null, - "source": [ - "convert_to_xdmf = task(outputs=[\"xdmf_file\", \"h5_file\"])(_convert_to_xdmf)\n", - "poisson = task(outputs=[\"numdofs\", \"pvd_file\", \"vtu_file\"])(_poisson)" - ], - "id": "c47205d289499756" - }, - { - "id": "8d911f98-3b80-457f-a0f4-3cb37ebf1691", - "cell_type": "code", - "source": "domain_size = orm.Float(2.0)", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 4 - }, - { - "id": "1e7e14ba-c4a7-485f-9bd8-44625830cca0", - "cell_type": "code", - "source": "wg = WorkGraph(\"wg-nfdi\")", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 5 - }, - { - "id": "71d411b6-cbec-489e-99e3-ba71680bcb5b", - "cell_type": "code", - "source": "gmsh_output_file = wg.add_task(\n generate_mesh,\n name=\"generate_mesh\",\n domain_size=domain_size,\n)", - "metadata": { - "tags": [], - "trusted": true - }, - "outputs": [], - "execution_count": 6 - }, - { - "id": "1d0d9804-f250-48b3-a5d0-a546d520f79b", - "cell_type": "code", - "source": "meshio_output_dict = wg.add_task(\n convert_to_xdmf,\n name=\"convert_to_xdmf\",\n gmsh_output_file=gmsh_output_file.outputs.result,\n)", - "metadata": { - "tags": [], - "trusted": true - }, - "outputs": [], - "execution_count": 7 - }, - { - "id": "7b69bcff-e2b1-4d4a-b62c-6a1c86eeb590", - "cell_type": "code", - "source": "poisson_dict = wg.add_task(\n poisson,\n name=\"poisson\",\n meshio_output_xdmf=meshio_output_dict.outputs.xdmf_file, \n meshio_output_h5=meshio_output_dict.outputs.h5_file,\n)", - "metadata": { - "tags": [], - "trusted": true - }, - "outputs": [], - "execution_count": 8 - }, - { - "id": "3c4a29b0-eb1e-490a-8be0-e03cfff15e0a", - "cell_type": "code", - "source": "pvbatch_output_file = wg.add_task(\n plot_over_line,\n name=\"plot_over_line\",\n poisson_output_pvd_file=poisson_dict.outputs.pvd_file, \n poisson_output_vtu_file=poisson_dict.outputs.vtu_file,\n)", - "metadata": { - "tags": [], - "trusted": true - }, - "outputs": [], - "execution_count": 9 - }, - { - "id": "a0a4c233-322d-4723-9627-62ca2487bfa9", - "cell_type": "code", - "source": "macros_tex_file = wg.add_task(\n substitute_macros,\n name=\"substitute_macros\",\n pvbatch_output_file=pvbatch_output_file.outputs.result, \n ndofs=poisson_dict.outputs.numdofs, \n domain_size=domain_size,\n)", - "metadata": { - "tags": [], - "trusted": true - }, - "outputs": [], - "execution_count": 10 - }, - { - "id": "c281408f-e63d-4380-a7e6-c595d49fbb8f", - "cell_type": "code", - "source": "paper_output = wg.add_task(\n compile_paper,\n name=\"compile_paper\",\n macros_tex=macros_tex_file.outputs.result, \n plot_file=pvbatch_output_file.outputs.result,\n)", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 11 - }, - { - "id": "a384d70a-8ef5-4fdd-880c-56ac7eaf87b9", - "cell_type": "code", - "source": "wg", - "metadata": { - "trusted": true - }, - "outputs": [ - { - "execution_count": 12, - "output_type": "execute_result", - "data": { - "text/plain": "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'wg-nfdi…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 1, - "model_id": "cc82d573b0404a4697e86fea0f52b39d" - } - }, - "metadata": {} - } - ], - "execution_count": 12 - }, - { - "id": "fb23ad9c-76fd-4c0b-b546-e305d6c49796", - "cell_type": "code", - "source": "workflow_json_filename = \"aiida_nfdi.json\"", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 13 - }, - { - "id": "4139547a-9717-4708-b1a5-8202a0382d77", - "cell_type": "code", - "source": "write_workflow_json(wg=wg, file_name=workflow_json_filename)", - "metadata": { - "trusted": true - }, - "outputs": [ - { - "execution_count": 14, - "output_type": "execute_result", - "data": { - "text/plain": "{'nodes': [{'id': 0, 'function': 'nfdi_ing_workflow.generate_mesh'},\n {'id': 1, 'function': 'nfdi_ing_workflow.convert_to_xdmf'},\n {'id': 2, 'function': 'nfdi_ing_workflow.poisson'},\n {'id': 3, 'function': 'nfdi_ing_workflow.plot_over_line'},\n {'id': 4, 'function': 'nfdi_ing_workflow.substitute_macros'},\n {'id': 5, 'function': 'nfdi_ing_workflow.compile_paper'},\n {'id': 6, 'value': 2.0}],\n 'edges': [{'target': 1,\n 'targetPort': 'gmsh_output_file',\n 'source': 0,\n 'sourcePort': None},\n {'target': 2,\n 'targetPort': 'meshio_output_xdmf',\n 'source': 1,\n 'sourcePort': 'xdmf_file'},\n {'target': 2,\n 'targetPort': 'meshio_output_h5',\n 'source': 1,\n 'sourcePort': 'h5_file'},\n {'target': 3,\n 'targetPort': 'poisson_output_pvd_file',\n 'source': 2,\n 'sourcePort': 'pvd_file'},\n {'target': 3,\n 'targetPort': 'poisson_output_vtu_file',\n 'source': 2,\n 'sourcePort': 'vtu_file'},\n {'target': 4,\n 'targetPort': 'pvbatch_output_file',\n 'source': 3,\n 'sourcePort': None},\n {'target': 4, 'targetPort': 'ndofs', 'source': 2, 'sourcePort': 'numdofs'},\n {'target': 5, 'targetPort': 'macros_tex', 'source': 4, 'sourcePort': None},\n {'target': 5, 'targetPort': 'plot_file', 'source': 3, 'sourcePort': None},\n {'target': 0, 'targetPort': 'domain_size', 'source': 6, 'sourcePort': None},\n {'target': 4, 'targetPort': 'domain_size', 'source': 6, 'sourcePort': None}]}" - }, - "metadata": {} - } - ], - "execution_count": 14 - }, - { - "id": "490df6a3-e402-4620-acf2-dbcfa0c5d537", - "cell_type": "code", - "source": "!cat {workflow_json_filename}", - "metadata": { - "trusted": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": "{\n \"nodes\": [\n {\n \"id\": 0,\n \"function\": \"nfdi_ing_workflow.generate_mesh\"\n },\n {\n \"id\": 1,\n \"function\": \"nfdi_ing_workflow.convert_to_xdmf\"\n },\n {\n \"id\": 2,\n \"function\": \"nfdi_ing_workflow.poisson\"\n },\n {\n \"id\": 3,\n \"function\": \"nfdi_ing_workflow.plot_over_line\"\n },\n {\n \"id\": 4,\n \"function\": \"nfdi_ing_workflow.substitute_macros\"\n },\n {\n \"id\": 5,\n \"function\": \"nfdi_ing_workflow.compile_paper\"\n },\n {\n \"id\": 6,\n \"value\": 2.0\n }\n ],\n \"edges\": [\n {\n \"target\": 1,\n \"targetPort\": \"gmsh_output_file\",\n \"source\": 0,\n \"sourcePort\": null\n },\n {\n \"target\": 2,\n \"targetPort\": \"meshio_output_xdmf\",\n \"source\": 1,\n \"sourcePort\": \"xdmf_file\"\n },\n {\n \"target\": 2,\n \"targetPort\": \"meshio_output_h5\",\n \"source\": 1,\n \"sourcePort\": \"h5_file\"\n },\n {\n \"target\": 3,\n \"targetPort\": \"poisson_output_pvd_file\",\n \"source\": 2,\n \"sourcePort\": \"pvd_file\"\n },\n {\n \"target\": 3,\n \"targetPort\": \"poisson_output_vtu_file\",\n \"source\": 2,\n \"sourcePort\": \"vtu_file\"\n },\n {\n \"target\": 4,\n \"targetPort\": \"pvbatch_output_file\",\n \"source\": 3,\n \"sourcePort\": null\n },\n {\n \"target\": 4,\n \"targetPort\": \"ndofs\",\n \"source\": 2,\n \"sourcePort\": \"numdofs\"\n },\n {\n \"target\": 5,\n \"targetPort\": \"macros_tex\",\n \"source\": 4,\n \"sourcePort\": null\n },\n {\n \"target\": 5,\n \"targetPort\": \"plot_file\",\n \"source\": 3,\n \"sourcePort\": null\n },\n {\n \"target\": 0,\n \"targetPort\": \"domain_size\",\n \"source\": 6,\n \"sourcePort\": null\n },\n {\n \"target\": 4,\n \"targetPort\": \"domain_size\",\n \"source\": 6,\n \"sourcePort\": null\n }\n ]\n}" - } - ], - "execution_count": 15 - }, - { - "id": "11a829e2-face-469f-b343-2c95763b1f13", - "cell_type": "markdown", - "source": "## Load Workflow with jobflow", - "metadata": {} - }, - { - "id": "4f3acabe-55df-479a-af4d-a23a80c4660d", - "cell_type": "code", - "source": "from python_workflow_definition.jobflow import load_workflow_json", - "metadata": { - "trusted": true - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": "/srv/conda/envs/notebook/lib/python3.12/site-packages/paramiko/pkey.py:82: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.\n \"cipher\": algorithms.TripleDES,\n/srv/conda/envs/notebook/lib/python3.12/site-packages/paramiko/transport.py:253: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.\n \"class\": algorithms.TripleDES,\n" - } - ], - "execution_count": 16 - }, - { - "id": "b6ba9444-a2c8-451b-b74c-19b0f69ba369", - "cell_type": "code", - "source": "from jobflow.managers.local import run_locally", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 17 - }, - { - "id": "c3528d55-6bf7-47ed-a110-65c47446ba92", - "cell_type": "code", - "source": "flow = load_workflow_json(file_name=workflow_json_filename)", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 18 - }, - { - "id": "5ef48778-4209-425f-8c6b-85a4cd2f92ec", - "cell_type": "code", - "source": "result = run_locally(flow)\nresult", - "metadata": { - "trusted": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": "2025-04-23 09:29:09,718 INFO Started executing jobs locally\n2025-04-23 09:29:10,027 INFO Starting job - generate_mesh (db4e4162-f31c-4da8-b474-aff5f748b02a)\n2025-04-23 09:29:11,997 INFO Finished job - generate_mesh (db4e4162-f31c-4da8-b474-aff5f748b02a)\n2025-04-23 09:29:11,998 INFO Starting job - convert_to_xdmf (25f3510a-42fc-4895-bb0c-1ea58a357c1d)\n2025-04-23 09:29:13,640 INFO Finished job - convert_to_xdmf (25f3510a-42fc-4895-bb0c-1ea58a357c1d)\n2025-04-23 09:29:13,642 INFO Starting job - poisson (03732863-096b-4c7f-b9fe-62edb0fd5d91)\n2025-04-23 09:29:23,400 INFO Finished job - poisson (03732863-096b-4c7f-b9fe-62edb0fd5d91)\n2025-04-23 09:29:23,401 INFO Starting job - plot_over_line (d326049f-820a-4b9c-8645-70a4d5a8b581)\n2025-04-23 09:29:25,817 INFO Finished job - plot_over_line (d326049f-820a-4b9c-8645-70a4d5a8b581)\n2025-04-23 09:29:25,818 INFO Starting job - substitute_macros (ce1245a5-8a5d-4428-9e90-437f8dff22e2)\n2025-04-23 09:29:26,635 INFO Finished job - substitute_macros (ce1245a5-8a5d-4428-9e90-437f8dff22e2)\n2025-04-23 09:29:26,636 INFO Starting job - compile_paper (5b619ad3-49d6-4e76-ad3f-0ac31e7d63cb)\n2025-04-23 09:30:40,178 INFO Finished job - compile_paper (5b619ad3-49d6-4e76-ad3f-0ac31e7d63cb)\n2025-04-23 09:30:40,179 INFO Finished executing jobs locally\n" - }, - { - "execution_count": 19, - "output_type": "execute_result", - "data": { - "text/plain": "{'db4e4162-f31c-4da8-b474-aff5f748b02a': {1: Response(output='/home/jovyan/preprocessing/square.msh', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))},\n '25f3510a-42fc-4895-bb0c-1ea58a357c1d': {1: Response(output={'xdmf_file': '/home/jovyan/preprocessing/square.xdmf', 'h5_file': '/home/jovyan/preprocessing/square.h5'}, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))},\n '03732863-096b-4c7f-b9fe-62edb0fd5d91': {1: Response(output={'numdofs': 357, 'pvd_file': '/home/jovyan/processing/poisson.pvd', 'vtu_file': '/home/jovyan/processing/poisson000000.vtu'}, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))},\n 'd326049f-820a-4b9c-8645-70a4d5a8b581': {1: Response(output='/home/jovyan/postprocessing/plotoverline.csv', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))},\n 'ce1245a5-8a5d-4428-9e90-437f8dff22e2': {1: Response(output='/home/jovyan/postprocessing/macros.tex', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))},\n '5b619ad3-49d6-4e76-ad3f-0ac31e7d63cb': {1: Response(output='/home/jovyan/postprocessing/paper.pdf', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))}}" - }, - "metadata": {} - } - ], - "execution_count": 19 - }, - { - "id": "397b16a2-e1ec-4eec-8562-1c84f585c347", - "cell_type": "markdown", - "source": "## Load Workflow with pyiron_base", - "metadata": {} - }, - { - "id": "be4d5d93-e9f6-4072-a6be-0ee5dc93590f", - "cell_type": "code", - "source": "from python_workflow_definition.pyiron_base import load_workflow_json", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 20 - }, - { - "id": "4452a648-d4c3-4f5f-8678-ffb54bef17dc", - "cell_type": "code", - "source": "delayed_object_lst = load_workflow_json(file_name=workflow_json_filename)\ndelayed_object_lst[-1].draw()", - "metadata": { - "trusted": true - }, - "outputs": [ - { - "output_type": "display_data", - "data": { - "text/plain": "", - "image/svg+xml": "\n\n\n\n\ncreate_function_job_69b38eef29d5c9aba4c6de512da1bb24\n\ncreate_function_job=<pyiron_base.project.delayed.DelayedObject object at 0x7470370855e0>\n\n\n\nmacros_tex_c5f640fc7b11414962941f82a40a8b04\n\nmacros_tex=<pyiron_base.project.delayed.DelayedObject object at 0x747042cb6ed0>\n\n\n\nmacros_tex_c5f640fc7b11414962941f82a40a8b04->create_function_job_69b38eef29d5c9aba4c6de512da1bb24\n\n\n\n\n\npvbatch_output_file_5f8f87a5c4f1bd1a4b6cca85a1fc2b78\n\npvbatch_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x747041dd8c20>\n\n\n\npvbatch_output_file_5f8f87a5c4f1bd1a4b6cca85a1fc2b78->macros_tex_c5f640fc7b11414962941f82a40a8b04\n\n\n\n\n\npoisson_output_pvd_file_08c5d21e2c998fd513709b7a059c6649\n\npoisson_output_pvd_file=<pyiron_base.project.delayed.DelayedObject object at 0x74704c596180>\n\n\n\npoisson_output_pvd_file_08c5d21e2c998fd513709b7a059c6649->pvbatch_output_file_5f8f87a5c4f1bd1a4b6cca85a1fc2b78\n\n\n\n\n\nplot_file_5f8f87a5c4f1bd1a4b6cca85a1fc2b78\n\nplot_file=<pyiron_base.project.delayed.DelayedObject object at 0x747041dd8c20>\n\n\n\npoisson_output_pvd_file_08c5d21e2c998fd513709b7a059c6649->plot_file_5f8f87a5c4f1bd1a4b6cca85a1fc2b78\n\n\n\n\n\nplot_file_5f8f87a5c4f1bd1a4b6cca85a1fc2b78->create_function_job_69b38eef29d5c9aba4c6de512da1bb24\n\n\n\n\n\nmeshio_output_xdmf_fc75e768124c1b73ca0efc70a5765dea\n\nmeshio_output_xdmf=<pyiron_base.project.delayed.DelayedObject object at 0x7470340b41d0>\n\n\n\nmeshio_output_xdmf_fc75e768124c1b73ca0efc70a5765dea->poisson_output_pvd_file_08c5d21e2c998fd513709b7a059c6649\n\n\n\n\n\npoisson_output_vtu_file_62144723b416cb6b52989d18b3dec55b\n\npoisson_output_vtu_file=<pyiron_base.project.delayed.DelayedObject object at 0x74704c5960c0>\n\n\n\nmeshio_output_xdmf_fc75e768124c1b73ca0efc70a5765dea->poisson_output_vtu_file_62144723b416cb6b52989d18b3dec55b\n\n\n\n\n\nndofs_c3811e53ce75b5460d97029d314439b5\n\nndofs=<pyiron_base.project.delayed.DelayedObject object at 0x747041dd9310>\n\n\n\nmeshio_output_xdmf_fc75e768124c1b73ca0efc70a5765dea->ndofs_c3811e53ce75b5460d97029d314439b5\n\n\n\n\n\npoisson_output_vtu_file_62144723b416cb6b52989d18b3dec55b->pvbatch_output_file_5f8f87a5c4f1bd1a4b6cca85a1fc2b78\n\n\n\n\n\npoisson_output_vtu_file_62144723b416cb6b52989d18b3dec55b->plot_file_5f8f87a5c4f1bd1a4b6cca85a1fc2b78\n\n\n\n\n\nndofs_c3811e53ce75b5460d97029d314439b5->macros_tex_c5f640fc7b11414962941f82a40a8b04\n\n\n\n\n\ngmsh_output_file_950b49ac6562a70cf11f14756f9831ea\n\ngmsh_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x746ea8314fb0>\n\n\n\ngmsh_output_file_950b49ac6562a70cf11f14756f9831ea->meshio_output_xdmf_fc75e768124c1b73ca0efc70a5765dea\n\n\n\n\n\nmeshio_output_h5_efe999f964b5fb7603bd642abcd8905d\n\nmeshio_output_h5=<pyiron_base.project.delayed.DelayedObject object at 0x746ea6f35d30>\n\n\n\ngmsh_output_file_950b49ac6562a70cf11f14756f9831ea->meshio_output_h5_efe999f964b5fb7603bd642abcd8905d\n\n\n\n\n\nmeshio_output_h5_efe999f964b5fb7603bd642abcd8905d->poisson_output_pvd_file_08c5d21e2c998fd513709b7a059c6649\n\n\n\n\n\nmeshio_output_h5_efe999f964b5fb7603bd642abcd8905d->poisson_output_vtu_file_62144723b416cb6b52989d18b3dec55b\n\n\n\n\n\nmeshio_output_h5_efe999f964b5fb7603bd642abcd8905d->ndofs_c3811e53ce75b5460d97029d314439b5\n\n\n\n\n\ndomain_size_f12a7f1986b9dd058dfc666dbe230b20\n\ndomain_size=2.0\n\n\n\ndomain_size_f12a7f1986b9dd058dfc666dbe230b20->macros_tex_c5f640fc7b11414962941f82a40a8b04\n\n\n\n\n\ndomain_size_f12a7f1986b9dd058dfc666dbe230b20->gmsh_output_file_950b49ac6562a70cf11f14756f9831ea\n\n\n\n\n" - }, - "metadata": {} - } - ], - "execution_count": 21 - }, - { - "id": "1c2760b6-96b4-4f44-ac49-a229d4a0cf67", - "cell_type": "code", - "source": "delayed_object_lst[-1].pull()", - "metadata": { - "trusted": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": "The job generate_mesh_0b48cf5155cd6802c17d20bb58104132 was saved and received the ID: 1\nThe job convert_to_xdmf_29ad6ec6927268429dc9aef8166fde43 was saved and received the ID: 2\nThe job poisson_a0224b23ceb2119d105a5d98ef37f93e was saved and received the ID: 3\nThe job plot_over_line_82b37a42e0747f11d9a7f6318f63ac6b was saved and received the ID: 4\nThe job substitute_macros_874fc185ecec04b4cb9537c58b7efb7b was saved and received the ID: 5\nThe job compile_paper_3cee534ffe692833d37faf1fd2170cb6 was saved and received the ID: 6\n" - }, - { - "execution_count": 22, - "output_type": "execute_result", - "data": { - "text/plain": "'/home/jovyan/postprocessing/paper.pdf'" - }, - "metadata": {} - } - ], - "execution_count": 22 - } - ] -} +{"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.12.8","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":5,"nbformat":4,"cells":[{"id":"106ded66-d202-46ac-82b0-2755ca309bdd","cell_type":"markdown","source":"# Aiida\n\nhttps://github.com/BAMresearch/NFDI4IngScientificWorkflowRequirements","metadata":{}},{"id":"11e09b78-cb72-465f-9c8b-5b77f0aa729c","cell_type":"markdown","source":"## Define workflow with aiida","metadata":{}},{"id":"17173d54-dc76-4052-ab39-d44771ac903d","cell_type":"code","source":"import os","metadata":{"trusted":true},"outputs":[],"execution_count":1},{"id":"89c02460-b543-442c-a27e-f1757dc2262e","cell_type":"code","source":"from python_workflow_definition.aiida import write_workflow_json\n\nfrom aiida_workgraph import WorkGraph, task\nfrom aiida import orm, load_profile\nload_profile()","metadata":{"trusted":true},"outputs":[{"execution_count":2,"output_type":"execute_result","data":{"text/plain":"Profile"},"metadata":{}}],"execution_count":2},{"id":"6dac225a1ce86b25","cell_type":"code","source":"from workflow import (\n generate_mesh,\n convert_to_xdmf as _convert_to_xdmf,\n poisson as _poisson,\n plot_over_line,\n substitute_macros,\n compile_paper,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":3},{"id":"c47205d289499756","cell_type":"code","source":"convert_to_xdmf = task(outputs=[\"xdmf_file\", \"h5_file\"])(_convert_to_xdmf)\npoisson = task(outputs=[\"numdofs\", \"pvd_file\", \"vtu_file\"])(_poisson)","metadata":{"trusted":true},"outputs":[],"execution_count":4},{"id":"37c9d988-1755-446c-9f7b-c32f99e280d4","cell_type":"code","source":"source_directory = orm.Str(os.path.abspath(os.path.join(os.curdir, \"source\")))","metadata":{"trusted":true},"outputs":[],"execution_count":5},{"id":"8d911f98-3b80-457f-a0f4-3cb37ebf1691","cell_type":"code","source":"domain_size = orm.Float(2.0)","metadata":{"trusted":true},"outputs":[],"execution_count":6},{"id":"1e7e14ba-c4a7-485f-9bd8-44625830cca0","cell_type":"code","source":"wg = WorkGraph(\"wg-nfdi\")","metadata":{"trusted":true},"outputs":[],"execution_count":7},{"id":"71d411b6-cbec-489e-99e3-ba71680bcb5b","cell_type":"code","source":"gmsh_output_file = wg.add_task(\n generate_mesh,\n name=\"generate_mesh\",\n domain_size=domain_size,\n source_directory=source_directory,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":8},{"id":"1d0d9804-f250-48b3-a5d0-a546d520f79b","cell_type":"code","source":"meshio_output_dict = wg.add_task(\n convert_to_xdmf,\n name=\"convert_to_xdmf\",\n gmsh_output_file=gmsh_output_file.outputs.result,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":9},{"id":"7b69bcff-e2b1-4d4a-b62c-6a1c86eeb590","cell_type":"code","source":"poisson_dict = wg.add_task(\n poisson,\n name=\"poisson\",\n meshio_output_xdmf=meshio_output_dict.outputs.xdmf_file, \n meshio_output_h5=meshio_output_dict.outputs.h5_file,\n source_directory=source_directory,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":10},{"id":"3c4a29b0-eb1e-490a-8be0-e03cfff15e0a","cell_type":"code","source":"pvbatch_output_file = wg.add_task(\n plot_over_line,\n name=\"plot_over_line\",\n poisson_output_pvd_file=poisson_dict.outputs.pvd_file, \n poisson_output_vtu_file=poisson_dict.outputs.vtu_file,\n source_directory=source_directory,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":11},{"id":"a0a4c233-322d-4723-9627-62ca2487bfa9","cell_type":"code","source":"macros_tex_file = wg.add_task(\n substitute_macros,\n name=\"substitute_macros\",\n pvbatch_output_file=pvbatch_output_file.outputs.result, \n ndofs=poisson_dict.outputs.numdofs, \n domain_size=domain_size,\n source_directory=source_directory,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":12},{"id":"c281408f-e63d-4380-a7e6-c595d49fbb8f","cell_type":"code","source":"paper_output = wg.add_task(\n compile_paper,\n name=\"compile_paper\",\n macros_tex=macros_tex_file.outputs.result, \n plot_file=pvbatch_output_file.outputs.result,\n source_directory=source_directory,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":13},{"id":"a384d70a-8ef5-4fdd-880c-56ac7eaf87b9","cell_type":"code","source":"wg","metadata":{"trusted":true},"outputs":[{"execution_count":14,"output_type":"execute_result","data":{"text/plain":"NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'wg-nfdi…","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":1,"model_id":"146d8dc7dfb641ca8d2e9d74c21dd397"}},"metadata":{}}],"execution_count":14},{"id":"fb23ad9c-76fd-4c0b-b546-e305d6c49796","cell_type":"code","source":"workflow_json_filename = \"aiida_nfdi.json\"","metadata":{"trusted":true},"outputs":[],"execution_count":15},{"id":"4139547a-9717-4708-b1a5-8202a0382d77","cell_type":"code","source":"write_workflow_json(wg=wg, file_name=workflow_json_filename)","metadata":{"trusted":true},"outputs":[],"execution_count":16},{"id":"490df6a3-e402-4620-acf2-dbcfa0c5d537","cell_type":"code","source":"!cat {workflow_json_filename}","metadata":{"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"{\n \"nodes\": [\n {\n \"id\": 0,\n \"type\": \"function\",\n \"value\": \"workflow.generate_mesh\"\n },\n {\n \"id\": 1,\n \"type\": \"function\",\n \"value\": \"workflow.convert_to_xdmf\"\n },\n {\n \"id\": 2,\n \"type\": \"function\",\n \"value\": \"workflow.poisson\"\n },\n {\n \"id\": 3,\n \"type\": \"function\",\n \"value\": \"workflow.plot_over_line\"\n },\n {\n \"id\": 4,\n \"type\": \"function\",\n \"value\": \"workflow.substitute_macros\"\n },\n {\n \"id\": 5,\n \"type\": \"function\",\n \"value\": \"workflow.compile_paper\"\n },\n {\n \"id\": 6,\n \"type\": \"input\",\n \"name\": \"domain_size\",\n \"value\": 2.0\n },\n {\n \"id\": 7,\n \"type\": \"input\",\n \"name\": \"source_directory\",\n \"value\": \"/home/jovyan/example_workflows/nfdi/source\"\n },\n {\n \"id\": 8,\n \"type\": \"output\",\n \"name\": \"result\"\n }\n ],\n \"edges\": [\n {\n \"target\": 1,\n \"targetPort\": \"gmsh_output_file\",\n \"source\": 0,\n \"sourcePort\": null\n },\n {\n \"target\": 2,\n \"targetPort\": \"meshio_output_xdmf\",\n \"source\": 1,\n \"sourcePort\": \"xdmf_file\"\n },\n {\n \"target\": 2,\n \"targetPort\": \"meshio_output_h5\",\n \"source\": 1,\n \"sourcePort\": \"h5_file\"\n },\n {\n \"target\": 3,\n \"targetPort\": \"poisson_output_pvd_file\",\n \"source\": 2,\n \"sourcePort\": \"pvd_file\"\n },\n {\n \"target\": 3,\n \"targetPort\": \"poisson_output_vtu_file\",\n \"source\": 2,\n \"sourcePort\": \"vtu_file\"\n },\n {\n \"target\": 4,\n \"targetPort\": \"pvbatch_output_file\",\n \"source\": 3,\n \"sourcePort\": null\n },\n {\n \"target\": 4,\n \"targetPort\": \"ndofs\",\n \"source\": 2,\n \"sourcePort\": \"numdofs\"\n },\n {\n \"target\": 5,\n \"targetPort\": \"macros_tex\",\n \"source\": 4,\n \"sourcePort\": null\n },\n {\n \"target\": 5,\n \"targetPort\": \"plot_file\",\n \"source\": 3,\n \"sourcePort\": null\n },\n {\n \"target\": 0,\n \"targetPort\": \"domain_size\",\n \"source\": 6,\n \"sourcePort\": null\n },\n {\n \"target\": 0,\n \"targetPort\": \"source_directory\",\n \"source\": 7,\n \"sourcePort\": null\n },\n {\n \"target\": 2,\n \"targetPort\": \"source_directory\",\n \"source\": 7,\n \"sourcePort\": null\n },\n {\n \"target\": 3,\n \"targetPort\": \"source_directory\",\n \"source\": 7,\n \"sourcePort\": null\n },\n {\n \"target\": 4,\n \"targetPort\": \"domain_size\",\n \"source\": 6,\n \"sourcePort\": null\n },\n {\n \"target\": 4,\n \"targetPort\": \"source_directory\",\n \"source\": 7,\n \"sourcePort\": null\n },\n {\n \"target\": 5,\n \"targetPort\": \"source_directory\",\n \"source\": 7,\n \"sourcePort\": null\n },\n {\n \"target\": 8,\n \"targetPort\": null,\n \"source\": 5,\n \"sourcePort\": null\n }\n ]\n}"}],"execution_count":17},{"id":"11a829e2-face-469f-b343-2c95763b1f13","cell_type":"markdown","source":"## Load Workflow with jobflow","metadata":{}},{"id":"4f3acabe-55df-479a-af4d-a23a80c4660d","cell_type":"code","source":"from python_workflow_definition.jobflow import load_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":18},{"id":"b6ba9444-a2c8-451b-b74c-19b0f69ba369","cell_type":"code","source":"from jobflow.managers.local import run_locally","metadata":{"trusted":true},"outputs":[],"execution_count":19},{"id":"c3528d55-6bf7-47ed-a110-65c47446ba92","cell_type":"code","source":"flow = load_workflow_json(file_name=workflow_json_filename)","metadata":{"trusted":true},"outputs":[],"execution_count":20},{"id":"5ef48778-4209-425f-8c6b-85a4cd2f92ec","cell_type":"code","source":"result = run_locally(flow)\nresult","metadata":{"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"2025-05-14 08:19:05,840 INFO Started executing jobs locally\n2025-05-14 08:19:06,092 INFO Starting job - generate_mesh (2b5d3769-0843-43a0-b074-2b307413b932)\n2025-05-14 08:19:07,248 INFO Finished job - generate_mesh (2b5d3769-0843-43a0-b074-2b307413b932)\n2025-05-14 08:19:07,249 INFO Starting job - convert_to_xdmf (60d93a50-60c8-4ebc-9822-fae5e9f6bf4b)\n2025-05-14 08:19:08,519 INFO Finished job - convert_to_xdmf (60d93a50-60c8-4ebc-9822-fae5e9f6bf4b)\n2025-05-14 08:19:08,521 INFO Starting job - poisson (06a30fcc-b3e5-4223-aa6e-1090166cd9c7)\n2025-05-14 08:19:11,239 INFO Finished job - poisson (06a30fcc-b3e5-4223-aa6e-1090166cd9c7)\n2025-05-14 08:19:11,240 INFO Starting job - plot_over_line (f899080b-495a-401e-a71c-3abba9e81a5b)\n2025-05-14 08:19:12,690 INFO Finished job - plot_over_line (f899080b-495a-401e-a71c-3abba9e81a5b)\n2025-05-14 08:19:12,691 INFO Starting job - substitute_macros (b1612cb4-0027-4140-95c2-8cb7581109ca)\n2025-05-14 08:19:13,570 INFO Finished job - substitute_macros (b1612cb4-0027-4140-95c2-8cb7581109ca)\n2025-05-14 08:19:13,571 INFO Starting job - compile_paper (c5e6caaa-9766-4079-a235-a774a6d5c7fa)\n2025-05-14 08:19:15,636 INFO Finished job - compile_paper (c5e6caaa-9766-4079-a235-a774a6d5c7fa)\n2025-05-14 08:19:15,637 INFO Finished executing jobs locally\n"},{"execution_count":21,"output_type":"execute_result","data":{"text/plain":"{'2b5d3769-0843-43a0-b074-2b307413b932': {1: Response(output='/home/jovyan/example_workflows/nfdi/preprocessing/square.msh', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan/example_workflows/nfdi'))},\n '60d93a50-60c8-4ebc-9822-fae5e9f6bf4b': {1: Response(output={'xdmf_file': '/home/jovyan/example_workflows/nfdi/preprocessing/square.xdmf', 'h5_file': '/home/jovyan/example_workflows/nfdi/preprocessing/square.h5'}, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan/example_workflows/nfdi'))},\n '06a30fcc-b3e5-4223-aa6e-1090166cd9c7': {1: Response(output={'numdofs': 357, 'pvd_file': '/home/jovyan/example_workflows/nfdi/processing/poisson.pvd', 'vtu_file': '/home/jovyan/example_workflows/nfdi/processing/poisson000000.vtu'}, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan/example_workflows/nfdi'))},\n 'f899080b-495a-401e-a71c-3abba9e81a5b': {1: Response(output='/home/jovyan/example_workflows/nfdi/postprocessing/plotoverline.csv', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan/example_workflows/nfdi'))},\n 'b1612cb4-0027-4140-95c2-8cb7581109ca': {1: Response(output='/home/jovyan/example_workflows/nfdi/postprocessing/macros.tex', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan/example_workflows/nfdi'))},\n 'c5e6caaa-9766-4079-a235-a774a6d5c7fa': {1: Response(output='/home/jovyan/example_workflows/nfdi/postprocessing/paper.pdf', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan/example_workflows/nfdi'))}}"},"metadata":{}}],"execution_count":21},{"id":"397b16a2-e1ec-4eec-8562-1c84f585c347","cell_type":"markdown","source":"## Load Workflow with pyiron_base","metadata":{}},{"id":"be4d5d93-e9f6-4072-a6be-0ee5dc93590f","cell_type":"code","source":"from python_workflow_definition.pyiron_base import load_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":22},{"id":"4452a648-d4c3-4f5f-8678-ffb54bef17dc","cell_type":"code","source":"delayed_object_lst = load_workflow_json(file_name=workflow_json_filename)\ndelayed_object_lst[-1].draw()","metadata":{"trusted":true},"outputs":[{"output_type":"display_data","data":{"text/plain":"","image/svg+xml":"\n\n\n\n\ncreate_function_job_9564f1c400f389023de93231c8a62a65\n\ncreate_function_job=<pyiron_base.project.delayed.DelayedObject object at 0x7e2106518c20>\n\n\n\nmacros_tex_4fdd7c93c52394e1a5aed103adf6dba4\n\nmacros_tex=<pyiron_base.project.delayed.DelayedObject object at 0x7e21065189b0>\n\n\n\nmacros_tex_4fdd7c93c52394e1a5aed103adf6dba4->create_function_job_9564f1c400f389023de93231c8a62a65\n\n\n\n\n\npvbatch_output_file_e4a68dc408161a17988f364b0337f341\n\npvbatch_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x7e2106518680>\n\n\n\npvbatch_output_file_e4a68dc408161a17988f364b0337f341->macros_tex_4fdd7c93c52394e1a5aed103adf6dba4\n\n\n\n\n\npoisson_output_pvd_file_7da70c04cc70bbdbd26f7da8deeaca29\n\npoisson_output_pvd_file=<pyiron_base.project.delayed.DelayedObject object at 0x7e21065183e0>\n\n\n\npoisson_output_pvd_file_7da70c04cc70bbdbd26f7da8deeaca29->pvbatch_output_file_e4a68dc408161a17988f364b0337f341\n\n\n\n\n\nplot_file_e4a68dc408161a17988f364b0337f341\n\nplot_file=<pyiron_base.project.delayed.DelayedObject object at 0x7e2106518680>\n\n\n\npoisson_output_pvd_file_7da70c04cc70bbdbd26f7da8deeaca29->plot_file_e4a68dc408161a17988f364b0337f341\n\n\n\n\n\nplot_file_e4a68dc408161a17988f364b0337f341->create_function_job_9564f1c400f389023de93231c8a62a65\n\n\n\n\n\nmeshio_output_xdmf_6ee525037bdcb254ca562ddfe379237e\n\nmeshio_output_xdmf=<pyiron_base.project.delayed.DelayedObject object at 0x7e21064e7d40>\n\n\n\nmeshio_output_xdmf_6ee525037bdcb254ca562ddfe379237e->poisson_output_pvd_file_7da70c04cc70bbdbd26f7da8deeaca29\n\n\n\n\n\npoisson_output_vtu_file_fa01b3a624ada2dba805b7518365a6a4\n\npoisson_output_vtu_file=<pyiron_base.project.delayed.DelayedObject object at 0x7e21065183b0>\n\n\n\nmeshio_output_xdmf_6ee525037bdcb254ca562ddfe379237e->poisson_output_vtu_file_fa01b3a624ada2dba805b7518365a6a4\n\n\n\n\n\nndofs_8b9741bf01bd3f1fc0fe9a772777a903\n\nndofs=<pyiron_base.project.delayed.DelayedObject object at 0x7e2106518710>\n\n\n\nmeshio_output_xdmf_6ee525037bdcb254ca562ddfe379237e->ndofs_8b9741bf01bd3f1fc0fe9a772777a903\n\n\n\n\n\npoisson_output_vtu_file_fa01b3a624ada2dba805b7518365a6a4->pvbatch_output_file_e4a68dc408161a17988f364b0337f341\n\n\n\n\n\npoisson_output_vtu_file_fa01b3a624ada2dba805b7518365a6a4->plot_file_e4a68dc408161a17988f364b0337f341\n\n\n\n\n\nndofs_8b9741bf01bd3f1fc0fe9a772777a903->macros_tex_4fdd7c93c52394e1a5aed103adf6dba4\n\n\n\n\n\ngmsh_output_file_4b409dc4c5063e64794e38b2cd0b37e1\n\ngmsh_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x7e21064e7dd0>\n\n\n\ngmsh_output_file_4b409dc4c5063e64794e38b2cd0b37e1->meshio_output_xdmf_6ee525037bdcb254ca562ddfe379237e\n\n\n\n\n\nmeshio_output_h5_f154dadcde14b5da6730af6d0a4c9df7\n\nmeshio_output_h5=<pyiron_base.project.delayed.DelayedObject object at 0x7e21064e7e90>\n\n\n\ngmsh_output_file_4b409dc4c5063e64794e38b2cd0b37e1->meshio_output_h5_f154dadcde14b5da6730af6d0a4c9df7\n\n\n\n\n\nmeshio_output_h5_f154dadcde14b5da6730af6d0a4c9df7->poisson_output_pvd_file_7da70c04cc70bbdbd26f7da8deeaca29\n\n\n\n\n\nmeshio_output_h5_f154dadcde14b5da6730af6d0a4c9df7->poisson_output_vtu_file_fa01b3a624ada2dba805b7518365a6a4\n\n\n\n\n\nmeshio_output_h5_f154dadcde14b5da6730af6d0a4c9df7->ndofs_8b9741bf01bd3f1fc0fe9a772777a903\n\n\n\n\n\ndomain_size_f12a7f1986b9dd058dfc666dbe230b20\n\ndomain_size=2.0\n\n\n\ndomain_size_f12a7f1986b9dd058dfc666dbe230b20->macros_tex_4fdd7c93c52394e1a5aed103adf6dba4\n\n\n\n\n\ndomain_size_f12a7f1986b9dd058dfc666dbe230b20->gmsh_output_file_4b409dc4c5063e64794e38b2cd0b37e1\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696\n\nsource_directory=/home/jovyan/example_workflows/nfdi/source\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->create_function_job_9564f1c400f389023de93231c8a62a65\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->macros_tex_4fdd7c93c52394e1a5aed103adf6dba4\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->pvbatch_output_file_e4a68dc408161a17988f364b0337f341\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->poisson_output_pvd_file_7da70c04cc70bbdbd26f7da8deeaca29\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->plot_file_e4a68dc408161a17988f364b0337f341\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->poisson_output_vtu_file_fa01b3a624ada2dba805b7518365a6a4\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->ndofs_8b9741bf01bd3f1fc0fe9a772777a903\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->gmsh_output_file_4b409dc4c5063e64794e38b2cd0b37e1\n\n\n\n\n"},"metadata":{}}],"execution_count":23},{"id":"1c2760b6-96b4-4f44-ac49-a229d4a0cf67","cell_type":"code","source":"delayed_object_lst[-1].pull()","metadata":{"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"The job generate_mesh_47725c16637f799ac042e47468005db3 was saved and received the ID: 1\nThe job convert_to_xdmf_d6a46eb9a4ec352aa996e783ec3c785f was saved and received the ID: 2\nThe job poisson_3c147fc86db87cf0c0f94bda333f8cd8 was saved and received the ID: 3\nThe job plot_over_line_ef50933291910dadcc8311924971e127 was saved and received the ID: 4\nThe job substitute_macros_63766eafd6b1980c7832dd8c9a97c96e was saved and received the ID: 5\nThe job compile_paper_128d1d58374953c00e95b8de62cbb10b was saved and received the ID: 6\n"},{"execution_count":24,"output_type":"execute_result","data":{"text/plain":"'/home/jovyan/example_workflows/nfdi/postprocessing/paper.pdf'"},"metadata":{}}],"execution_count":24}]} \ No newline at end of file diff --git a/example_workflows/nfdi/jobflow.ipynb b/example_workflows/nfdi/jobflow.ipynb index 5346083..f5df278 100644 --- a/example_workflows/nfdi/jobflow.ipynb +++ b/example_workflows/nfdi/jobflow.ipynb @@ -1 +1 @@ -{"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.12.8","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":5,"nbformat":4,"cells":[{"id":"048b53d1-db08-44ff-84cc-a4ff50032944","cell_type":"markdown","source":"# jobflow","metadata":{}},{"id":"106ded66-d202-46ac-82b0-2755ca309bdd","cell_type":"markdown","source":"https://github.com/BAMresearch/NFDI4IngScientificWorkflowRequirements","metadata":{}},{"id":"856b2ba2-93d5-4516-93e1-a1eac49c48f2","cell_type":"markdown","source":"## Define workflow with jobflow","metadata":{}},{"id":"89c02460-b543-442c-a27e-f1757dc2262e","cell_type":"code","source":"from jobflow import job, Flow\n\nfrom python_workflow_definition.jobflow import write_workflow_json","metadata":{"trusted":true},"outputs":[{"name":"stderr","output_type":"stream","text":"/srv/conda/envs/notebook/lib/python3.12/site-packages/paramiko/pkey.py:82: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.\n \"cipher\": algorithms.TripleDES,\n/srv/conda/envs/notebook/lib/python3.12/site-packages/paramiko/transport.py:253: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.\n \"class\": algorithms.TripleDES,\n"}],"execution_count":1},{"id":"864f048d78ea3f08","cell_type":"code","source":"from workflow import (\n generate_mesh as _generate_mesh, \n convert_to_xdmf as _convert_to_xdmf,\n poisson as _poisson,\n plot_over_line as _plot_over_line,\n substitute_macros as _substitute_macros,\n compile_paper as _compile_paper,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":2},{"id":"147b81b7b494ceda","cell_type":"code","source":"generate_mesh = job(_generate_mesh)\nconvert_to_xdmf = job(_convert_to_xdmf)\npoisson = job(_poisson)\nplot_over_line = job(_plot_over_line)\nsubstitute_macros = job(_substitute_macros)\ncompile_paper = job(_compile_paper)","metadata":{"trusted":true},"outputs":[],"execution_count":3},{"id":"8d911f98-3b80-457f-a0f4-3cb37ebf1691","cell_type":"code","source":"domain_size = 2.0","metadata":{"trusted":true},"outputs":[],"execution_count":4},{"id":"71d411b6-cbec-489e-99e3-ba71680bcb5b","cell_type":"code","source":"gmsh_output_file = generate_mesh(\n domain_size=domain_size,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":5},{"id":"1d0d9804-f250-48b3-a5d0-a546d520f79b","cell_type":"code","source":"meshio_output_dict = convert_to_xdmf(\n gmsh_output_file=gmsh_output_file.output,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":6},{"id":"7b69bcff-e2b1-4d4a-b62c-6a1c86eeb590","cell_type":"code","source":"poisson_dict = poisson(\n meshio_output_xdmf=meshio_output_dict.output.xdmf_file, \n meshio_output_h5=meshio_output_dict.output.h5_file,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":7},{"id":"3c4a29b0-eb1e-490a-8be0-e03cfff15e0a","cell_type":"code","source":"pvbatch_output_file = plot_over_line(\n poisson_output_pvd_file=poisson_dict.output.pvd_file, \n poisson_output_vtu_file=poisson_dict.output.vtu_file,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":8},{"id":"a0a4c233-322d-4723-9627-62ca2487bfa9","cell_type":"code","source":"macros_tex_file = substitute_macros( \n pvbatch_output_file=pvbatch_output_file.output, \n ndofs=poisson_dict.output.numdofs, \n domain_size=domain_size,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":9},{"id":"c281408f-e63d-4380-a7e6-c595d49fbb8f","cell_type":"code","source":"paper_output = compile_paper(\n macros_tex=macros_tex_file.output, \n plot_file=pvbatch_output_file.output,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":10},{"id":"a384d70a-8ef5-4fdd-880c-56ac7eaf87b9","cell_type":"code","source":"flow = Flow([gmsh_output_file, meshio_output_dict, poisson_dict, pvbatch_output_file, macros_tex_file, paper_output])","metadata":{"trusted":true},"outputs":[],"execution_count":11},{"id":"fb23ad9c-76fd-4c0b-b546-e305d6c49796","cell_type":"code","source":"workflow_json_filename = \"jobflow_nfdi.json\"","metadata":{"trusted":true},"outputs":[],"execution_count":12},{"id":"4139547a-9717-4708-b1a5-8202a0382d77","cell_type":"code","source":"write_workflow_json(flow=flow, file_name=workflow_json_filename)","metadata":{"trusted":true},"outputs":[],"execution_count":13},{"id":"11a829e2-face-469f-b343-2c95763b1f13","cell_type":"markdown","source":"## Load Workflow with aiida","metadata":{}},{"id":"4f3acabe-55df-479a-af4d-a23a80c4660d","cell_type":"code","source":"from aiida import load_profile\n\nload_profile()","metadata":{"trusted":true},"outputs":[{"execution_count":14,"output_type":"execute_result","data":{"text/plain":"Profile"},"metadata":{}}],"execution_count":14},{"id":"b6ba9444-a2c8-451b-b74c-19b0f69ba369","cell_type":"code","source":"from python_workflow_definition.aiida import load_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":15},{"id":"c3528d55-6bf7-47ed-a110-65c47446ba92","cell_type":"code","source":"wg = load_workflow_json(file_name=workflow_json_filename)\nwg","metadata":{"trusted":true},"outputs":[{"execution_count":16,"output_type":"execute_result","data":{"text/plain":"NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'WorkGra…","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":1,"model_id":"2639a5a7e617406f8d238d7022110ad2"}},"metadata":{}}],"execution_count":16},{"id":"5ef48778-4209-425f-8c6b-85a4cd2f92ec","cell_type":"code","source":"wg.run()","metadata":{"trusted":true},"outputs":[{"name":"stderr","output_type":"stream","text":"04/24/2025 02:15:53 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|continue_workgraph]: tasks ready to run: generate_mesh1\n04/24/2025 02:15:55 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|update_task_state]: Task: generate_mesh1, type: PyFunction, finished.\n04/24/2025 02:15:55 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|continue_workgraph]: tasks ready to run: convert_to_xdmf2\n04/24/2025 02:15:57 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|update_task_state]: Task: convert_to_xdmf2, type: PyFunction, finished.\n04/24/2025 02:15:57 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|continue_workgraph]: tasks ready to run: poisson3\n04/24/2025 02:16:06 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|update_task_state]: Task: poisson3, type: PyFunction, finished.\n04/24/2025 02:16:06 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|continue_workgraph]: tasks ready to run: plot_over_line4\n04/24/2025 02:16:09 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|update_task_state]: Task: plot_over_line4, type: PyFunction, finished.\n04/24/2025 02:16:09 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|continue_workgraph]: tasks ready to run: substitute_macros5\n04/24/2025 02:16:10 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|update_task_state]: Task: substitute_macros5, type: PyFunction, finished.\n04/24/2025 02:16:10 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|continue_workgraph]: tasks ready to run: compile_paper6\n04/24/2025 02:17:18 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|update_task_state]: Task: compile_paper6, type: PyFunction, finished.\n04/24/2025 02:17:18 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n04/24/2025 02:17:18 PM <316> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [14|WorkGraphEngine|finalize]: Finalize workgraph.\n"}],"execution_count":17},{"id":"397b16a2-e1ec-4eec-8562-1c84f585c347","cell_type":"markdown","source":"## Load Workflow with pyiron_base","metadata":{}},{"id":"be4d5d93-e9f6-4072-a6be-0ee5dc93590f","cell_type":"code","source":"from python_workflow_definition.pyiron_base import load_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":18},{"id":"4452a648-d4c3-4f5f-8678-ffb54bef17dc","cell_type":"code","source":"delayed_object_lst = load_workflow_json(file_name=workflow_json_filename)\ndelayed_object_lst[-1].draw()","metadata":{"trusted":true},"outputs":[{"output_type":"display_data","data":{"text/plain":"","image/svg+xml":"\n\n\n\n\ncreate_function_job_540f87366e9d2012847fc7cd300d7387\n\ncreate_function_job=<pyiron_base.project.delayed.DelayedObject object at 0x784df5d5fef0>\n\n\n\nmacros_tex_7e50dc06332e1809c8fe30ee1d48fd5a\n\nmacros_tex=<pyiron_base.project.delayed.DelayedObject object at 0x784df5d5fd10>\n\n\n\nmacros_tex_7e50dc06332e1809c8fe30ee1d48fd5a->create_function_job_540f87366e9d2012847fc7cd300d7387\n\n\n\n\n\npvbatch_output_file_10790f77479ebcaaa52a128a418bbaf9\n\npvbatch_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x784df5d5fa70>\n\n\n\npvbatch_output_file_10790f77479ebcaaa52a128a418bbaf9->macros_tex_7e50dc06332e1809c8fe30ee1d48fd5a\n\n\n\n\n\npoisson_output_pvd_file_833dadabb722663d51a4450bb5493e8d\n\npoisson_output_pvd_file=<pyiron_base.project.delayed.DelayedObject object at 0x784df5d5f710>\n\n\n\npoisson_output_pvd_file_833dadabb722663d51a4450bb5493e8d->pvbatch_output_file_10790f77479ebcaaa52a128a418bbaf9\n\n\n\n\n\nplot_file_10790f77479ebcaaa52a128a418bbaf9\n\nplot_file=<pyiron_base.project.delayed.DelayedObject object at 0x784df5d5fa70>\n\n\n\npoisson_output_pvd_file_833dadabb722663d51a4450bb5493e8d->plot_file_10790f77479ebcaaa52a128a418bbaf9\n\n\n\n\n\nplot_file_10790f77479ebcaaa52a128a418bbaf9->create_function_job_540f87366e9d2012847fc7cd300d7387\n\n\n\n\n\nmeshio_output_xdmf_98f79427fb4d7ccf8291df7fc1ac6838\n\nmeshio_output_xdmf=<pyiron_base.project.delayed.DelayedObject object at 0x784df5d5f3b0>\n\n\n\nmeshio_output_xdmf_98f79427fb4d7ccf8291df7fc1ac6838->poisson_output_pvd_file_833dadabb722663d51a4450bb5493e8d\n\n\n\n\n\npoisson_output_vtu_file_a9608d2bb2030c145ddffeb990e126ac\n\npoisson_output_vtu_file=<pyiron_base.project.delayed.DelayedObject object at 0x784df5d5f6e0>\n\n\n\nmeshio_output_xdmf_98f79427fb4d7ccf8291df7fc1ac6838->poisson_output_vtu_file_a9608d2bb2030c145ddffeb990e126ac\n\n\n\n\n\nndofs_87378fae3980624a699f18e869088c97\n\nndofs=<pyiron_base.project.delayed.DelayedObject object at 0x784df5d5fb00>\n\n\n\nmeshio_output_xdmf_98f79427fb4d7ccf8291df7fc1ac6838->ndofs_87378fae3980624a699f18e869088c97\n\n\n\n\n\npoisson_output_vtu_file_a9608d2bb2030c145ddffeb990e126ac->pvbatch_output_file_10790f77479ebcaaa52a128a418bbaf9\n\n\n\n\n\npoisson_output_vtu_file_a9608d2bb2030c145ddffeb990e126ac->plot_file_10790f77479ebcaaa52a128a418bbaf9\n\n\n\n\n\nndofs_87378fae3980624a699f18e869088c97->macros_tex_7e50dc06332e1809c8fe30ee1d48fd5a\n\n\n\n\n\ngmsh_output_file_b3f6074f84f86309b317934247a8ae12\n\ngmsh_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x784df5d5f170>\n\n\n\ngmsh_output_file_b3f6074f84f86309b317934247a8ae12->meshio_output_xdmf_98f79427fb4d7ccf8291df7fc1ac6838\n\n\n\n\n\nmeshio_output_h5_f8b981e1a2ec68db7cdb678f7f634c18\n\nmeshio_output_h5=<pyiron_base.project.delayed.DelayedObject object at 0x784df5d5f380>\n\n\n\ngmsh_output_file_b3f6074f84f86309b317934247a8ae12->meshio_output_h5_f8b981e1a2ec68db7cdb678f7f634c18\n\n\n\n\n\nmeshio_output_h5_f8b981e1a2ec68db7cdb678f7f634c18->poisson_output_pvd_file_833dadabb722663d51a4450bb5493e8d\n\n\n\n\n\nmeshio_output_h5_f8b981e1a2ec68db7cdb678f7f634c18->poisson_output_vtu_file_a9608d2bb2030c145ddffeb990e126ac\n\n\n\n\n\nmeshio_output_h5_f8b981e1a2ec68db7cdb678f7f634c18->ndofs_87378fae3980624a699f18e869088c97\n\n\n\n\n\ndomain_size_f12a7f1986b9dd058dfc666dbe230b20\n\ndomain_size=2.0\n\n\n\ndomain_size_f12a7f1986b9dd058dfc666dbe230b20->macros_tex_7e50dc06332e1809c8fe30ee1d48fd5a\n\n\n\n\n\ndomain_size_f12a7f1986b9dd058dfc666dbe230b20->gmsh_output_file_b3f6074f84f86309b317934247a8ae12\n\n\n\n\n"},"metadata":{}}],"execution_count":19},{"id":"1c2760b6-96b4-4f44-ac49-a229d4a0cf67","cell_type":"code","source":"delayed_object_lst[-1].pull()","metadata":{"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"The job generate_mesh_33d3e231d4f5badd161639211a4df9ff was saved and received the ID: 1\nThe job convert_to_xdmf_d6a46eb9a4ec352aa996e783ec3c785f was saved and received the ID: 2\nThe job poisson_757ce07607bbfc1ac00c0f2ed9fff133 was saved and received the ID: 3\nThe job plot_over_line_78c9de5c91dd3550b1cc113d2523f1e8 was saved and received the ID: 4\nThe job substitute_macros_06cc93df70c8a343d15e56040b1a651d was saved and received the ID: 5\nThe job compile_paper_e8bba68a92b18c0a5be4abe502340394 was saved and received the ID: 6\n"},{"execution_count":20,"output_type":"execute_result","data":{"text/plain":"'/home/jovyan/example_workflows/nfdi/postprocessing/paper.pdf'"},"metadata":{}}],"execution_count":20}]} \ No newline at end of file +{"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.12.8","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":5,"nbformat":4,"cells":[{"id":"048b53d1-db08-44ff-84cc-a4ff50032944","cell_type":"markdown","source":"# jobflow","metadata":{}},{"id":"106ded66-d202-46ac-82b0-2755ca309bdd","cell_type":"markdown","source":"https://github.com/BAMresearch/NFDI4IngScientificWorkflowRequirements","metadata":{}},{"id":"856b2ba2-93d5-4516-93e1-a1eac49c48f2","cell_type":"markdown","source":"## Define workflow with jobflow","metadata":{}},{"id":"43d5c810-a701-4971-8534-56dcbd112716","cell_type":"code","source":"import os","metadata":{"trusted":true},"outputs":[],"execution_count":1},{"id":"89c02460-b543-442c-a27e-f1757dc2262e","cell_type":"code","source":"from jobflow import job, Flow\n\nfrom python_workflow_definition.jobflow import write_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":2},{"id":"864f048d78ea3f08","cell_type":"code","source":"from workflow import (\n generate_mesh as _generate_mesh, \n convert_to_xdmf as _convert_to_xdmf,\n poisson as _poisson,\n plot_over_line as _plot_over_line,\n substitute_macros as _substitute_macros,\n compile_paper as _compile_paper,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":3},{"id":"147b81b7b494ceda","cell_type":"code","source":"generate_mesh = job(_generate_mesh)\nconvert_to_xdmf = job(_convert_to_xdmf)\npoisson = job(_poisson)\nplot_over_line = job(_plot_over_line)\nsubstitute_macros = job(_substitute_macros)\ncompile_paper = job(_compile_paper)","metadata":{"trusted":true},"outputs":[],"execution_count":4},{"id":"981e548b-a3b4-49a3-9653-85e90f05c60e","cell_type":"code","source":"source_directory = os.path.abspath(os.path.join(os.curdir, \"source\"))","metadata":{"trusted":true},"outputs":[],"execution_count":5},{"id":"8d911f98-3b80-457f-a0f4-3cb37ebf1691","cell_type":"code","source":"domain_size = 2.0","metadata":{"trusted":true},"outputs":[],"execution_count":6},{"id":"71d411b6-cbec-489e-99e3-ba71680bcb5b","cell_type":"code","source":"gmsh_output_file = generate_mesh(\n domain_size=domain_size,\n source_directory=source_directory,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":7},{"id":"1d0d9804-f250-48b3-a5d0-a546d520f79b","cell_type":"code","source":"meshio_output_dict = convert_to_xdmf(\n gmsh_output_file=gmsh_output_file.output,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":8},{"id":"7b69bcff-e2b1-4d4a-b62c-6a1c86eeb590","cell_type":"code","source":"poisson_dict = poisson(\n meshio_output_xdmf=meshio_output_dict.output.xdmf_file, \n meshio_output_h5=meshio_output_dict.output.h5_file,\n source_directory=source_directory,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":9},{"id":"3c4a29b0-eb1e-490a-8be0-e03cfff15e0a","cell_type":"code","source":"pvbatch_output_file = plot_over_line(\n poisson_output_pvd_file=poisson_dict.output.pvd_file, \n poisson_output_vtu_file=poisson_dict.output.vtu_file,\n source_directory=source_directory,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":10},{"id":"a0a4c233-322d-4723-9627-62ca2487bfa9","cell_type":"code","source":"macros_tex_file = substitute_macros( \n pvbatch_output_file=pvbatch_output_file.output, \n ndofs=poisson_dict.output.numdofs, \n domain_size=domain_size,\n source_directory=source_directory,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":11},{"id":"c281408f-e63d-4380-a7e6-c595d49fbb8f","cell_type":"code","source":"paper_output = compile_paper(\n macros_tex=macros_tex_file.output, \n plot_file=pvbatch_output_file.output,\n source_directory=source_directory,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":12},{"id":"a384d70a-8ef5-4fdd-880c-56ac7eaf87b9","cell_type":"code","source":"flow = Flow([gmsh_output_file, meshio_output_dict, poisson_dict, pvbatch_output_file, macros_tex_file, paper_output])","metadata":{"trusted":true},"outputs":[],"execution_count":13},{"id":"fb23ad9c-76fd-4c0b-b546-e305d6c49796","cell_type":"code","source":"workflow_json_filename = \"jobflow_nfdi.json\"","metadata":{"trusted":true},"outputs":[],"execution_count":14},{"id":"4139547a-9717-4708-b1a5-8202a0382d77","cell_type":"code","source":"write_workflow_json(flow=flow, file_name=workflow_json_filename)","metadata":{"trusted":true},"outputs":[],"execution_count":15},{"id":"11a829e2-face-469f-b343-2c95763b1f13","cell_type":"markdown","source":"## Load Workflow with aiida","metadata":{}},{"id":"4f3acabe-55df-479a-af4d-a23a80c4660d","cell_type":"code","source":"from aiida import load_profile\n\nload_profile()","metadata":{"trusted":true},"outputs":[{"execution_count":16,"output_type":"execute_result","data":{"text/plain":"Profile"},"metadata":{}}],"execution_count":16},{"id":"b6ba9444-a2c8-451b-b74c-19b0f69ba369","cell_type":"code","source":"from python_workflow_definition.aiida import load_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":17},{"id":"c3528d55-6bf7-47ed-a110-65c47446ba92","cell_type":"code","source":"wg = load_workflow_json(file_name=workflow_json_filename)\nwg","metadata":{"trusted":true},"outputs":[{"execution_count":18,"output_type":"execute_result","data":{"text/plain":"NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'WorkGra…","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":1,"model_id":"fd19d63f68234bebaa4e1db7d6dcfc99"}},"metadata":{}}],"execution_count":18},{"id":"5ef48778-4209-425f-8c6b-85a4cd2f92ec","cell_type":"code","source":"wg.run()","metadata":{"trusted":true},"outputs":[{"name":"stderr","output_type":"stream","text":"05/14/2025 08:21:04 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|continue_workgraph]: tasks ready to run: generate_mesh1\n05/14/2025 08:21:06 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|update_task_state]: Task: generate_mesh1, type: PyFunction, finished.\n05/14/2025 08:21:06 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|continue_workgraph]: tasks ready to run: convert_to_xdmf2\n05/14/2025 08:21:08 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|update_task_state]: Task: convert_to_xdmf2, type: PyFunction, finished.\n05/14/2025 08:21:08 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|continue_workgraph]: tasks ready to run: poisson3\n05/14/2025 08:21:11 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|update_task_state]: Task: poisson3, type: PyFunction, finished.\n05/14/2025 08:21:11 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|continue_workgraph]: tasks ready to run: plot_over_line4\n05/14/2025 08:21:13 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|update_task_state]: Task: plot_over_line4, type: PyFunction, finished.\n05/14/2025 08:21:13 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|continue_workgraph]: tasks ready to run: substitute_macros5\n05/14/2025 08:21:14 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|update_task_state]: Task: substitute_macros5, type: PyFunction, finished.\n05/14/2025 08:21:14 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|continue_workgraph]: tasks ready to run: compile_paper6\n05/14/2025 08:21:17 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|update_task_state]: Task: compile_paper6, type: PyFunction, finished.\n05/14/2025 08:21:17 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n05/14/2025 08:21:17 AM <3280> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [51|WorkGraphEngine|finalize]: Finalize workgraph.\n"}],"execution_count":19},{"id":"397b16a2-e1ec-4eec-8562-1c84f585c347","cell_type":"markdown","source":"## Load Workflow with pyiron_base","metadata":{}},{"id":"be4d5d93-e9f6-4072-a6be-0ee5dc93590f","cell_type":"code","source":"from python_workflow_definition.pyiron_base import load_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":20},{"id":"4452a648-d4c3-4f5f-8678-ffb54bef17dc","cell_type":"code","source":"delayed_object_lst = load_workflow_json(file_name=workflow_json_filename)\ndelayed_object_lst[-1].draw()","metadata":{"trusted":true},"outputs":[{"output_type":"display_data","data":{"text/plain":"","image/svg+xml":"\n\n\n\n\ncreate_function_job_9564f1c400f389023de93231c8a62a65\n\ncreate_function_job=<pyiron_base.project.delayed.DelayedObject object at 0x7efce81a77d0>\n\n\n\nmacros_tex_4fdd7c93c52394e1a5aed103adf6dba4\n\nmacros_tex=<pyiron_base.project.delayed.DelayedObject object at 0x7efce81a75f0>\n\n\n\nmacros_tex_4fdd7c93c52394e1a5aed103adf6dba4->create_function_job_9564f1c400f389023de93231c8a62a65\n\n\n\n\n\npvbatch_output_file_e4a68dc408161a17988f364b0337f341\n\npvbatch_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x7efce81a7320>\n\n\n\npvbatch_output_file_e4a68dc408161a17988f364b0337f341->macros_tex_4fdd7c93c52394e1a5aed103adf6dba4\n\n\n\n\n\npoisson_output_pvd_file_7da70c04cc70bbdbd26f7da8deeaca29\n\npoisson_output_pvd_file=<pyiron_base.project.delayed.DelayedObject object at 0x7efce81a7020>\n\n\n\npoisson_output_pvd_file_7da70c04cc70bbdbd26f7da8deeaca29->pvbatch_output_file_e4a68dc408161a17988f364b0337f341\n\n\n\n\n\nplot_file_e4a68dc408161a17988f364b0337f341\n\nplot_file=<pyiron_base.project.delayed.DelayedObject object at 0x7efce81a7320>\n\n\n\npoisson_output_pvd_file_7da70c04cc70bbdbd26f7da8deeaca29->plot_file_e4a68dc408161a17988f364b0337f341\n\n\n\n\n\nplot_file_e4a68dc408161a17988f364b0337f341->create_function_job_9564f1c400f389023de93231c8a62a65\n\n\n\n\n\nmeshio_output_xdmf_6ee525037bdcb254ca562ddfe379237e\n\nmeshio_output_xdmf=<pyiron_base.project.delayed.DelayedObject object at 0x7efce8178620>\n\n\n\nmeshio_output_xdmf_6ee525037bdcb254ca562ddfe379237e->poisson_output_pvd_file_7da70c04cc70bbdbd26f7da8deeaca29\n\n\n\n\n\npoisson_output_vtu_file_fa01b3a624ada2dba805b7518365a6a4\n\npoisson_output_vtu_file=<pyiron_base.project.delayed.DelayedObject object at 0x7efce81a6ff0>\n\n\n\nmeshio_output_xdmf_6ee525037bdcb254ca562ddfe379237e->poisson_output_vtu_file_fa01b3a624ada2dba805b7518365a6a4\n\n\n\n\n\nndofs_8b9741bf01bd3f1fc0fe9a772777a903\n\nndofs=<pyiron_base.project.delayed.DelayedObject object at 0x7efce81a73b0>\n\n\n\nmeshio_output_xdmf_6ee525037bdcb254ca562ddfe379237e->ndofs_8b9741bf01bd3f1fc0fe9a772777a903\n\n\n\n\n\npoisson_output_vtu_file_fa01b3a624ada2dba805b7518365a6a4->pvbatch_output_file_e4a68dc408161a17988f364b0337f341\n\n\n\n\n\npoisson_output_vtu_file_fa01b3a624ada2dba805b7518365a6a4->plot_file_e4a68dc408161a17988f364b0337f341\n\n\n\n\n\nndofs_8b9741bf01bd3f1fc0fe9a772777a903->macros_tex_4fdd7c93c52394e1a5aed103adf6dba4\n\n\n\n\n\ngmsh_output_file_4b409dc4c5063e64794e38b2cd0b37e1\n\ngmsh_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x7efce8ba3e90>\n\n\n\ngmsh_output_file_4b409dc4c5063e64794e38b2cd0b37e1->meshio_output_xdmf_6ee525037bdcb254ca562ddfe379237e\n\n\n\n\n\nmeshio_output_h5_f154dadcde14b5da6730af6d0a4c9df7\n\nmeshio_output_h5=<pyiron_base.project.delayed.DelayedObject object at 0x7efce81a6d20>\n\n\n\ngmsh_output_file_4b409dc4c5063e64794e38b2cd0b37e1->meshio_output_h5_f154dadcde14b5da6730af6d0a4c9df7\n\n\n\n\n\nmeshio_output_h5_f154dadcde14b5da6730af6d0a4c9df7->poisson_output_pvd_file_7da70c04cc70bbdbd26f7da8deeaca29\n\n\n\n\n\nmeshio_output_h5_f154dadcde14b5da6730af6d0a4c9df7->poisson_output_vtu_file_fa01b3a624ada2dba805b7518365a6a4\n\n\n\n\n\nmeshio_output_h5_f154dadcde14b5da6730af6d0a4c9df7->ndofs_8b9741bf01bd3f1fc0fe9a772777a903\n\n\n\n\n\ndomain_size_f12a7f1986b9dd058dfc666dbe230b20\n\ndomain_size=2.0\n\n\n\ndomain_size_f12a7f1986b9dd058dfc666dbe230b20->macros_tex_4fdd7c93c52394e1a5aed103adf6dba4\n\n\n\n\n\ndomain_size_f12a7f1986b9dd058dfc666dbe230b20->gmsh_output_file_4b409dc4c5063e64794e38b2cd0b37e1\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696\n\nsource_directory=/home/jovyan/example_workflows/nfdi/source\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->create_function_job_9564f1c400f389023de93231c8a62a65\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->macros_tex_4fdd7c93c52394e1a5aed103adf6dba4\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->pvbatch_output_file_e4a68dc408161a17988f364b0337f341\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->poisson_output_pvd_file_7da70c04cc70bbdbd26f7da8deeaca29\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->plot_file_e4a68dc408161a17988f364b0337f341\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->poisson_output_vtu_file_fa01b3a624ada2dba805b7518365a6a4\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->ndofs_8b9741bf01bd3f1fc0fe9a772777a903\n\n\n\n\n\nsource_directory_053958014e7cd4a4df22cfa51c9fc696->gmsh_output_file_4b409dc4c5063e64794e38b2cd0b37e1\n\n\n\n\n"},"metadata":{}}],"execution_count":21},{"id":"1c2760b6-96b4-4f44-ac49-a229d4a0cf67","cell_type":"code","source":"delayed_object_lst[-1].pull()","metadata":{"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"The job generate_mesh_47725c16637f799ac042e47468005db3 was saved and received the ID: 1\nThe job convert_to_xdmf_d6a46eb9a4ec352aa996e783ec3c785f was saved and received the ID: 2\nThe job poisson_3c147fc86db87cf0c0f94bda333f8cd8 was saved and received the ID: 3\nThe job plot_over_line_ef50933291910dadcc8311924971e127 was saved and received the ID: 4\nThe job substitute_macros_63766eafd6b1980c7832dd8c9a97c96e was saved and received the ID: 5\nThe job compile_paper_128d1d58374953c00e95b8de62cbb10b was saved and received the ID: 6\n"},{"execution_count":22,"output_type":"execute_result","data":{"text/plain":"'/home/jovyan/example_workflows/nfdi/postprocessing/paper.pdf'"},"metadata":{}}],"execution_count":22}]} \ No newline at end of file diff --git a/example_workflows/nfdi/pyiron_base.ipynb b/example_workflows/nfdi/pyiron_base.ipynb index 2e5506c..0c91dd0 100644 --- a/example_workflows/nfdi/pyiron_base.ipynb +++ b/example_workflows/nfdi/pyiron_base.ipynb @@ -1,312 +1 @@ -{ - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12.8", - "mimetype": "text/x-python", - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "pygments_lexer": "ipython3", - "nbconvert_exporter": "python", - "file_extension": ".py" - } - }, - "nbformat_minor": 5, - "nbformat": 4, - "cells": [ - { - "id": "106ded66-d202-46ac-82b0-2755ca309bdd", - "cell_type": "markdown", - "source": "# pyiron\n\nhttps://github.com/BAMresearch/NFDI4IngScientificWorkflowRequirements", - "metadata": {} - }, - { - "id": "91dd48ea-aa7e-4937-a68e-59fc5017eb1e", - "cell_type": "markdown", - "source": "## Define workflow with pyiron_base", - "metadata": {} - }, - { - "metadata": {}, - "cell_type": "code", - "outputs": [], - "execution_count": null, - "source": [ - "from workflow import (\n", - " generate_mesh as _generate_mesh, \n", - " convert_to_xdmf as _convert_to_xdmf,\n", - " poisson as _poisson,\n", - " plot_over_line as _plot_over_line,\n", - " substitute_macros as _substitute_macros,\n", - " compile_paper as _compile_paper,\n", - ")" - ], - "id": "d265bb5aa6af79d6" - }, - { - "metadata": {}, - "cell_type": "code", - "outputs": [], - "execution_count": null, - "source": [ - "from pyiron_base import job\n", - "\n", - "from python_workflow_definition.pyiron_base import write_workflow_json" - ], - "id": "2dced28725813fc1" - }, - { - "id": "549ecf27-88ef-4e77-8bd4-b616cfdda2e4", - "cell_type": "code", - "source": "generate_mesh = job(_generate_mesh)\nconvert_to_xdmf = job(_convert_to_xdmf, output_key_lst=[\"xdmf_file\", \"h5_file\"])\npoisson = job(_poisson, output_key_lst=[\"numdofs\", \"pvd_file\", \"vtu_file\"])\nplot_over_line = job(_plot_over_line)\nsubstitute_macros = job(_substitute_macros)\ncompile_paper = job(_compile_paper)", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 3 - }, - { - "id": "8d911f98-3b80-457f-a0f4-3cb37ebf1691", - "cell_type": "code", - "source": "domain_size = 2.0", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 4 - }, - { - "id": "71d411b6-cbec-489e-99e3-ba71680bcb5b", - "cell_type": "code", - "source": "gmsh_output_file = generate_mesh(\n domain_size=domain_size,\n)", - "metadata": { - "tags": [], - "trusted": true - }, - "outputs": [], - "execution_count": 5 - }, - { - "id": "1d0d9804-f250-48b3-a5d0-a546d520f79b", - "cell_type": "code", - "source": "meshio_output_dict = convert_to_xdmf(\n gmsh_output_file=gmsh_output_file,\n)", - "metadata": { - "tags": [], - "trusted": true - }, - "outputs": [], - "execution_count": 6 - }, - { - "id": "7b69bcff-e2b1-4d4a-b62c-6a1c86eeb590", - "cell_type": "code", - "source": "poisson_dict = poisson(\n meshio_output_xdmf=meshio_output_dict.output.xdmf_file, \n meshio_output_h5=meshio_output_dict.output.h5_file,\n)", - "metadata": { - "tags": [], - "trusted": true - }, - "outputs": [], - "execution_count": 7 - }, - { - "id": "3c4a29b0-eb1e-490a-8be0-e03cfff15e0a", - "cell_type": "code", - "source": "pvbatch_output_file = plot_over_line(\n poisson_output_pvd_file=poisson_dict.output.pvd_file, \n poisson_output_vtu_file=poisson_dict.output.vtu_file,\n)", - "metadata": { - "tags": [], - "trusted": true - }, - "outputs": [], - "execution_count": 8 - }, - { - "id": "a0a4c233-322d-4723-9627-62ca2487bfa9", - "cell_type": "code", - "source": "macros_tex_file = substitute_macros( \n pvbatch_output_file=pvbatch_output_file, \n ndofs=poisson_dict.output.numdofs, \n domain_size=domain_size,\n)", - "metadata": { - "tags": [], - "trusted": true - }, - "outputs": [], - "execution_count": 9 - }, - { - "id": "c281408f-e63d-4380-a7e6-c595d49fbb8f", - "cell_type": "code", - "source": "paper_output = compile_paper(\n macros_tex=macros_tex_file, \n plot_file=pvbatch_output_file,\n)", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 10 - }, - { - "id": "63f29646-3846-4a97-a033-20e9df0ac214", - "cell_type": "code", - "source": "workflow_json_filename = \"pyiron_base_nfdi.json\"", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 11 - }, - { - "id": "f62111ba-9271-4987-9c7e-3b1c9f9eae7a", - "cell_type": "code", - "source": "write_workflow_json(delayed_object=paper_output, file_name=workflow_json_filename)", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 12 - }, - { - "id": "d789971e-8f41-45fa-832a-11fd72dea96e", - "cell_type": "markdown", - "source": "## Load Workflow with aiida", - "metadata": {} - }, - { - "id": "a6e85e89-5d7a-40eb-809c-ac44974e3fd7", - "cell_type": "code", - "source": "from aiida import load_profile\n\nload_profile()", - "metadata": { - "trusted": true - }, - "outputs": [ - { - "execution_count": 13, - "output_type": "execute_result", - "data": { - "text/plain": "Profile" - }, - "metadata": {} - } - ], - "execution_count": 13 - }, - { - "id": "3de84fb7-b01b-4541-868a-92e881eb6e77", - "cell_type": "code", - "source": "from python_workflow_definition.aiida import load_workflow_json", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 14 - }, - { - "id": "b33f5528-10cd-47c8-8723-622902978859", - "cell_type": "code", - "source": "wg = load_workflow_json(file_name=workflow_json_filename)\nwg", - "metadata": { - "trusted": true - }, - "outputs": [ - { - "execution_count": 15, - "output_type": "execute_result", - "data": { - "text/plain": "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'WorkGra…", - "application/vnd.jupyter.widget-view+json": { - "version_major": 2, - "version_minor": 1, - "model_id": "ef807dc1b56a416796bab756bbb1896f" - } - }, - "metadata": {} - } - ], - "execution_count": 15 - }, - { - "id": "15282ca1-d339-40e7-ad68-8a7613ed08da", - "cell_type": "code", - "source": "wg.run()", - "metadata": { - "trusted": true - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": "04/23/2025 09:46:12 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|continue_workgraph]: tasks ready to run: generate_mesh6\n04/23/2025 09:46:13 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|update_task_state]: Task: generate_mesh6, type: PyFunction, finished.\n04/23/2025 09:46:13 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|continue_workgraph]: tasks ready to run: convert_to_xdmf5\n04/23/2025 09:46:15 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|update_task_state]: Task: convert_to_xdmf5, type: PyFunction, finished.\n04/23/2025 09:46:15 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|continue_workgraph]: tasks ready to run: poisson4\n04/23/2025 09:46:19 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|update_task_state]: Task: poisson4, type: PyFunction, finished.\n04/23/2025 09:46:19 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|continue_workgraph]: tasks ready to run: plot_over_line3\n04/23/2025 09:46:21 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|update_task_state]: Task: plot_over_line3, type: PyFunction, finished.\n04/23/2025 09:46:21 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|continue_workgraph]: tasks ready to run: substitute_macros2\n04/23/2025 09:46:23 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|update_task_state]: Task: substitute_macros2, type: PyFunction, finished.\n04/23/2025 09:46:23 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|continue_workgraph]: tasks ready to run: compile_paper1\n04/23/2025 09:46:26 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|update_task_state]: Task: compile_paper1, type: PyFunction, finished.\n04/23/2025 09:46:26 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n04/23/2025 09:46:26 AM <4155> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [149|WorkGraphEngine|finalize]: Finalize workgraph.\n" - } - ], - "execution_count": 16 - }, - { - "id": "55dc8d12-dfe6-4465-a368-b7e590ae6800", - "cell_type": "markdown", - "source": "## Load Workflow with jobflow", - "metadata": {} - }, - { - "id": "dff46eb8-e0e7-49bb-8c40-0db2df133124", - "cell_type": "code", - "source": "from python_workflow_definition.jobflow import load_workflow_json", - "metadata": { - "trusted": true - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": "/srv/conda/envs/notebook/lib/python3.12/site-packages/paramiko/pkey.py:82: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.\n \"cipher\": algorithms.TripleDES,\n/srv/conda/envs/notebook/lib/python3.12/site-packages/paramiko/transport.py:253: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.\n \"class\": algorithms.TripleDES,\n" - } - ], - "execution_count": 17 - }, - { - "id": "6a189459-84e4-4738-ada1-37ee8c65b2ab", - "cell_type": "code", - "source": "from jobflow.managers.local import run_locally", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 18 - }, - { - "id": "6e7f3614-c971-4e2d-83f0-96f0d0fc04de", - "cell_type": "code", - "source": "flow = load_workflow_json(file_name=workflow_json_filename)", - "metadata": { - "trusted": true - }, - "outputs": [], - "execution_count": 19 - }, - { - "id": "2d87ed45-f5d9-403f-a03a-26be4a47a3ef", - "cell_type": "code", - "source": "result = run_locally(flow)\nresult", - "metadata": { - "trusted": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": "2025-04-23 09:46:27,159 INFO Started executing jobs locally\n2025-04-23 09:46:27,488 INFO Starting job - generate_mesh (972ab469-7d1c-4dba-9d59-957741b6a6c8)\n2025-04-23 09:46:28,720 INFO Finished job - generate_mesh (972ab469-7d1c-4dba-9d59-957741b6a6c8)\n2025-04-23 09:46:28,721 INFO Starting job - convert_to_xdmf (7374ea3b-fa17-4554-bea9-5e97bf7c49a9)\n2025-04-23 09:46:30,169 INFO Finished job - convert_to_xdmf (7374ea3b-fa17-4554-bea9-5e97bf7c49a9)\n2025-04-23 09:46:30,170 INFO Starting job - poisson (5c920484-2b4a-47d1-92a1-5d2919557682)\n2025-04-23 09:46:33,008 INFO Finished job - poisson (5c920484-2b4a-47d1-92a1-5d2919557682)\n2025-04-23 09:46:33,009 INFO Starting job - plot_over_line (82770ae4-8a07-44c2-8a87-1cee9b178df5)\n2025-04-23 09:46:35,835 INFO Finished job - plot_over_line (82770ae4-8a07-44c2-8a87-1cee9b178df5)\n2025-04-23 09:46:35,836 INFO Starting job - substitute_macros (35dd4c5e-41f5-4d23-99ab-6972ad8d4827)\n2025-04-23 09:46:36,748 INFO Finished job - substitute_macros (35dd4c5e-41f5-4d23-99ab-6972ad8d4827)\n2025-04-23 09:46:36,749 INFO Starting job - compile_paper (785da10b-dd2a-47eb-9d5e-91d7e889807d)\n2025-04-23 09:46:39,139 INFO Finished job - compile_paper (785da10b-dd2a-47eb-9d5e-91d7e889807d)\n2025-04-23 09:46:39,140 INFO Finished executing jobs locally\n" - }, - { - "execution_count": 20, - "output_type": "execute_result", - "data": { - "text/plain": "{'972ab469-7d1c-4dba-9d59-957741b6a6c8': {1: Response(output='/home/jovyan/preprocessing/square.msh', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))},\n '7374ea3b-fa17-4554-bea9-5e97bf7c49a9': {1: Response(output={'xdmf_file': '/home/jovyan/preprocessing/square.xdmf', 'h5_file': '/home/jovyan/preprocessing/square.h5'}, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))},\n '5c920484-2b4a-47d1-92a1-5d2919557682': {1: Response(output={'numdofs': 357, 'pvd_file': '/home/jovyan/processing/poisson.pvd', 'vtu_file': '/home/jovyan/processing/poisson000000.vtu'}, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))},\n '82770ae4-8a07-44c2-8a87-1cee9b178df5': {1: Response(output='/home/jovyan/postprocessing/plotoverline.csv', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))},\n '35dd4c5e-41f5-4d23-99ab-6972ad8d4827': {1: Response(output='/home/jovyan/postprocessing/macros.tex', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))},\n '785da10b-dd2a-47eb-9d5e-91d7e889807d': {1: Response(output='/home/jovyan/postprocessing/paper.pdf', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))}}" - }, - "metadata": {} - } - ], - "execution_count": 20 - } - ] -} +{"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.12.8","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":5,"nbformat":4,"cells":[{"id":"106ded66-d202-46ac-82b0-2755ca309bdd","cell_type":"markdown","source":"# pyiron\n\nhttps://github.com/BAMresearch/NFDI4IngScientificWorkflowRequirements","metadata":{}},{"id":"91dd48ea-aa7e-4937-a68e-59fc5017eb1e","cell_type":"markdown","source":"## Define workflow with pyiron_base","metadata":{}},{"id":"2c9622f5-ab7e-460e-b8e4-8d21413eda77","cell_type":"code","source":"import os ","metadata":{"trusted":true},"outputs":[],"execution_count":1},{"id":"d265bb5aa6af79d6","cell_type":"code","source":"from workflow import (\n generate_mesh as _generate_mesh, \n convert_to_xdmf as _convert_to_xdmf,\n poisson as _poisson,\n plot_over_line as _plot_over_line,\n substitute_macros as _substitute_macros,\n compile_paper as _compile_paper,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":2},{"id":"2dced28725813fc1","cell_type":"code","source":"from pyiron_base import job\n\nfrom python_workflow_definition.pyiron_base import write_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":3},{"id":"549ecf27-88ef-4e77-8bd4-b616cfdda2e4","cell_type":"code","source":"generate_mesh = job(_generate_mesh)\nconvert_to_xdmf = job(_convert_to_xdmf, output_key_lst=[\"xdmf_file\", \"h5_file\"])\npoisson = job(_poisson, output_key_lst=[\"numdofs\", \"pvd_file\", \"vtu_file\"])\nplot_over_line = job(_plot_over_line)\nsubstitute_macros = job(_substitute_macros)\ncompile_paper = job(_compile_paper)","metadata":{"trusted":true},"outputs":[],"execution_count":4},{"id":"8d911f98-3b80-457f-a0f4-3cb37ebf1691","cell_type":"code","source":"domain_size = 2.0","metadata":{"trusted":true},"outputs":[],"execution_count":5},{"id":"c6ea980b-6761-4191-8407-7b1f78a4c3ea","cell_type":"code","source":"source_directory = os.path.abspath(os.path.join(os.curdir, \"source\"))","metadata":{"trusted":true},"outputs":[],"execution_count":6},{"id":"71d411b6-cbec-489e-99e3-ba71680bcb5b","cell_type":"code","source":"gmsh_output_file = generate_mesh(\n domain_size=domain_size,\n source_directory=source_directory,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":7},{"id":"1d0d9804-f250-48b3-a5d0-a546d520f79b","cell_type":"code","source":"meshio_output_dict = convert_to_xdmf(\n gmsh_output_file=gmsh_output_file,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":8},{"id":"7b69bcff-e2b1-4d4a-b62c-6a1c86eeb590","cell_type":"code","source":"poisson_dict = poisson(\n meshio_output_xdmf=meshio_output_dict.output.xdmf_file, \n meshio_output_h5=meshio_output_dict.output.h5_file,\n source_directory=source_directory,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":9},{"id":"3c4a29b0-eb1e-490a-8be0-e03cfff15e0a","cell_type":"code","source":"pvbatch_output_file = plot_over_line(\n poisson_output_pvd_file=poisson_dict.output.pvd_file, \n poisson_output_vtu_file=poisson_dict.output.vtu_file,\n source_directory=source_directory,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":10},{"id":"a0a4c233-322d-4723-9627-62ca2487bfa9","cell_type":"code","source":"macros_tex_file = substitute_macros( \n pvbatch_output_file=pvbatch_output_file, \n ndofs=poisson_dict.output.numdofs, \n domain_size=domain_size,\n source_directory=source_directory,\n)","metadata":{"tags":[],"trusted":true},"outputs":[],"execution_count":11},{"id":"c281408f-e63d-4380-a7e6-c595d49fbb8f","cell_type":"code","source":"paper_output = compile_paper(\n macros_tex=macros_tex_file, \n plot_file=pvbatch_output_file,\n source_directory=source_directory,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":12},{"id":"63f29646-3846-4a97-a033-20e9df0ac214","cell_type":"code","source":"workflow_json_filename = \"pyiron_base_nfdi.json\"","metadata":{"trusted":true},"outputs":[],"execution_count":13},{"id":"f62111ba-9271-4987-9c7e-3b1c9f9eae7a","cell_type":"code","source":"write_workflow_json(delayed_object=paper_output, file_name=workflow_json_filename)","metadata":{"trusted":true},"outputs":[],"execution_count":14},{"id":"d789971e-8f41-45fa-832a-11fd72dea96e","cell_type":"markdown","source":"## Load Workflow with aiida","metadata":{}},{"id":"a6e85e89-5d7a-40eb-809c-ac44974e3fd7","cell_type":"code","source":"from aiida import load_profile\n\nload_profile()","metadata":{"trusted":true},"outputs":[{"execution_count":15,"output_type":"execute_result","data":{"text/plain":"Profile"},"metadata":{}}],"execution_count":15},{"id":"3de84fb7-b01b-4541-868a-92e881eb6e77","cell_type":"code","source":"from python_workflow_definition.aiida import load_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":16},{"id":"b33f5528-10cd-47c8-8723-622902978859","cell_type":"code","source":"wg = load_workflow_json(file_name=workflow_json_filename)\nwg","metadata":{"trusted":true},"outputs":[{"execution_count":17,"output_type":"execute_result","data":{"text/plain":"NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'WorkGra…","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":1,"model_id":"ab6acab36bbd42c9860072a9faa50796"}},"metadata":{}}],"execution_count":17},{"id":"15282ca1-d339-40e7-ad68-8a7613ed08da","cell_type":"code","source":"wg.run()","metadata":{"trusted":true},"outputs":[{"name":"stderr","output_type":"stream","text":"05/14/2025 08:13:58 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|continue_workgraph]: tasks ready to run: generate_mesh6\n05/14/2025 08:14:00 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|update_task_state]: Task: generate_mesh6, type: PyFunction, finished.\n05/14/2025 08:14:00 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|continue_workgraph]: tasks ready to run: convert_to_xdmf5\n05/14/2025 08:14:02 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|update_task_state]: Task: convert_to_xdmf5, type: PyFunction, finished.\n05/14/2025 08:14:02 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|continue_workgraph]: tasks ready to run: poisson4\n05/14/2025 08:14:10 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|update_task_state]: Task: poisson4, type: PyFunction, finished.\n05/14/2025 08:14:10 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|continue_workgraph]: tasks ready to run: plot_over_line3\n05/14/2025 08:14:12 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|update_task_state]: Task: plot_over_line3, type: PyFunction, finished.\n05/14/2025 08:14:12 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|continue_workgraph]: tasks ready to run: substitute_macros2\n05/14/2025 08:14:13 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|update_task_state]: Task: substitute_macros2, type: PyFunction, finished.\n05/14/2025 08:14:13 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|continue_workgraph]: tasks ready to run: compile_paper1\n05/14/2025 08:15:13 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|update_task_state]: Task: compile_paper1, type: PyFunction, finished.\n05/14/2025 08:15:13 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n05/14/2025 08:15:13 AM <465> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [21|WorkGraphEngine|finalize]: Finalize workgraph.\n"}],"execution_count":18},{"id":"55dc8d12-dfe6-4465-a368-b7e590ae6800","cell_type":"markdown","source":"## Load Workflow with jobflow","metadata":{}},{"id":"dff46eb8-e0e7-49bb-8c40-0db2df133124","cell_type":"code","source":"from python_workflow_definition.jobflow import load_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":19},{"id":"6a189459-84e4-4738-ada1-37ee8c65b2ab","cell_type":"code","source":"from jobflow.managers.local import run_locally","metadata":{"trusted":true},"outputs":[],"execution_count":20},{"id":"6e7f3614-c971-4e2d-83f0-96f0d0fc04de","cell_type":"code","source":"flow = load_workflow_json(file_name=workflow_json_filename)","metadata":{"trusted":true},"outputs":[],"execution_count":21},{"id":"2d87ed45-f5d9-403f-a03a-26be4a47a3ef","cell_type":"code","source":"result = run_locally(flow)\nresult","metadata":{"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"2025-05-14 08:15:14,382 INFO Started executing jobs locally\n2025-05-14 08:15:14,545 INFO Starting job - generate_mesh (e5f18781-922f-446c-961b-3acdf00c5688)\n2025-05-14 08:15:15,654 INFO Finished job - generate_mesh (e5f18781-922f-446c-961b-3acdf00c5688)\n2025-05-14 08:15:15,655 INFO Starting job - convert_to_xdmf (2ee6c9fd-3a29-4f2a-bf4b-dd588ce58b79)\n2025-05-14 08:15:16,962 INFO Finished job - convert_to_xdmf (2ee6c9fd-3a29-4f2a-bf4b-dd588ce58b79)\n2025-05-14 08:15:16,963 INFO Starting job - poisson (ff73ebf0-2704-4c65-ab6d-a1a880634a1f)\n2025-05-14 08:15:19,635 INFO Finished job - poisson (ff73ebf0-2704-4c65-ab6d-a1a880634a1f)\n2025-05-14 08:15:19,636 INFO Starting job - plot_over_line (7225c5f3-ad66-425c-98b5-786d2a2da40d)\n2025-05-14 08:15:21,057 INFO Finished job - plot_over_line (7225c5f3-ad66-425c-98b5-786d2a2da40d)\n2025-05-14 08:15:21,059 INFO Starting job - substitute_macros (c1ae26db-a52a-491d-b5ea-52060b5fe0a7)\n2025-05-14 08:15:21,885 INFO Finished job - substitute_macros (c1ae26db-a52a-491d-b5ea-52060b5fe0a7)\n2025-05-14 08:15:21,886 INFO Starting job - compile_paper (36f03213-4816-4c5b-aa1a-a643e317e9e9)\n2025-05-14 08:15:24,020 INFO Finished job - compile_paper (36f03213-4816-4c5b-aa1a-a643e317e9e9)\n2025-05-14 08:15:24,021 INFO Finished executing jobs locally\n"},{"execution_count":22,"output_type":"execute_result","data":{"text/plain":"{'e5f18781-922f-446c-961b-3acdf00c5688': {1: Response(output='/home/jovyan/example_workflows/nfdi/preprocessing/square.msh', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan/example_workflows/nfdi'))},\n '2ee6c9fd-3a29-4f2a-bf4b-dd588ce58b79': {1: Response(output={'xdmf_file': '/home/jovyan/example_workflows/nfdi/preprocessing/square.xdmf', 'h5_file': '/home/jovyan/example_workflows/nfdi/preprocessing/square.h5'}, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan/example_workflows/nfdi'))},\n 'ff73ebf0-2704-4c65-ab6d-a1a880634a1f': {1: Response(output={'numdofs': 357, 'pvd_file': '/home/jovyan/example_workflows/nfdi/processing/poisson.pvd', 'vtu_file': '/home/jovyan/example_workflows/nfdi/processing/poisson000000.vtu'}, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan/example_workflows/nfdi'))},\n '7225c5f3-ad66-425c-98b5-786d2a2da40d': {1: Response(output='/home/jovyan/example_workflows/nfdi/postprocessing/plotoverline.csv', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan/example_workflows/nfdi'))},\n 'c1ae26db-a52a-491d-b5ea-52060b5fe0a7': {1: Response(output='/home/jovyan/example_workflows/nfdi/postprocessing/macros.tex', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan/example_workflows/nfdi'))},\n '36f03213-4816-4c5b-aa1a-a643e317e9e9': {1: Response(output='/home/jovyan/example_workflows/nfdi/postprocessing/paper.pdf', detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan/example_workflows/nfdi'))}}"},"metadata":{}}],"execution_count":22}]} \ No newline at end of file diff --git a/example_workflows/nfdi/workflow.json b/example_workflows/nfdi/workflow.json index c964fa8..c8e46c4 100644 --- a/example_workflows/nfdi/workflow.json +++ b/example_workflows/nfdi/workflow.json @@ -7,20 +7,26 @@ {"id": 4, "type": "function", "value": "workflow.substitute_macros"}, {"id": 5, "type": "function", "value": "workflow.compile_paper"}, {"id": 6, "type": "input", "value": 2.0, "name": "domain_size"}, - {"id": 7, "type": "output", "name": "result"} + {"id": 7, "type": "input", "value": "source", "name": "source_directory"}, + {"id": 8, "type": "output", "name": "result"} ], "edges": [ {"target": 0, "targetPort": "domain_size", "source": 6, "sourcePort": null}, + {"target": 0, "targetPort": "source_directory", "source": 7, "sourcePort": null}, {"target": 1, "targetPort": "gmsh_output_file", "source": 0, "sourcePort": null}, {"target": 2, "targetPort": "meshio_output_xdmf", "source": 1, "sourcePort": "xdmf_file"}, {"target": 2, "targetPort": "meshio_output_h5", "source": 1, "sourcePort": "h5_file"}, + {"target": 2, "targetPort": "source_directory", "source": 7, "sourcePort": null}, {"target": 3, "targetPort": "poisson_output_pvd_file", "source": 2, "sourcePort": "pvd_file"}, {"target": 3, "targetPort": "poisson_output_vtu_file", "source": 2, "sourcePort": "vtu_file"}, + {"target": 3, "targetPort": "source_directory", "source": 7, "sourcePort": null}, {"target": 4, "targetPort": "pvbatch_output_file", "source": 3, "sourcePort": null}, {"target": 4, "targetPort": "ndofs", "source": 2, "sourcePort": "numdofs"}, {"target": 4, "targetPort": "domain_size", "source": 6, "sourcePort": null}, + {"target": 4, "targetPort": "source_directory", "source": 7, "sourcePort": null}, {"target": 5, "targetPort": "macros_tex", "source": 4, "sourcePort": null}, {"target": 5, "targetPort": "plot_file", "source": 3, "sourcePort": null}, - {"target": 7, "targetPort": null, "source": 5, "sourcePort": null} + {"target": 5, "targetPort": "source_directory", "source": 7, "sourcePort": null}, + {"target": 8, "targetPort": null, "source": 5, "sourcePort": null} ] } \ No newline at end of file diff --git a/example_workflows/nfdi/workflow.py b/example_workflows/nfdi/workflow.py index 3893a38..03b16a7 100644 --- a/example_workflows/nfdi/workflow.py +++ b/example_workflows/nfdi/workflow.py @@ -2,15 +2,13 @@ from conda_subprocess import check_output import shutil -source_directory = os.path.join(os.path.dirname(os.path.abspath(__file__)), "source") - -def generate_mesh(domain_size: float = 2.0) -> str: +def generate_mesh(domain_size: float, source_directory: str) -> str: stage_name = "preprocessing" gmsh_output_file_name = "square.msh" source_file_name ="unit_square.geo" os.makedirs(stage_name, exist_ok=True) - _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name) + _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name, source_directory=source_directory) _ = check_output( [ "gmsh", "-2", "-setnumber", "domain_size", str(domain_size), @@ -40,13 +38,13 @@ def convert_to_xdmf(gmsh_output_file : str) -> dict: } -def poisson(meshio_output_xdmf: str, meshio_output_h5: str) -> dict: +def poisson(meshio_output_xdmf: str, meshio_output_h5: str, source_directory: str) -> dict: stage_name = "processing" poisson_output_pvd_file_name = "poisson.pvd" poisson_output_numdofs_file_name = "numdofs.txt" source_file_name = "poisson.py" os.makedirs(stage_name, exist_ok=True) - _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name) + _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name, source_directory=source_directory) _copy_file(stage_name=stage_name, source_file=meshio_output_xdmf) _copy_file(stage_name=stage_name, source_file=meshio_output_h5) _ = check_output( @@ -65,12 +63,12 @@ def poisson(meshio_output_xdmf: str, meshio_output_h5: str) -> dict: } -def plot_over_line(poisson_output_pvd_file: str, poisson_output_vtu_file: str) -> str: +def plot_over_line(poisson_output_pvd_file: str, poisson_output_vtu_file: str, source_directory: str) -> str: stage_name = "postprocessing" pvbatch_output_file_name = "plotoverline.csv" source_file_name = "postprocessing.py" os.makedirs(stage_name, exist_ok=True) - _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name) + _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name, source_directory=source_directory) _copy_file(stage_name=stage_name, source_file=poisson_output_pvd_file) _copy_file(stage_name=stage_name, source_file=poisson_output_vtu_file) _ = check_output( @@ -82,14 +80,14 @@ def plot_over_line(poisson_output_pvd_file: str, poisson_output_vtu_file: str) - return os.path.abspath(os.path.join("postprocessing", pvbatch_output_file_name)) -def substitute_macros(pvbatch_output_file: str, ndofs: int, domain_size: float = 2.0) -> str: +def substitute_macros(pvbatch_output_file: str, ndofs: int, domain_size: float, source_directory: str) -> str: stage_name = "postprocessing" source_file_name = "prepare_paper_macros.py" template_file_name = "macros.tex.template" macros_output_file_name = "macros.tex" os.makedirs(stage_name, exist_ok=True) - _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name) - _copy_file_from_source(stage_name=stage_name, source_file_name=template_file_name) + _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name, source_directory=source_directory) + _copy_file_from_source(stage_name=stage_name, source_file_name=template_file_name, source_directory=source_directory) _copy_file(stage_name=stage_name, source_file=pvbatch_output_file) _ = check_output( [ @@ -104,12 +102,12 @@ def substitute_macros(pvbatch_output_file: str, ndofs: int, domain_size: float = return os.path.abspath(os.path.join(stage_name, macros_output_file_name)) -def compile_paper(macros_tex: str, plot_file: str) -> str: +def compile_paper(macros_tex: str, plot_file: str, source_directory: str) -> str: stage_name = "postprocessing" paper_output = "paper.pdf" source_file_name = "paper.tex" os.makedirs(stage_name, exist_ok=True) - _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name) + _copy_file_from_source(stage_name=stage_name, source_file_name=source_file_name, source_directory=source_directory) _copy_file(stage_name=stage_name, source_file=macros_tex) _copy_file(stage_name=stage_name, source_file=plot_file) _ = check_output( @@ -126,12 +124,12 @@ def _poisson_collect_output(numdofs_file: str) -> int: return int(f.read()) -def _copy_file(stage_name, source_file): +def _copy_file(stage_name: str, source_file: str): input_file = os.path.join(os.path.abspath(stage_name), os.path.basename(source_file)) if input_file != source_file: shutil.copyfile(source_file, input_file) -def _copy_file_from_source(stage_name, source_file_name): +def _copy_file_from_source(stage_name: str, source_file_name: str, source_directory: str): source_file = os.path.join(source_directory, source_file_name) - shutil.copyfile(source_file, os.path.join(stage_name, source_file_name)) \ No newline at end of file + shutil.copyfile(source_file, os.path.join(stage_name, source_file_name))