Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Collect shared functionality in a shared module
  • Loading branch information
jan-janssen committed Mar 15, 2025
commit beb5a7ea414710598b6fe7f1db822e550a3cbbd4
10 changes: 0 additions & 10 deletions pyiron_base_to_jobflow_qe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@
"outputs": [],
"execution_count": 2
},
{
"id": "78ca455d-d0b8-4814-81fa-6039f6adb4c4",
"cell_type": "code",
"source": "from python_workflow_definition.jobflow import load_workflow_json",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": 3
},
{
"id": "14d87342-706e-4120-99e6-b5363f724601",
"cell_type": "code",
Expand Down
209 changes: 208 additions & 1 deletion pyiron_base_to_jobflow_simple.ipynb
Original file line number Diff line number Diff line change
@@ -1 +1,208 @@
{"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.8"}},"nbformat_minor":5,"nbformat":4,"cells":[{"id":"28d69730-d8cb-4174-ae3f-aa70da8a8108","cell_type":"code","source":"import numpy as np","metadata":{"trusted":true},"outputs":[],"execution_count":1},{"id":"cacaa0a8-27c8-44de-9e37-69cd3d13408b","cell_type":"code","source":"from jobflow.managers.local import run_locally","metadata":{"trusted":true},"outputs":[],"execution_count":2},{"id":"78ca455d-d0b8-4814-81fa-6039f6adb4c4","cell_type":"code","source":"from python_workflow_definition.jobflow import load_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":3},{"id":"14d87342-706e-4120-99e6-b5363f724601","cell_type":"code","source":"from pyiron_base import Project, job","metadata":{"trusted":true},"outputs":[],"execution_count":4},{"id":"a2ed2608-9e1b-4a81-81cb-5079573ea2d1","cell_type":"code","source":"from python_workflow_definition.pyiron_base import write_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":5},{"id":"444347b0-d5ba-4903-b8d4-a9d7fc35d268","cell_type":"code","source":"from python_workflow_definition.jobflow import load_workflow_json","metadata":{"trusted":true},"outputs":[],"execution_count":6},{"id":"b75c2530-9b89-4185-838f-a17e517fa68f","cell_type":"code","source":"from simple_workflow import (\n add_x_and_y as _add_x_and_y, \n add_x_and_y_and_z as _add_x_and_y_and_z,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":7},{"id":"208ddfb8-dfda-4227-aa1f-3dc29e34ea82","cell_type":"code","source":"add_x_and_y = job(_add_x_and_y, output_key_lst=[\"x\", \"y\", \"z\"])\nadd_x_and_y_and_z = job(_add_x_and_y_and_z)","metadata":{"trusted":true},"outputs":[],"execution_count":8},{"id":"13debfcd-362d-4fd0-a91f-5ab33632fceb","cell_type":"code","source":"pr = Project(\"test\")\npr.remove_jobs(recursive=True, silently=True)","metadata":{"trusted":true},"outputs":[{"output_type":"display_data","data":{"text/plain":"0it [00:00, ?it/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"1bcb58b981944c688403d1eaca7b3598"}},"metadata":{}}],"execution_count":9},{"id":"1f1cb12f-4001-478d-8ea0-b369f4f2981a","cell_type":"code","source":"obj = add_x_and_y(x=1, y=2, pyiron_project=pr)","metadata":{"trusted":true},"outputs":[],"execution_count":10},{"id":"4140f07b-af54-41ef-be22-df6b5b53bf95","cell_type":"code","source":"w = add_x_and_y_and_z(x=obj.output.x, y=obj.output.y, z=obj.output.z, pyiron_project=pr)","metadata":{"trusted":true},"outputs":[],"execution_count":11},{"id":"52646121-335f-48e6-bd5e-a1d69d00e8bc","cell_type":"code","source":"write_workflow_json(delayed_object=w, file_name=\"workflow_pyiron.json\")","metadata":{"trusted":true},"outputs":[],"execution_count":12},{"id":"72c8e6e6-8e60-4a4f-81f3-968b4b5f36ee","cell_type":"code","source":"!cat workflow_pyiron.json","metadata":{"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"{\"nodes\": {\"0\": \"simple_workflow.add_x_and_y_and_z\", \"1\": \"simple_workflow.add_x_and_y\", \"2\": 1, \"3\": 2}, \"edges\": [{\"target\": 0, \"targetHandle\": \"x\", \"source\": 1, \"sourceHandle\": \"x\"}, {\"target\": 1, \"targetHandle\": \"x\", \"source\": 2, \"sourceHandle\": null}, {\"target\": 1, \"targetHandle\": \"y\", \"source\": 3, \"sourceHandle\": null}, {\"target\": 0, \"targetHandle\": \"y\", \"source\": 1, \"sourceHandle\": \"y\"}, {\"target\": 0, \"targetHandle\": \"z\", \"source\": 1, \"sourceHandle\": \"z\"}]}"}],"execution_count":13},{"id":"32fcd4b2-4f0a-442d-b098-827672823796","cell_type":"code","source":"flow = load_workflow_json(file_name=\"workflow_pyiron.json\")","metadata":{"trusted":true},"outputs":[],"execution_count":14},{"id":"a80b59bd-fe30-49c6-92ca-35ef2d77a6fb","cell_type":"code","source":"result = run_locally(flow)\nresult","metadata":{"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"2025-03-13 06:29:36,854 INFO Started executing jobs locally\n2025-03-13 06:29:37,166 INFO Starting job - add_x_and_y (75f3eb14-326b-46bb-848d-ef501b2d43b4)\n2025-03-13 06:29:37,169 INFO Finished job - add_x_and_y (75f3eb14-326b-46bb-848d-ef501b2d43b4)\n2025-03-13 06:29:37,170 INFO Starting job - add_x_and_y_and_z (609c1659-ec60-4211-8996-670770e4b36c)\n2025-03-13 06:29:37,172 INFO Finished job - add_x_and_y_and_z (609c1659-ec60-4211-8996-670770e4b36c)\n2025-03-13 06:29:37,172 INFO Finished executing jobs locally\n"},{"execution_count":15,"output_type":"execute_result","data":{"text/plain":"{'75f3eb14-326b-46bb-848d-ef501b2d43b4': {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/jovyan'))},\n '609c1659-ec60-4211-8996-670770e4b36c': {1: Response(output=6, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))}}"},"metadata":{}}],"execution_count":15},{"id":"6a8d1a17-3698-4873-8937-616e9e7dc7ca","cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}
{
"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.8"
}
},
"nbformat_minor": 5,
"nbformat": 4,
"cells": [
{
"id": "28d69730-d8cb-4174-ae3f-aa70da8a8108",
"cell_type": "code",
"source": "import numpy as np",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": 1
},
{
"id": "cacaa0a8-27c8-44de-9e37-69cd3d13408b",
"cell_type": "code",
"source": "from jobflow.managers.local import run_locally",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": 2
},
{
"id": "14d87342-706e-4120-99e6-b5363f724601",
"cell_type": "code",
"source": "from pyiron_base import Project, job",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": 4
},
{
"id": "a2ed2608-9e1b-4a81-81cb-5079573ea2d1",
"cell_type": "code",
"source": "from python_workflow_definition.pyiron_base import write_workflow_json",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": 5
},
{
"id": "444347b0-d5ba-4903-b8d4-a9d7fc35d268",
"cell_type": "code",
"source": "from python_workflow_definition.jobflow import load_workflow_json",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": 6
},
{
"id": "b75c2530-9b89-4185-838f-a17e517fa68f",
"cell_type": "code",
"source": "from simple_workflow import (\n add_x_and_y as _add_x_and_y, \n add_x_and_y_and_z as _add_x_and_y_and_z,\n)",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": 7
},
{
"id": "208ddfb8-dfda-4227-aa1f-3dc29e34ea82",
"cell_type": "code",
"source": "add_x_and_y = job(_add_x_and_y, output_key_lst=[\"x\", \"y\", \"z\"])\nadd_x_and_y_and_z = job(_add_x_and_y_and_z)",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": 8
},
{
"id": "13debfcd-362d-4fd0-a91f-5ab33632fceb",
"cell_type": "code",
"source": "pr = Project(\"test\")\npr.remove_jobs(recursive=True, silently=True)",
"metadata": {
"trusted": true
},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": "0it [00:00, ?it/s]",
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "1bcb58b981944c688403d1eaca7b3598"
}
},
"metadata": {}
}
],
"execution_count": 9
},
{
"id": "1f1cb12f-4001-478d-8ea0-b369f4f2981a",
"cell_type": "code",
"source": "obj = add_x_and_y(x=1, y=2, pyiron_project=pr)",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": 10
},
{
"id": "4140f07b-af54-41ef-be22-df6b5b53bf95",
"cell_type": "code",
"source": "w = add_x_and_y_and_z(x=obj.output.x, y=obj.output.y, z=obj.output.z, pyiron_project=pr)",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": 11
},
{
"id": "52646121-335f-48e6-bd5e-a1d69d00e8bc",
"cell_type": "code",
"source": "write_workflow_json(delayed_object=w, file_name=\"workflow_pyiron.json\")",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": 12
},
{
"id": "72c8e6e6-8e60-4a4f-81f3-968b4b5f36ee",
"cell_type": "code",
"source": "!cat workflow_pyiron.json",
"metadata": {
"trusted": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "{\"nodes\": {\"0\": \"simple_workflow.add_x_and_y_and_z\", \"1\": \"simple_workflow.add_x_and_y\", \"2\": 1, \"3\": 2}, \"edges\": [{\"target\": 0, \"targetHandle\": \"x\", \"source\": 1, \"sourceHandle\": \"x\"}, {\"target\": 1, \"targetHandle\": \"x\", \"source\": 2, \"sourceHandle\": null}, {\"target\": 1, \"targetHandle\": \"y\", \"source\": 3, \"sourceHandle\": null}, {\"target\": 0, \"targetHandle\": \"y\", \"source\": 1, \"sourceHandle\": \"y\"}, {\"target\": 0, \"targetHandle\": \"z\", \"source\": 1, \"sourceHandle\": \"z\"}]}"
}
],
"execution_count": 13
},
{
"id": "32fcd4b2-4f0a-442d-b098-827672823796",
"cell_type": "code",
"source": "flow = load_workflow_json(file_name=\"workflow_pyiron.json\")",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": 14
},
{
"id": "a80b59bd-fe30-49c6-92ca-35ef2d77a6fb",
"cell_type": "code",
"source": "result = run_locally(flow)\nresult",
"metadata": {
"trusted": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "2025-03-13 06:29:36,854 INFO Started executing jobs locally\n2025-03-13 06:29:37,166 INFO Starting job - add_x_and_y (75f3eb14-326b-46bb-848d-ef501b2d43b4)\n2025-03-13 06:29:37,169 INFO Finished job - add_x_and_y (75f3eb14-326b-46bb-848d-ef501b2d43b4)\n2025-03-13 06:29:37,170 INFO Starting job - add_x_and_y_and_z (609c1659-ec60-4211-8996-670770e4b36c)\n2025-03-13 06:29:37,172 INFO Finished job - add_x_and_y_and_z (609c1659-ec60-4211-8996-670770e4b36c)\n2025-03-13 06:29:37,172 INFO Finished executing jobs locally\n"
},
{
"execution_count": 15,
"output_type": "execute_result",
"data": {
"text/plain": "{'75f3eb14-326b-46bb-848d-ef501b2d43b4': {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/jovyan'))},\n '609c1659-ec60-4211-8996-670770e4b36c': {1: Response(output=6, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/jovyan'))}}"
},
"metadata": {}
}
],
"execution_count": 15
},
{
"id": "6a8d1a17-3698-4873-8937-616e9e7dc7ca",
"cell_type": "code",
"source": "",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": null
}
]
}
Loading