From 1cac32066c7a40c5d92328b2bcb4476eddf3fb09 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Wed, 2 Apr 2025 12:55:14 +0200 Subject: [PATCH 01/12] Add a third workflow - comptaibility to NFDI4Ing The Workflow was originally published at: https://github.com/BAMresearch/NFDI4IngScientificWorkflowRequirements --- .github/workflows/nfdi.yml | 37 ++ jobflow_nfdi.ipynb | 822 ++++++++++++++++++++++++++++++++ nfdi_ing_workflow.py | 133 ++++++ pyiron_base_nfdi.ipynb | 424 ++++++++++++++++ source/envs/postprocessing.yaml | 5 + source/envs/preprocessing.yaml | 5 + source/envs/processing.yaml | 4 + source/macros.tex.template | 3 + source/paper.tex | 22 + source/poisson.py | 108 +++++ source/postprocessing.py | 54 +++ source/prepare_paper_macros.py | 43 ++ source/unit_square.geo | 9 + 13 files changed, 1669 insertions(+) create mode 100644 .github/workflows/nfdi.yml create mode 100644 jobflow_nfdi.ipynb create mode 100644 nfdi_ing_workflow.py create mode 100644 pyiron_base_nfdi.ipynb create mode 100644 source/envs/postprocessing.yaml create mode 100644 source/envs/preprocessing.yaml create mode 100644 source/envs/processing.yaml create mode 100644 source/macros.tex.template create mode 100644 source/paper.tex create mode 100644 source/poisson.py create mode 100644 source/postprocessing.py create mode 100644 source/prepare_paper_macros.py create mode 100644 source/unit_square.geo diff --git a/.github/workflows/nfdi.yml b/.github/workflows/nfdi.yml new file mode 100644 index 0000000..0b95f11 --- /dev/null +++ b/.github/workflows/nfdi.yml @@ -0,0 +1,37 @@ +name: NFDI4Ing + +on: + push: + branches: [ main ] + pull_request: + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + python-version: "3.12" + environment-file: environment.yml + auto-activate-base: false + - name: Installation and setup + shell: bash -l {0} + run: | + pip install -e qe_xml_parser + pip install -e python_workflow_definition + conda install -c conda-forge jupyter papermill + - name: Create Additional Conda Environments + shell: bash -l {0} + run: | + conda env create -n preprocessing -f source/envs/preprocessing.yaml -y + conda env create -n processing -f source/envs/processing.yaml -y + conda env create -n postprocessing -f source/envs/postprocessing.yaml -y + - name: Tests + shell: bash -l {0} + run: | + papermill pyiron_base_nfdi.ipynb pyiron_base_nfdi_out.ipynb -k "python3" + papermill jobflow_nfdi.ipynb jobflow_nfdi_out.ipynb -k "python3" diff --git a/jobflow_nfdi.ipynb b/jobflow_nfdi.ipynb new file mode 100644 index 0000000..af7fb0f --- /dev/null +++ b/jobflow_nfdi.ipynb @@ -0,0 +1,822 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "106ded66-d202-46ac-82b0-2755ca309bdd", + "metadata": {}, + "source": [ + "https://github.com/BAMresearch/NFDI4IngScientificWorkflowRequirements" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "6d86e804-245a-4d96-a1a3-1bc3216c3646", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "# conda environments:\n", + "#\n", + "base * /home/janssen/mambaforge\n", + "postprocessing /home/janssen/mambaforge/envs/postprocessing\n", + "preprocessing /home/janssen/mambaforge/envs/preprocessing\n", + "processing /home/janssen/mambaforge/envs/processing\n", + "\n" + ] + } + ], + "source": [ + "!conda env list" + ] + }, + { + "cell_type": "markdown", + "id": "11e09b78-cb72-465f-9c8b-5b77f0aa729c", + "metadata": {}, + "source": [ + "# Preprocessing " + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "a76e6c0a-98f2-4436-af10-8097da183341", + "metadata": {}, + "outputs": [], + "source": [ + "from nfdi_ing_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", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "89c02460-b543-442c-a27e-f1757dc2262e", + "metadata": {}, + "outputs": [], + "source": [ + "from jobflow import job, Flow" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "549ecf27-88ef-4e77-8bd4-b616cfdda2e4", + "metadata": {}, + "outputs": [], + "source": [ + "generate_mesh = job(_generate_mesh)\n", + "convert_to_xdmf = job(_convert_to_xdmf, data=[\"xdmf_file\", \"h5_file\"])\n", + "poisson = job(_poisson, data=[\"numdofs\", \"pvd_file\", \"vtu_file\"])\n", + "plot_over_line = job(_plot_over_line)\n", + "substitute_macros = job(_substitute_macros)\n", + "compile_paper = job(_compile_paper)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "8d911f98-3b80-457f-a0f4-3cb37ebf1691", + "metadata": {}, + "outputs": [], + "source": [ + "domain_size = 2.0" + ] + }, + { + "cell_type": "markdown", + "id": "cf1e22d2-9ce5-488f-8048-308d7d5d4966", + "metadata": {}, + "source": [ + "## generate mesh" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "71d411b6-cbec-489e-99e3-ba71680bcb5b", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "gmsh_output_file = generate_mesh(\n", + " domain_size=domain_size,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "019938e7-8b41-47a9-b226-00e05dabc193", + "metadata": {}, + "source": [ + "## convert to xdmf" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "1d0d9804-f250-48b3-a5d0-a546d520f79b", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "meshio_output_dict = convert_to_xdmf(\n", + " gmsh_output_file=gmsh_output_file.output,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "ceb0b643-caaa-426c-9781-28703440e647", + "metadata": {}, + "source": [ + "# Processing" + ] + }, + { + "cell_type": "markdown", + "id": "11815a8b-319c-4ff3-8eae-330bf6e58eee", + "metadata": {}, + "source": [ + "## poisson" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "7b69bcff-e2b1-4d4a-b62c-6a1c86eeb590", + "metadata": { + "tags": [] + }, + "outputs": [], + "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", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "bc8a8634-029e-4337-96a2-a1f284cb4c38", + "metadata": {}, + "source": [ + "# Postprocessing" + ] + }, + { + "cell_type": "markdown", + "id": "157c5386-91a3-4e21-ac65-8f947f2d62fa", + "metadata": {}, + "source": [ + "## plot over line" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "3c4a29b0-eb1e-490a-8be0-e03cfff15e0a", + "metadata": { + "tags": [] + }, + "outputs": [], + "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", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "54f1d4bd-b944-470f-9cf8-30e64a24eb6d", + "metadata": {}, + "source": [ + "## substitute macros" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "a0a4c233-322d-4723-9627-62ca2487bfa9", + "metadata": { + "tags": [] + }, + "outputs": [], + "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", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "2031b693-acf3-48bd-bb00-e33f669381e9", + "metadata": {}, + "source": [ + "## compile paper" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "c281408f-e63d-4380-a7e6-c595d49fbb8f", + "metadata": {}, + "outputs": [], + "source": [ + "paper_output = compile_paper(\n", + " macros_tex=macros_tex_file.output, \n", + " plot_file=pvbatch_output_file.output,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "a384d70a-8ef5-4fdd-880c-56ac7eaf87b9", + "metadata": {}, + "outputs": [], + "source": [ + "flow = Flow([gmsh_output_file, meshio_output_dict, poisson_dict, pvbatch_output_file, macros_tex_file, paper_output])" + ] + }, + { + "cell_type": "markdown", + "id": "5c1b0200-bba3-484d-ac49-f582898e974f", + "metadata": {}, + "source": [ + "# Convert " + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "196faf18-c46b-4f42-a652-698d2c580221", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.jobflow import write_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "fb23ad9c-76fd-4c0b-b546-e305d6c49796", + "metadata": {}, + "outputs": [], + "source": [ + "workflow_json_filename = \"jobflow_nfdi.json\"" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "4139547a-9717-4708-b1a5-8202a0382d77", + "metadata": {}, + "outputs": [], + "source": [ + "write_workflow_json(flow=flow, file_name=workflow_json_filename)" + ] + }, + { + "cell_type": "markdown", + "id": "397b16a2-e1ec-4eec-8562-1c84f585c347", + "metadata": {}, + "source": [ + "# Load Workflow with pyiron_base" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "fdde6b82-b51d-434a-a9a8-5a8c31bbb429", + "metadata": {}, + "outputs": [], + "source": [ + "from pyiron_base import Project" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "be4d5d93-e9f6-4072-a6be-0ee5dc93590f", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.pyiron_base import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "4db75587-5f4c-416d-a1f6-c949077fa2ca", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1f42ddabf265471cbb57f5ad5064bd4e", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "0it [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "pr = Project(\"test\")\n", + "pr.remove_jobs(recursive=True, silently=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "4452a648-d4c3-4f5f-8678-ffb54bef17dc", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", + "\n", + "create_function_job=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff65a0>\n", + "\n", + "\n", + "\n", + "macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "macros_tex=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff6300>\n", + "\n", + "\n", + "\n", + "macros_tex_f8e7c70add5a6917362eaba96348676f->create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "pvbatch_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff5fa0>\n", + "\n", + "\n", + "\n", + "pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf->macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", + "\n", + "poisson_output_pvd_file=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff5c10>\n", + "\n", + "\n", + "\n", + "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973->pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "plot_file=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff5fa0>\n", + "\n", + "\n", + "\n", + "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973->plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "plot_file_a227e82a0cabcaa4ff69b537232c3daf->create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d\n", + "\n", + "meshio_output_xdmf=<pyiron_base.project.delayed.DelayedObject object at 0x73aeac6f6c90>\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", + "\n", + "poisson_output_vtu_file=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff5ac0>\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "ndofs_af456a32dc17ccd053cef8f83b61802e\n", + "\n", + "ndofs=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff6030>\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->ndofs_af456a32dc17ccd053cef8f83b61802e\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3->pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3->plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "ndofs_af456a32dc17ccd053cef8f83b61802e->macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "gmsh_output_file_b41125ac47f34334493d860607ee71a3\n", + "\n", + "gmsh_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff5580>\n", + "\n", + "\n", + "\n", + "gmsh_output_file_b41125ac47f34334493d860607ee71a3->meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081\n", + "\n", + "meshio_output_h5=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff5310>\n", + "\n", + "\n", + "\n", + "gmsh_output_file_b41125ac47f34334493d860607ee71a3->meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->ndofs_af456a32dc17ccd053cef8f83b61802e\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "domain_size_f12a7f1986b9dd058dfc666dbe230b20\n", + "\n", + "domain_size=2.0\n", + "\n", + "\n", + "\n", + "domain_size_f12a7f1986b9dd058dfc666dbe230b20->macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "domain_size_f12a7f1986b9dd058dfc666dbe230b20->gmsh_output_file_b41125ac47f34334493d860607ee71a3\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "delayed_object = load_workflow_json(project=pr, file_name=workflow_json_filename)\n", + "delayed_object.draw()" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "1c2760b6-96b4-4f44-ac49-a229d4a0cf67", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The job generate_mesh_0b48cf5155cd6802c17d20bb58104132 was saved and received the ID: 2005\n", + "The job convert_to_xdmf_9ded0361e4866afe4962398287e4f6ae was saved and received the ID: 2006\n", + "The job poisson_2d98621ac2c8e43a266693cf65647173 was saved and received the ID: 2007\n", + "The job plot_over_line_004790462b53a54f512cc7e1a2a10519 was saved and received the ID: 2008\n", + "The job substitute_macros_52130ff9ec1931ec82532a7119df653f was saved and received the ID: 2009\n", + "The job compile_paper_b65627cdc212fc76a216689a26379fae was saved and received the ID: 2010\n" + ] + }, + { + "data": { + "text/plain": [ + "'/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/postprocessing/paper.pdf'" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "delayed_object.pull()" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "b3bba27e-ece9-4c02-834c-53e69844b140", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idstatuschemicalformulajobsubjobprojectpathprojecttimestarttimestoptotalcputimecomputerhamiltonhamversionparentidmasterid
02005finishedNonegenerate_mesh_0b48cf5155cd6802c17d20bb58104132/generate_mesh_0b48cf5155cd6802c17d20bb58104132None/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 12:21:45.438450NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
12006finishedNoneconvert_to_xdmf_9ded0361e4866afe4962398287e4f6ae/convert_to_xdmf_9ded0361e4866afe4962398287e4f6aeNone/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 12:21:51.424277NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
22007finishedNonepoisson_2d98621ac2c8e43a266693cf65647173/poisson_2d98621ac2c8e43a266693cf65647173None/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 12:21:58.678881NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
32008finishedNoneplot_over_line_004790462b53a54f512cc7e1a2a10519/plot_over_line_004790462b53a54f512cc7e1a2a10519None/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 12:22:08.130059NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
42009finishedNonesubstitute_macros_52130ff9ec1931ec82532a7119df653f/substitute_macros_52130ff9ec1931ec82532a7119df653fNone/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 12:22:15.564673NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
52010finishedNonecompile_paper_b65627cdc212fc76a216689a26379fae/compile_paper_b65627cdc212fc76a216689a26379faeNone/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 12:22:21.966167NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
\n", + "
" + ], + "text/plain": [ + " id status chemicalformula \\\n", + "0 2005 finished None \n", + "1 2006 finished None \n", + "2 2007 finished None \n", + "3 2008 finished None \n", + "4 2009 finished None \n", + "5 2010 finished None \n", + "\n", + " job \\\n", + "0 generate_mesh_0b48cf5155cd6802c17d20bb58104132 \n", + "1 convert_to_xdmf_9ded0361e4866afe4962398287e4f6ae \n", + "2 poisson_2d98621ac2c8e43a266693cf65647173 \n", + "3 plot_over_line_004790462b53a54f512cc7e1a2a10519 \n", + "4 substitute_macros_52130ff9ec1931ec82532a7119df653f \n", + "5 compile_paper_b65627cdc212fc76a216689a26379fae \n", + "\n", + " subjob projectpath \\\n", + "0 /generate_mesh_0b48cf5155cd6802c17d20bb58104132 None \n", + "1 /convert_to_xdmf_9ded0361e4866afe4962398287e4f6ae None \n", + "2 /poisson_2d98621ac2c8e43a266693cf65647173 None \n", + "3 /plot_over_line_004790462b53a54f512cc7e1a2a10519 None \n", + "4 /substitute_macros_52130ff9ec1931ec82532a7119df653f None \n", + "5 /compile_paper_b65627cdc212fc76a216689a26379fae None \n", + "\n", + " project \\\n", + "0 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "1 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "2 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "3 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "4 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "5 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "\n", + " timestart timestop totalcputime computer \\\n", + "0 2025-04-02 12:21:45.438450 None None pyiron@cmpc06#1 \n", + "1 2025-04-02 12:21:51.424277 None None pyiron@cmpc06#1 \n", + "2 2025-04-02 12:21:58.678881 None None pyiron@cmpc06#1 \n", + "3 2025-04-02 12:22:08.130059 None None pyiron@cmpc06#1 \n", + "4 2025-04-02 12:22:15.564673 None None pyiron@cmpc06#1 \n", + "5 2025-04-02 12:22:21.966167 None None pyiron@cmpc06#1 \n", + "\n", + " hamilton hamversion parentid masterid \n", + "0 PythonFunctionContainerJob 0.4 None None \n", + "1 PythonFunctionContainerJob 0.4 None None \n", + "2 PythonFunctionContainerJob 0.4 None None \n", + "3 PythonFunctionContainerJob 0.4 None None \n", + "4 PythonFunctionContainerJob 0.4 None None \n", + "5 PythonFunctionContainerJob 0.4 None None " + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pr.job_table()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/nfdi_ing_workflow.py b/nfdi_ing_workflow.py new file mode 100644 index 0000000..3fb15ec --- /dev/null +++ b/nfdi_ing_workflow.py @@ -0,0 +1,133 @@ +import os +import subprocess +import shutil + +source_directory = os.path.join(os.path.dirname(os.path.abspath(__file__)), "source") + + +def generate_mesh(domain_size: float = 2.0) -> 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) + _ = subprocess.check_output( + [ + "conda", "run", "-n", stage_name, "gmsh", "-2", "-setnumber", + "domain_size", str(domain_size), source_file_name, "-o", gmsh_output_file_name + ], + cwd=stage_name, + universal_newlines=True, + ).split("\n") + return os.path.abspath(os.path.join(stage_name, gmsh_output_file_name)) + + +def convert_to_xdmf(gmsh_output_file : str) -> str: + stage_name = "preprocessing" + meshio_output_file_name = "square.xdmf" + os.makedirs(stage_name, exist_ok=True) + _copy_file(stage_name=stage_name, source_file=gmsh_output_file) + _ = subprocess.check_output( + ["conda", "run", "-n", stage_name, "meshio", "convert", os.path.basename(gmsh_output_file), meshio_output_file_name], + cwd=stage_name, + universal_newlines=True, + ).split("\n") + return { + "xdmf": os.path.abspath(os.path.join(stage_name, meshio_output_file_name)), + "h5": os.path.join(os.path.abspath(stage_name), "square.h5"), + } + + +def poisson(meshio_output_xdmf: str, meshio_output_h5: 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(stage_name=stage_name, source_file=meshio_output_xdmf) + _copy_file(stage_name=stage_name, source_file=meshio_output_h5) + _ = subprocess.check_output( + [ + "conda", "run", "-n", stage_name, "python", "poisson.py", + "--mesh", os.path.basename(meshio_output_xdmf), "--degree", "2", + "--outputfile", poisson_output_pvd_file_name, "--num-dofs", poisson_output_numdofs_file_name + ], + cwd=stage_name, + universal_newlines=True, + ).split("\n") + return { + "numdofs": _poisson_collect_output(numdofs_file=os.path.join(stage_name, poisson_output_numdofs_file_name)), + "poisson_output_pvd_file": os.path.abspath(os.path.join(stage_name, poisson_output_pvd_file_name)), + "poisson_output_vtu_file": os.path.abspath(os.path.join(stage_name, "poisson000000.vtu")), + } + + +def plot_over_line(poisson_output_pvd_file: str, poisson_output_vtu_file: 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(stage_name=stage_name, source_file=poisson_output_pvd_file) + _copy_file(stage_name=stage_name, source_file=poisson_output_vtu_file) + _ = subprocess.check_output( + ["conda", "run", "-n", stage_name, "pvbatch", source_file_name, os.path.basename(poisson_output_pvd_file), pvbatch_output_file_name], + cwd=stage_name, + universal_newlines=True, + ).split("\n") + 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: + 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(stage_name=stage_name, source_file=pvbatch_output_file) + _ = subprocess.check_output( + [ + "conda", "run", "-n", stage_name, "python", "prepare_paper_macros.py", + "--macro-template-file", template_file_name, "--plot-data-path", os.path.basename(pvbatch_output_file), + "--domain-size", str(domain_size), "--num-dofs", str(ndofs), + "--output-macro-file", macros_output_file_name, + ], + cwd=stage_name, + universal_newlines=True, + ).split("\n") + return os.path.abspath(os.path.join(stage_name, macros_output_file_name)) + + +def compile_paper(macros_tex: str, plot_file: 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(stage_name=stage_name, source_file=macros_tex) + _copy_file(stage_name=stage_name, source_file=plot_file) + _ = subprocess.check_output( + ["conda", "run", "-n", stage_name, "tectonic", source_file_name], + universal_newlines=True, + cwd=stage_name, + ).split("\n") + return os.path.abspath(os.path.join(stage_name, paper_output)) + + +def _poisson_collect_output(numdofs_file: str) -> int: + with open(os.path.join(numdofs_file), "r") as f: + return int(f.read()) + + +def _copy_file(stage_name, source_file): + input_file = os.path.join(os.path.abspath(stage_name), source_file) + if input_file != source_file: + shutil.copyfile(source_file, input_file) + + +def _copy_file_from_source(stage_name, source_file_name): + 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 diff --git a/pyiron_base_nfdi.ipynb b/pyiron_base_nfdi.ipynb new file mode 100644 index 0000000..54ccf33 --- /dev/null +++ b/pyiron_base_nfdi.ipynb @@ -0,0 +1,424 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "106ded66-d202-46ac-82b0-2755ca309bdd", + "metadata": {}, + "source": [ + "https://github.com/BAMresearch/NFDI4IngScientificWorkflowRequirements" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "6d86e804-245a-4d96-a1a3-1bc3216c3646", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "# conda environments:\n", + "#\n", + "base * /home/janssen/mambaforge\n", + "postprocessing /home/janssen/mambaforge/envs/postprocessing\n", + "preprocessing /home/janssen/mambaforge/envs/preprocessing\n", + "processing /home/janssen/mambaforge/envs/processing\n", + "\n" + ] + } + ], + "source": [ + "!conda env list" + ] + }, + { + "cell_type": "markdown", + "id": "11e09b78-cb72-465f-9c8b-5b77f0aa729c", + "metadata": {}, + "source": [ + "# Preprocessing " + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "a76e6c0a-98f2-4436-af10-8097da183341", + "metadata": {}, + "outputs": [], + "source": [ + "from nfdi_ing_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", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "89c02460-b543-442c-a27e-f1757dc2262e", + "metadata": {}, + "outputs": [], + "source": [ + "from pyiron_base import Project, job" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "549ecf27-88ef-4e77-8bd4-b616cfdda2e4", + "metadata": {}, + "outputs": [], + "source": [ + "generate_mesh = job(_generate_mesh)\n", + "convert_to_xdmf = job(_convert_to_xdmf, output_key_lst=[\"xdmf_file\", \"h5_file\"])\n", + "poisson = job(_poisson, output_key_lst=[\"numdofs\", \"pvd_file\", \"vtu_file\"])\n", + "plot_over_line = job(_plot_over_line)\n", + "substitute_macros = job(_substitute_macros)\n", + "compile_paper = job(_compile_paper)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "508e6549-f7b8-492b-8c88-9e46c08ffca9", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "be3cedb38a374d93ae4b49d69040c4e9", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/6 [00:00 Date: Wed, 2 Apr 2025 13:21:44 +0200 Subject: [PATCH 02/12] fix output --- nfdi_ing_workflow.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nfdi_ing_workflow.py b/nfdi_ing_workflow.py index 3fb15ec..66bd290 100644 --- a/nfdi_ing_workflow.py +++ b/nfdi_ing_workflow.py @@ -33,8 +33,8 @@ def convert_to_xdmf(gmsh_output_file : str) -> str: universal_newlines=True, ).split("\n") return { - "xdmf": os.path.abspath(os.path.join(stage_name, meshio_output_file_name)), - "h5": os.path.join(os.path.abspath(stage_name), "square.h5"), + "xdmf_file": os.path.abspath(os.path.join(stage_name, meshio_output_file_name)), + "h5_file": os.path.join(os.path.abspath(stage_name), "square.h5"), } @@ -58,8 +58,8 @@ def poisson(meshio_output_xdmf: str, meshio_output_h5: str) -> dict: ).split("\n") return { "numdofs": _poisson_collect_output(numdofs_file=os.path.join(stage_name, poisson_output_numdofs_file_name)), - "poisson_output_pvd_file": os.path.abspath(os.path.join(stage_name, poisson_output_pvd_file_name)), - "poisson_output_vtu_file": os.path.abspath(os.path.join(stage_name, "poisson000000.vtu")), + "pvd_file": os.path.abspath(os.path.join(stage_name, poisson_output_pvd_file_name)), + "vtu_file": os.path.abspath(os.path.join(stage_name, "poisson000000.vtu")), } From 8e5dd7f5cb7ac11b6290a654b9829f0161ec0b9a Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Wed, 2 Apr 2025 13:35:17 +0200 Subject: [PATCH 03/12] Update nfdi.yml --- .github/workflows/nfdi.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/nfdi.yml b/.github/workflows/nfdi.yml index 0b95f11..ca96f68 100644 --- a/.github/workflows/nfdi.yml +++ b/.github/workflows/nfdi.yml @@ -7,9 +7,7 @@ on: jobs: build: - - runs-on: ubuntu-latest - + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - uses: conda-incubator/setup-miniconda@v3 From 2a4fa638c6f45b49148471d64b5400b025de255b Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Wed, 2 Apr 2025 14:28:50 +0200 Subject: [PATCH 04/12] Create apt.txt --- apt.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 apt.txt diff --git a/apt.txt b/apt.txt new file mode 100644 index 0000000..611b8e6 --- /dev/null +++ b/apt.txt @@ -0,0 +1,2 @@ +libgl1-mesa-glx +libegl1-mesa From c538e2f1d7fd404965321ad537bf1ec967523db5 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Wed, 2 Apr 2025 14:29:30 +0200 Subject: [PATCH 05/12] Update nfdi.yml --- .github/workflows/nfdi.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nfdi.yml b/.github/workflows/nfdi.yml index ca96f68..dd0d0e3 100644 --- a/.github/workflows/nfdi.yml +++ b/.github/workflows/nfdi.yml @@ -22,6 +22,7 @@ jobs: pip install -e qe_xml_parser pip install -e python_workflow_definition conda install -c conda-forge jupyter papermill + sudo apt-get install -y $(cat apt.txt) - name: Create Additional Conda Environments shell: bash -l {0} run: | From 662ec1a6bca9161de2890407068a8af50a620444 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Wed, 2 Apr 2025 15:00:15 +0200 Subject: [PATCH 06/12] bug fix --- nfdi_ing_workflow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nfdi_ing_workflow.py b/nfdi_ing_workflow.py index 66bd290..254e73b 100644 --- a/nfdi_ing_workflow.py +++ b/nfdi_ing_workflow.py @@ -123,7 +123,7 @@ def _poisson_collect_output(numdofs_file: str) -> int: def _copy_file(stage_name, source_file): - input_file = os.path.join(os.path.abspath(stage_name), source_file) + 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) From e422a1b1161f2371622496f2d904cb096db22aeb Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Wed, 2 Apr 2025 15:14:12 +0200 Subject: [PATCH 07/12] Add aiida as execution engine --- jobflow_nfdi.ipynb | 197 ++++++++++++++++++++++++++--------------- pyiron_base_nfdi.ipynb | 95 +++++++++++++++----- 2 files changed, 197 insertions(+), 95 deletions(-) diff --git a/jobflow_nfdi.ipynb b/jobflow_nfdi.ipynb index af7fb0f..b36be26 100644 --- a/jobflow_nfdi.ipynb +++ b/jobflow_nfdi.ipynb @@ -292,6 +292,57 @@ "write_workflow_json(flow=flow, file_name=workflow_json_filename)" ] }, + { + "cell_type": "markdown", + "id": "11a829e2-face-469f-b343-2c95763b1f13", + "metadata": {}, + "source": [ + "# Load Workflow with aiida" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4f3acabe-55df-479a-af4d-a23a80c4660d", + "metadata": {}, + "outputs": [], + "source": [ + "from aiida import load_profile\n", + "\n", + "load_profile()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b6ba9444-a2c8-451b-b74c-19b0f69ba369", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.aiida import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c3528d55-6bf7-47ed-a110-65c47446ba92", + "metadata": {}, + "outputs": [], + "source": [ + "wg = load_workflow_json(file_name=workflow_json_filename)\n", + "wg" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5ef48778-4209-425f-8c6b-85a4cd2f92ec", + "metadata": {}, + "outputs": [], + "source": [ + "wg.run()" + ] + }, { "cell_type": "markdown", "id": "397b16a2-e1ec-4eec-8562-1c84f585c347", @@ -329,7 +380,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "1f42ddabf265471cbb57f5ad5064bd4e", + "model_id": "b5c4c082a18b4d5391aac8dd470570d5", "version_major": 2, "version_minor": 0 }, @@ -355,182 +406,182 @@ { "data": { "image/svg+xml": [ - "\n", + "\n", "\n", - "\n", + "\n", "\n", "\n", "create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", - "\n", - "create_function_job=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff65a0>\n", + "\n", + "create_function_job=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4ab70>\n", "\n", "\n", "\n", "macros_tex_f8e7c70add5a6917362eaba96348676f\n", - "\n", - "macros_tex=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff6300>\n", + "\n", + "macros_tex=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a8d0>\n", "\n", "\n", "\n", "macros_tex_f8e7c70add5a6917362eaba96348676f->create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", - "\n", - "pvbatch_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff5fa0>\n", + "\n", + "pvbatch_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a570>\n", "\n", "\n", "\n", "pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf->macros_tex_f8e7c70add5a6917362eaba96348676f\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", - "\n", - "poisson_output_pvd_file=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff5c10>\n", + "\n", + "poisson_output_pvd_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a1e0>\n", "\n", "\n", "\n", "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973->pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", - "\n", - "plot_file=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff5fa0>\n", + "\n", + "plot_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a570>\n", "\n", "\n", "\n", "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973->plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "plot_file_a227e82a0cabcaa4ff69b537232c3daf->create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d\n", - "\n", - "meshio_output_xdmf=<pyiron_base.project.delayed.DelayedObject object at 0x73aeac6f6c90>\n", + "\n", + "meshio_output_xdmf=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d49dc0>\n", "\n", "\n", "\n", "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", - "\n", - "poisson_output_vtu_file=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff5ac0>\n", + "\n", + "poisson_output_vtu_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a090>\n", "\n", "\n", "\n", "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "ndofs_af456a32dc17ccd053cef8f83b61802e\n", - "\n", - "ndofs=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff6030>\n", + "\n", + "ndofs=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a600>\n", "\n", "\n", "\n", "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->ndofs_af456a32dc17ccd053cef8f83b61802e\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3->pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3->plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "ndofs_af456a32dc17ccd053cef8f83b61802e->macros_tex_f8e7c70add5a6917362eaba96348676f\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "gmsh_output_file_b41125ac47f34334493d860607ee71a3\n", - "\n", - "gmsh_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff5580>\n", + "\n", + "gmsh_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d49af0>\n", "\n", "\n", "\n", "gmsh_output_file_b41125ac47f34334493d860607ee71a3->meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081\n", - "\n", - "meshio_output_h5=<pyiron_base.project.delayed.DelayedObject object at 0x73aea8ff5310>\n", + "\n", + "meshio_output_h5=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d49a30>\n", "\n", "\n", "\n", "gmsh_output_file_b41125ac47f34334493d860607ee71a3->meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->ndofs_af456a32dc17ccd053cef8f83b61802e\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "domain_size_f12a7f1986b9dd058dfc666dbe230b20\n", - "\n", - "domain_size=2.0\n", + "\n", + "domain_size=2.0\n", "\n", "\n", "\n", "domain_size_f12a7f1986b9dd058dfc666dbe230b20->macros_tex_f8e7c70add5a6917362eaba96348676f\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "\n", "domain_size_f12a7f1986b9dd058dfc666dbe230b20->gmsh_output_file_b41125ac47f34334493d860607ee71a3\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "" @@ -635,7 +686,7 @@ " /generate_mesh_0b48cf5155cd6802c17d20bb58104132\n", " None\n", " /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/\n", - " 2025-04-02 12:21:45.438450\n", + " 2025-04-02 15:02:38.490191\n", " None\n", " None\n", " pyiron@cmpc06#1\n", @@ -653,7 +704,7 @@ " /convert_to_xdmf_9ded0361e4866afe4962398287e4f6ae\n", " None\n", " /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/\n", - " 2025-04-02 12:21:51.424277\n", + " 2025-04-02 15:02:45.247485\n", " None\n", " None\n", " pyiron@cmpc06#1\n", @@ -671,7 +722,7 @@ " /poisson_2d98621ac2c8e43a266693cf65647173\n", " None\n", " /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/\n", - " 2025-04-02 12:21:58.678881\n", + " 2025-04-02 15:02:52.878817\n", " None\n", " None\n", " pyiron@cmpc06#1\n", @@ -689,7 +740,7 @@ " /plot_over_line_004790462b53a54f512cc7e1a2a10519\n", " None\n", " /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/\n", - " 2025-04-02 12:22:08.130059\n", + " 2025-04-02 15:03:02.977300\n", " None\n", " None\n", " pyiron@cmpc06#1\n", @@ -707,7 +758,7 @@ " /substitute_macros_52130ff9ec1931ec82532a7119df653f\n", " None\n", " /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/\n", - " 2025-04-02 12:22:15.564673\n", + " 2025-04-02 15:03:10.674995\n", " None\n", " None\n", " pyiron@cmpc06#1\n", @@ -725,7 +776,7 @@ " /compile_paper_b65627cdc212fc76a216689a26379fae\n", " None\n", " /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/\n", - " 2025-04-02 12:22:21.966167\n", + " 2025-04-02 15:03:16.820860\n", " None\n", " None\n", " pyiron@cmpc06#1\n", @@ -772,12 +823,12 @@ "5 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", "\n", " timestart timestop totalcputime computer \\\n", - "0 2025-04-02 12:21:45.438450 None None pyiron@cmpc06#1 \n", - "1 2025-04-02 12:21:51.424277 None None pyiron@cmpc06#1 \n", - "2 2025-04-02 12:21:58.678881 None None pyiron@cmpc06#1 \n", - "3 2025-04-02 12:22:08.130059 None None pyiron@cmpc06#1 \n", - "4 2025-04-02 12:22:15.564673 None None pyiron@cmpc06#1 \n", - "5 2025-04-02 12:22:21.966167 None None pyiron@cmpc06#1 \n", + "0 2025-04-02 15:02:38.490191 None None pyiron@cmpc06#1 \n", + "1 2025-04-02 15:02:45.247485 None None pyiron@cmpc06#1 \n", + "2 2025-04-02 15:02:52.878817 None None pyiron@cmpc06#1 \n", + "3 2025-04-02 15:03:02.977300 None None pyiron@cmpc06#1 \n", + "4 2025-04-02 15:03:10.674995 None None pyiron@cmpc06#1 \n", + "5 2025-04-02 15:03:16.820860 None None pyiron@cmpc06#1 \n", "\n", " hamilton hamversion parentid masterid \n", "0 PythonFunctionContainerJob 0.4 None None \n", diff --git a/pyiron_base_nfdi.ipynb b/pyiron_base_nfdi.ipynb index 54ccf33..92f3c22 100644 --- a/pyiron_base_nfdi.ipynb +++ b/pyiron_base_nfdi.ipynb @@ -92,12 +92,12 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "be3cedb38a374d93ae4b49d69040c4e9", + "model_id": "be42f1e956da4894a40ff667564b7f53", "version_major": 2, "version_minor": 0 }, "text/plain": [ - " 0%| | 0/6 [00:00 Date: Wed, 2 Apr 2025 15:16:17 +0200 Subject: [PATCH 08/12] Include universal workflow --- .github/workflows/nfdi.yml | 1 + universal_workflow_nfdi.ipynb | 627 ++++++++++++++++++++++++++++++++++ workflow_nfdi.json | 24 ++ 3 files changed, 652 insertions(+) create mode 100644 universal_workflow_nfdi.ipynb create mode 100644 workflow_nfdi.json diff --git a/.github/workflows/nfdi.yml b/.github/workflows/nfdi.yml index dd0d0e3..a171791 100644 --- a/.github/workflows/nfdi.yml +++ b/.github/workflows/nfdi.yml @@ -34,3 +34,4 @@ jobs: run: | papermill pyiron_base_nfdi.ipynb pyiron_base_nfdi_out.ipynb -k "python3" papermill jobflow_nfdi.ipynb jobflow_nfdi_out.ipynb -k "python3" + papermill universal_workflow_nfdi.ipynb universal_workflow_nfdi_out.ipynb -k "python3" diff --git a/universal_workflow_nfdi.ipynb b/universal_workflow_nfdi.ipynb new file mode 100644 index 0000000..2ae6836 --- /dev/null +++ b/universal_workflow_nfdi.ipynb @@ -0,0 +1,627 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load Simple Workflow" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Aiida " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Profile" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from python_workflow_definition.aiida import load_workflow_json\n", + "\n", + "from aiida import load_profile\n", + "load_profile()" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "workgraph = load_workflow_json(file_name='workflow_nfdi.json')" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "c1671fb385e3469ea269044a47160225", + "version_major": 2, + "version_minor": 1 + }, + "text/plain": [ + "NodeGraphWidget(settings={'minimap': True}, style={'width': '90%', 'height': '600px'}, value={'name': 'WorkGra…" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# TODO: Create inputs rather than tasks out of data nodes\n", + "workgraph" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "03/24/2025 12:15:40 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|continue_workgraph]: tasks ready to run: pickle_node3,pickle_node4\n", + "03/24/2025 12:15:49 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 1076, 1083\n", + "03/24/2025 12:16:27 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|update_task_state]: Task: pickle_node3, type: PYTHONJOB, finished.\n", + "03/24/2025 12:16:28 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|update_task_state]: Task: pickle_node4, type: PYTHONJOB, finished.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "invalid state\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "03/24/2025 12:16:29 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|continue_workgraph]: tasks ready to run: add_x_and_y1\n", + "03/24/2025 12:16:35 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 1098\n", + "03/24/2025 12:16:58 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|update_task_state]: Task: add_x_and_y1, type: PYTHONJOB, finished.\n", + "03/24/2025 12:16:59 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|continue_workgraph]: tasks ready to run: add_x_and_y_and_z2\n", + "03/24/2025 12:17:04 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 1111\n", + "03/24/2025 12:17:23 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|update_task_state]: Task: add_x_and_y_and_z2, type: PYTHONJOB, finished.\n", + "03/24/2025 12:17:25 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n", + "03/24/2025 12:17:25 PM <259264> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [1069|WorkGraphEngine|finalize]: Finalize workgraph.\n" + ] + } + ], + "source": [ + "\n", + "workgraph.run()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## executorlib" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "from executorlib import SingleNodeExecutor" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.executorlib import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "with SingleNodeExecutor(max_workers=1) as exe:\n", + " result = load_workflow_json(file_name=\"workflow_nfdi.json\", exe=exe).result()" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "result" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Jobflow" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/jan/mambaforge/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", + "/home/jan/mambaforge/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" + ] + } + ], + "source": [ + "from jobflow.managers.local import run_locally" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.jobflow import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "flow = load_workflow_json(file_name=\"workflow_nfdi.json\")" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2025-03-24 12:17:31,659 INFO Started executing jobs locally\n", + "2025-03-24 12:17:33,059 INFO Starting job - add_x_and_y (a8004d81-a7b8-41f1-a673-17b4d6e90ebf)\n", + "2025-03-24 12:17:33,061 INFO Finished job - add_x_and_y (a8004d81-a7b8-41f1-a673-17b4d6e90ebf)\n", + "2025-03-24 12:17:33,062 INFO Starting job - add_x_and_y_and_z (26ddcedb-34b3-4b09-883d-311b2689d870)\n", + "2025-03-24 12:17:33,066 INFO Finished job - add_x_and_y_and_z (26ddcedb-34b3-4b09-883d-311b2689d870)\n", + "2025-03-24 12:17:33,070 INFO Finished executing jobs locally\n" + ] + }, + { + "data": { + "text/plain": [ + "{'a8004d81-a7b8-41f1-a673-17b4d6e90ebf': {1: Response(output={'x': 1, 'y': 2, 'z': 3}, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jan/notebooks/2025/2025-03-22-compare-workflows'))},\n", + " '26ddcedb-34b3-4b09-883d-311b2689d870': {1: Response(output=6, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jan/notebooks/2025/2025-03-22-compare-workflows'))}}" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "result = run_locally(flow)\n", + "result" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## pyiron" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "from pyiron_base import Project" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.pyiron_base import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "c62706b413eb44a391d2a24366c8ef82", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "0it [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "pr = Project(\"test\")\n", + "pr.remove_jobs(recursive=True, silently=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "create_function_job_64c8e93072cd8858b5acc14f0b6a1345\n", + "\n", + "create_function_job=<pyiron_base.project.delayed.DelayedObject object at 0x7f6346efa3f0>\n", + "\n", + "\n", + "\n", + "x_66de6656099aebbaa5cdc840b1bf9733\n", + "\n", + "x=<pyiron_base.project.delayed.DelayedObject object at 0x7f6346efa030>\n", + "\n", + "\n", + "\n", + "x_66de6656099aebbaa5cdc840b1bf9733->create_function_job_64c8e93072cd8858b5acc14f0b6a1345\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "x_1d847da32ecaabf6731c38f798c3d4ce\n", + "\n", + "x=1\n", + "\n", + "\n", + "\n", + "x_1d847da32ecaabf6731c38f798c3d4ce->x_66de6656099aebbaa5cdc840b1bf9733\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "y_12cc51ee4250f1b82f9bc22e047ad944\n", + "\n", + "y=<pyiron_base.project.delayed.DelayedObject object at 0x7f6346efa000>\n", + "\n", + "\n", + "\n", + "x_1d847da32ecaabf6731c38f798c3d4ce->y_12cc51ee4250f1b82f9bc22e047ad944\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "z_91b561a78a57aad1d943f498a3c737ed\n", + "\n", + "z=<pyiron_base.project.delayed.DelayedObject object at 0x7f6346ef9ee0>\n", + "\n", + "\n", + "\n", + "x_1d847da32ecaabf6731c38f798c3d4ce->z_91b561a78a57aad1d943f498a3c737ed\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "y_12cc51ee4250f1b82f9bc22e047ad944->create_function_job_64c8e93072cd8858b5acc14f0b6a1345\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "z_91b561a78a57aad1d943f498a3c737ed->create_function_job_64c8e93072cd8858b5acc14f0b6a1345\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "y_a9ec4f5f33f0d64e74ed5d9900bceac6\n", + "\n", + "y=2\n", + "\n", + "\n", + "\n", + "y_a9ec4f5f33f0d64e74ed5d9900bceac6->x_66de6656099aebbaa5cdc840b1bf9733\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "y_a9ec4f5f33f0d64e74ed5d9900bceac6->y_12cc51ee4250f1b82f9bc22e047ad944\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "y_a9ec4f5f33f0d64e74ed5d9900bceac6->z_91b561a78a57aad1d943f498a3c737ed\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "delayed_object = load_workflow_json(project=pr, file_name=\"workflow_nfdi.json\")\n", + "delayed_object.draw()" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The job add_x_and_y_68901482a2c5221cc845f828aabebd27 was saved and received the ID: 8\n", + "The job add_x_and_y_and_z_b671e81aaa4670d81d7eee509650af8d was saved and received the ID: 9\n" + ] + }, + { + "data": { + "text/plain": [ + "6" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "delayed_object.pull()" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idstatuschemicalformulajobsubjobprojectpathprojecttimestarttimestoptotalcputimecomputerhamiltonhamversionparentidmasterid
08finishedNoneadd_x_and_y_68901482a2c5221cc845f828aabebd27/add_x_and_y_68901482a2c5221cc845f828aabebd27None/home/jan/notebooks/2025/2025-03-22-compare-workflows/test/2025-03-24 12:17:37.412001NoneNonepyiron@p200300e77f488c66bae2561c878c14a2.dip0.t-ipconnect.de#1PythonFunctionContainerJob0.4NoneNone
19finishedNoneadd_x_and_y_and_z_b671e81aaa4670d81d7eee509650af8d/add_x_and_y_and_z_b671e81aaa4670d81d7eee509650af8dNone/home/jan/notebooks/2025/2025-03-22-compare-workflows/test/2025-03-24 12:17:39.161717NoneNonepyiron@p200300e77f488c66bae2561c878c14a2.dip0.t-ipconnect.de#1PythonFunctionContainerJob0.4NoneNone
\n", + "
" + ], + "text/plain": [ + " id status chemicalformula \\\n", + "0 8 finished None \n", + "1 9 finished None \n", + "\n", + " job \\\n", + "0 add_x_and_y_68901482a2c5221cc845f828aabebd27 \n", + "1 add_x_and_y_and_z_b671e81aaa4670d81d7eee509650af8d \n", + "\n", + " subjob projectpath \\\n", + "0 /add_x_and_y_68901482a2c5221cc845f828aabebd27 None \n", + "1 /add_x_and_y_and_z_b671e81aaa4670d81d7eee509650af8d None \n", + "\n", + " project \\\n", + "0 /home/jan/notebooks/2025/2025-03-22-compare-workflows/test/ \n", + "1 /home/jan/notebooks/2025/2025-03-22-compare-workflows/test/ \n", + "\n", + " timestart timestop totalcputime \\\n", + "0 2025-03-24 12:17:37.412001 None None \n", + "1 2025-03-24 12:17:39.161717 None None \n", + "\n", + " computer \\\n", + "0 pyiron@p200300e77f488c66bae2561c878c14a2.dip0.t-ipconnect.de#1 \n", + "1 pyiron@p200300e77f488c66bae2561c878c14a2.dip0.t-ipconnect.de#1 \n", + "\n", + " hamilton hamversion parentid masterid \n", + "0 PythonFunctionContainerJob 0.4 None None \n", + "1 PythonFunctionContainerJob 0.4 None None " + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pr.job_table()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Python" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.purepython import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "load_workflow_json(file_name=\"workflow_nfdi.json\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/workflow_nfdi.json b/workflow_nfdi.json new file mode 100644 index 0000000..141d170 --- /dev/null +++ b/workflow_nfdi.json @@ -0,0 +1,24 @@ +{ + "nodes": { + "0": "nfdi_ing_workflow.generate_mesh", + "1": "nfdi_ing_workflow.convert_to_xdmf", + "2": "nfdi_ing_workflow.poisson", + "3": "nfdi_ing_workflow.plot_over_line", + "4": "nfdi_ing_workflow.substitute_macros", + "5": "nfdi_ing_workflow.compile_paper", + "6": 2.0 + }, + "edges": [ + {"tn": 0, "th": "domain_size", "sn": 6, "sh": null}, + {"tn": 1, "th": "gmsh_output_file", "sn": 0, "sh": null}, + {"tn": 2, "th": "meshio_output_xdmf", "sn": 1, "sh": "xdmf_file"}, + {"tn": 2, "th": "meshio_output_h5", "sn": 1, "sh": "h5_file"}, + {"tn": 3, "th": "poisson_output_pvd_file", "sn": 2, "sh": "pvd_file"}, + {"tn": 3, "th": "poisson_output_vtu_file", "sn": 2, "sh": "vtu_file"}, + {"tn": 4, "th": "pvbatch_output_file", "sn": 3, "sh": null}, + {"tn": 4, "th": "ndofs", "sn": 2, "sh": "numdofs"}, + {"tn": 4, "th": "domain_size", "sn": 6, "sh": null}, + {"tn": 5, "th": "macros_tex", "sn": 4, "sh": null}, + {"tn": 5, "th": "plot_file", "sn": 3, "sh": null} + ] +} \ No newline at end of file From f338ad08f70920204b0d61982399dc507f45c266 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Wed, 2 Apr 2025 15:19:36 +0200 Subject: [PATCH 09/12] fix aiida setup --- .github/workflows/nfdi.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nfdi.yml b/.github/workflows/nfdi.yml index a171791..ac8c966 100644 --- a/.github/workflows/nfdi.yml +++ b/.github/workflows/nfdi.yml @@ -22,6 +22,7 @@ jobs: pip install -e qe_xml_parser pip install -e python_workflow_definition conda install -c conda-forge jupyter papermill + verdi presto --profile-name pwd sudo apt-get install -y $(cat apt.txt) - name: Create Additional Conda Environments shell: bash -l {0} From ffb8646335815de546d624bb37c3f6fea0e4f200 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Wed, 2 Apr 2025 15:39:54 +0200 Subject: [PATCH 10/12] Add aiida example --- .github/workflows/nfdi.yml | 3 +- aiida_nfdi.ipynb | 903 +++++++++++++++++++++++++++++++++++++ 2 files changed, 905 insertions(+), 1 deletion(-) create mode 100644 aiida_nfdi.ipynb diff --git a/.github/workflows/nfdi.yml b/.github/workflows/nfdi.yml index ac8c966..c160766 100644 --- a/.github/workflows/nfdi.yml +++ b/.github/workflows/nfdi.yml @@ -33,6 +33,7 @@ jobs: - name: Tests shell: bash -l {0} run: | - papermill pyiron_base_nfdi.ipynb pyiron_base_nfdi_out.ipynb -k "python3" + papermill aiida_nfdi.ipynb aiida_nfdi_out.ipynb -k "python3" papermill jobflow_nfdi.ipynb jobflow_nfdi_out.ipynb -k "python3" + papermill pyiron_base_nfdi.ipynb pyiron_base_nfdi_out.ipynb -k "python3" papermill universal_workflow_nfdi.ipynb universal_workflow_nfdi_out.ipynb -k "python3" diff --git a/aiida_nfdi.ipynb b/aiida_nfdi.ipynb new file mode 100644 index 0000000..195968d --- /dev/null +++ b/aiida_nfdi.ipynb @@ -0,0 +1,903 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "106ded66-d202-46ac-82b0-2755ca309bdd", + "metadata": {}, + "source": [ + "https://github.com/BAMresearch/NFDI4IngScientificWorkflowRequirements" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "6d86e804-245a-4d96-a1a3-1bc3216c3646", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "# conda environments:\n", + "#\n", + "base * /home/janssen/mambaforge\n", + "postprocessing /home/janssen/mambaforge/envs/postprocessing\n", + "preprocessing /home/janssen/mambaforge/envs/preprocessing\n", + "processing /home/janssen/mambaforge/envs/processing\n", + "\n" + ] + } + ], + "source": [ + "!conda env list" + ] + }, + { + "cell_type": "markdown", + "id": "11e09b78-cb72-465f-9c8b-5b77f0aa729c", + "metadata": {}, + "source": [ + "# Preprocessing " + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "a76e6c0a-98f2-4436-af10-8097da183341", + "metadata": {}, + "outputs": [], + "source": [ + "from nfdi_ing_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", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "89c02460-b543-442c-a27e-f1757dc2262e", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.aiida import write_workflow_json\n", + "\n", + "from aiida_workgraph import WorkGraph, task\n", + "from aiida import orm, load_profile\n", + "load_profile()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "549ecf27-88ef-4e77-8bd4-b616cfdda2e4", + "metadata": {}, + "outputs": [], + "source": [ + "convert_to_xdmf = task(outputs=[\"xdmf_file\", \"h5_file\"])(_convert_to_xdmf)\n", + "poisson = task(outputs=[\"numdofs\", \"pvd_file\", \"vtu_file\"])(_poisson)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "8d911f98-3b80-457f-a0f4-3cb37ebf1691", + "metadata": {}, + "outputs": [], + "source": [ + "domain_size = orm.Float(2.0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1e7e14ba-c4a7-485f-9bd8-44625830cca0", + "metadata": {}, + "outputs": [], + "source": [ + "wg = WorkGraph(\"wg-nfdi\")" + ] + }, + { + "cell_type": "markdown", + "id": "cf1e22d2-9ce5-488f-8048-308d7d5d4966", + "metadata": {}, + "source": [ + "## generate mesh" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "71d411b6-cbec-489e-99e3-ba71680bcb5b", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "add_x_and_y_task = wg.add_task(\n", + " generate_mesh,\n", + " name=\"generate_mesh\",\n", + " domain_size=domain_size,\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "019938e7-8b41-47a9-b226-00e05dabc193", + "metadata": {}, + "source": [ + "## convert to xdmf" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "1d0d9804-f250-48b3-a5d0-a546d520f79b", + "metadata": { + "tags": [] + }, + "outputs": [], + "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", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "ceb0b643-caaa-426c-9781-28703440e647", + "metadata": {}, + "source": [ + "# Processing" + ] + }, + { + "cell_type": "markdown", + "id": "11815a8b-319c-4ff3-8eae-330bf6e58eee", + "metadata": {}, + "source": [ + "## poisson" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "7b69bcff-e2b1-4d4a-b62c-6a1c86eeb590", + "metadata": { + "tags": [] + }, + "outputs": [], + "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", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "bc8a8634-029e-4337-96a2-a1f284cb4c38", + "metadata": {}, + "source": [ + "# Postprocessing" + ] + }, + { + "cell_type": "markdown", + "id": "157c5386-91a3-4e21-ac65-8f947f2d62fa", + "metadata": {}, + "source": [ + "## plot over line" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "3c4a29b0-eb1e-490a-8be0-e03cfff15e0a", + "metadata": { + "tags": [] + }, + "outputs": [], + "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", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "54f1d4bd-b944-470f-9cf8-30e64a24eb6d", + "metadata": {}, + "source": [ + "## substitute macros" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "a0a4c233-322d-4723-9627-62ca2487bfa9", + "metadata": { + "tags": [] + }, + "outputs": [], + "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", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "2031b693-acf3-48bd-bb00-e33f669381e9", + "metadata": {}, + "source": [ + "## compile paper" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "c281408f-e63d-4380-a7e6-c595d49fbb8f", + "metadata": {}, + "outputs": [], + "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", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "a384d70a-8ef5-4fdd-880c-56ac7eaf87b9", + "metadata": {}, + "outputs": [], + "source": [ + "wg" + ] + }, + { + "cell_type": "markdown", + "id": "5c1b0200-bba3-484d-ac49-f582898e974f", + "metadata": {}, + "source": [ + "# Convert " + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "196faf18-c46b-4f42-a652-698d2c580221", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.aiida import write_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "fb23ad9c-76fd-4c0b-b546-e305d6c49796", + "metadata": {}, + "outputs": [], + "source": [ + "workflow_json_filename = \"aiida_nfdi.json\"" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "4139547a-9717-4708-b1a5-8202a0382d77", + "metadata": {}, + "outputs": [], + "source": [ + "write_workflow_json(flow=flow, file_name=workflow_json_filename)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "490df6a3-e402-4620-acf2-dbcfa0c5d537", + "metadata": {}, + "outputs": [], + "source": [ + "!cat {workflow_json_filename}" + ] + }, + { + "cell_type": "markdown", + "id": "11a829e2-face-469f-b343-2c95763b1f13", + "metadata": {}, + "source": [ + "# Load Workflow with jobflow" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4f3acabe-55df-479a-af4d-a23a80c4660d", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.jobflow import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b6ba9444-a2c8-451b-b74c-19b0f69ba369", + "metadata": {}, + "outputs": [], + "source": [ + "from jobflow.managers.local import run_locally" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c3528d55-6bf7-47ed-a110-65c47446ba92", + "metadata": {}, + "outputs": [], + "source": [ + "flow = load_workflow_json(file_name=workflow_json_filename)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5ef48778-4209-425f-8c6b-85a4cd2f92ec", + "metadata": {}, + "outputs": [], + "source": [ + "result = run_locally(flow)\n", + "result" + ] + }, + { + "cell_type": "markdown", + "id": "397b16a2-e1ec-4eec-8562-1c84f585c347", + "metadata": {}, + "source": [ + "# Load Workflow with pyiron_base" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "fdde6b82-b51d-434a-a9a8-5a8c31bbb429", + "metadata": {}, + "outputs": [], + "source": [ + "from pyiron_base import Project" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "be4d5d93-e9f6-4072-a6be-0ee5dc93590f", + "metadata": {}, + "outputs": [], + "source": [ + "from python_workflow_definition.pyiron_base import load_workflow_json" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "4db75587-5f4c-416d-a1f6-c949077fa2ca", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "b5c4c082a18b4d5391aac8dd470570d5", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "0it [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "pr = Project(\"test\")\n", + "pr.remove_jobs(recursive=True, silently=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "4452a648-d4c3-4f5f-8678-ffb54bef17dc", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", + "\n", + "create_function_job=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4ab70>\n", + "\n", + "\n", + "\n", + "macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "macros_tex=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a8d0>\n", + "\n", + "\n", + "\n", + "macros_tex_f8e7c70add5a6917362eaba96348676f->create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "pvbatch_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a570>\n", + "\n", + "\n", + "\n", + "pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf->macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", + "\n", + "poisson_output_pvd_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a1e0>\n", + "\n", + "\n", + "\n", + "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973->pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "plot_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a570>\n", + "\n", + "\n", + "\n", + "poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973->plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "plot_file_a227e82a0cabcaa4ff69b537232c3daf->create_function_job_19ee2cba4a6ec0c97eab519834ce2c6b\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d\n", + "\n", + "meshio_output_xdmf=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d49dc0>\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", + "\n", + "poisson_output_vtu_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a090>\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "ndofs_af456a32dc17ccd053cef8f83b61802e\n", + "\n", + "ndofs=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d4a600>\n", + "\n", + "\n", + "\n", + "meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d->ndofs_af456a32dc17ccd053cef8f83b61802e\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3->pvbatch_output_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3->plot_file_a227e82a0cabcaa4ff69b537232c3daf\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "ndofs_af456a32dc17ccd053cef8f83b61802e->macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "gmsh_output_file_b41125ac47f34334493d860607ee71a3\n", + "\n", + "gmsh_output_file=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d49af0>\n", + "\n", + "\n", + "\n", + "gmsh_output_file_b41125ac47f34334493d860607ee71a3->meshio_output_xdmf_5f6efd392b1691367349ce93caf0169d\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081\n", + "\n", + "meshio_output_h5=<pyiron_base.project.delayed.DelayedObject object at 0x7de8d9d49a30>\n", + "\n", + "\n", + "\n", + "gmsh_output_file_b41125ac47f34334493d860607ee71a3->meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->poisson_output_pvd_file_3d7237a32c9c37d58bcde272202eb973\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->poisson_output_vtu_file_6970a46dfc05b1a19e5634d8c18059e3\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "meshio_output_h5_d7fa661d88a4ddaa49c65aba59c05081->ndofs_af456a32dc17ccd053cef8f83b61802e\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "domain_size_f12a7f1986b9dd058dfc666dbe230b20\n", + "\n", + "domain_size=2.0\n", + "\n", + "\n", + "\n", + "domain_size_f12a7f1986b9dd058dfc666dbe230b20->macros_tex_f8e7c70add5a6917362eaba96348676f\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "domain_size_f12a7f1986b9dd058dfc666dbe230b20->gmsh_output_file_b41125ac47f34334493d860607ee71a3\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "delayed_object = load_workflow_json(project=pr, file_name=workflow_json_filename)\n", + "delayed_object.draw()" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "1c2760b6-96b4-4f44-ac49-a229d4a0cf67", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The job generate_mesh_0b48cf5155cd6802c17d20bb58104132 was saved and received the ID: 2005\n", + "The job convert_to_xdmf_9ded0361e4866afe4962398287e4f6ae was saved and received the ID: 2006\n", + "The job poisson_2d98621ac2c8e43a266693cf65647173 was saved and received the ID: 2007\n", + "The job plot_over_line_004790462b53a54f512cc7e1a2a10519 was saved and received the ID: 2008\n", + "The job substitute_macros_52130ff9ec1931ec82532a7119df653f was saved and received the ID: 2009\n", + "The job compile_paper_b65627cdc212fc76a216689a26379fae was saved and received the ID: 2010\n" + ] + }, + { + "data": { + "text/plain": [ + "'/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/postprocessing/paper.pdf'" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "delayed_object.pull()" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "b3bba27e-ece9-4c02-834c-53e69844b140", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idstatuschemicalformulajobsubjobprojectpathprojecttimestarttimestoptotalcputimecomputerhamiltonhamversionparentidmasterid
02005finishedNonegenerate_mesh_0b48cf5155cd6802c17d20bb58104132/generate_mesh_0b48cf5155cd6802c17d20bb58104132None/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:02:38.490191NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
12006finishedNoneconvert_to_xdmf_9ded0361e4866afe4962398287e4f6ae/convert_to_xdmf_9ded0361e4866afe4962398287e4f6aeNone/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:02:45.247485NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
22007finishedNonepoisson_2d98621ac2c8e43a266693cf65647173/poisson_2d98621ac2c8e43a266693cf65647173None/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:02:52.878817NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
32008finishedNoneplot_over_line_004790462b53a54f512cc7e1a2a10519/plot_over_line_004790462b53a54f512cc7e1a2a10519None/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:03:02.977300NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
42009finishedNonesubstitute_macros_52130ff9ec1931ec82532a7119df653f/substitute_macros_52130ff9ec1931ec82532a7119df653fNone/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:03:10.674995NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
52010finishedNonecompile_paper_b65627cdc212fc76a216689a26379fae/compile_paper_b65627cdc212fc76a216689a26379faeNone/home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/2025-04-02 15:03:16.820860NoneNonepyiron@cmpc06#1PythonFunctionContainerJob0.4NoneNone
\n", + "
" + ], + "text/plain": [ + " id status chemicalformula \\\n", + "0 2005 finished None \n", + "1 2006 finished None \n", + "2 2007 finished None \n", + "3 2008 finished None \n", + "4 2009 finished None \n", + "5 2010 finished None \n", + "\n", + " job \\\n", + "0 generate_mesh_0b48cf5155cd6802c17d20bb58104132 \n", + "1 convert_to_xdmf_9ded0361e4866afe4962398287e4f6ae \n", + "2 poisson_2d98621ac2c8e43a266693cf65647173 \n", + "3 plot_over_line_004790462b53a54f512cc7e1a2a10519 \n", + "4 substitute_macros_52130ff9ec1931ec82532a7119df653f \n", + "5 compile_paper_b65627cdc212fc76a216689a26379fae \n", + "\n", + " subjob projectpath \\\n", + "0 /generate_mesh_0b48cf5155cd6802c17d20bb58104132 None \n", + "1 /convert_to_xdmf_9ded0361e4866afe4962398287e4f6ae None \n", + "2 /poisson_2d98621ac2c8e43a266693cf65647173 None \n", + "3 /plot_over_line_004790462b53a54f512cc7e1a2a10519 None \n", + "4 /substitute_macros_52130ff9ec1931ec82532a7119df653f None \n", + "5 /compile_paper_b65627cdc212fc76a216689a26379fae None \n", + "\n", + " project \\\n", + "0 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "1 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "2 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "3 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "4 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "5 /home/janssen/notebooks/2025/2025-04-02-nfdi-pwd/test/ \n", + "\n", + " timestart timestop totalcputime computer \\\n", + "0 2025-04-02 15:02:38.490191 None None pyiron@cmpc06#1 \n", + "1 2025-04-02 15:02:45.247485 None None pyiron@cmpc06#1 \n", + "2 2025-04-02 15:02:52.878817 None None pyiron@cmpc06#1 \n", + "3 2025-04-02 15:03:02.977300 None None pyiron@cmpc06#1 \n", + "4 2025-04-02 15:03:10.674995 None None pyiron@cmpc06#1 \n", + "5 2025-04-02 15:03:16.820860 None None pyiron@cmpc06#1 \n", + "\n", + " hamilton hamversion parentid masterid \n", + "0 PythonFunctionContainerJob 0.4 None None \n", + "1 PythonFunctionContainerJob 0.4 None None \n", + "2 PythonFunctionContainerJob 0.4 None None \n", + "3 PythonFunctionContainerJob 0.4 None None \n", + "4 PythonFunctionContainerJob 0.4 None None \n", + "5 PythonFunctionContainerJob 0.4 None None " + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pr.job_table()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.5" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 5b053a606a9bdb2e6a83292e57f1516d2c60d9d6 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Wed, 2 Apr 2025 15:50:01 +0200 Subject: [PATCH 11/12] Update aiida_nfdi.ipynb --- aiida_nfdi.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiida_nfdi.ipynb b/aiida_nfdi.ipynb index 195968d..12e3350 100644 --- a/aiida_nfdi.ipynb +++ b/aiida_nfdi.ipynb @@ -120,7 +120,7 @@ }, "outputs": [], "source": [ - "add_x_and_y_task = wg.add_task(\n", + "gmsh_output_file = wg.add_task(\n", " generate_mesh,\n", " name=\"generate_mesh\",\n", " domain_size=domain_size,\n", From 9949e6c9bddc39d1a676d47d4efa0f3b077fa22b Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Wed, 2 Apr 2025 15:55:37 +0200 Subject: [PATCH 12/12] Update aiida_nfdi.ipynb --- aiida_nfdi.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiida_nfdi.ipynb b/aiida_nfdi.ipynb index 12e3350..0d73c32 100644 --- a/aiida_nfdi.ipynb +++ b/aiida_nfdi.ipynb @@ -311,7 +311,7 @@ "metadata": {}, "outputs": [], "source": [ - "write_workflow_json(flow=flow, file_name=workflow_json_filename)" + "write_workflow_json(wg=wg, file_name=workflow_json_filename)" ] }, {