Skip to content

Commit beb5a7e

Browse files
committed
Collect shared functionality in a shared module
1 parent 20c48b7 commit beb5a7e

File tree

7 files changed

+287
-127
lines changed

7 files changed

+287
-127
lines changed

pyiron_base_to_jobflow_qe.ipynb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@
4141
"outputs": [],
4242
"execution_count": 2
4343
},
44-
{
45-
"id": "78ca455d-d0b8-4814-81fa-6039f6adb4c4",
46-
"cell_type": "code",
47-
"source": "from python_workflow_definition.jobflow import load_workflow_json",
48-
"metadata": {
49-
"trusted": true
50-
},
51-
"outputs": [],
52-
"execution_count": 3
53-
},
5444
{
5545
"id": "14d87342-706e-4120-99e6-b5363f724601",
5646
"cell_type": "code",
Lines changed: 208 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,208 @@
1-
{"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}]}
1+
{
2+
"metadata": {
3+
"kernelspec": {
4+
"display_name": "Python 3 (ipykernel)",
5+
"language": "python",
6+
"name": "python3"
7+
},
8+
"language_info": {
9+
"codemirror_mode": {
10+
"name": "ipython",
11+
"version": 3
12+
},
13+
"file_extension": ".py",
14+
"mimetype": "text/x-python",
15+
"name": "python",
16+
"nbconvert_exporter": "python",
17+
"pygments_lexer": "ipython3",
18+
"version": "3.12.8"
19+
}
20+
},
21+
"nbformat_minor": 5,
22+
"nbformat": 4,
23+
"cells": [
24+
{
25+
"id": "28d69730-d8cb-4174-ae3f-aa70da8a8108",
26+
"cell_type": "code",
27+
"source": "import numpy as np",
28+
"metadata": {
29+
"trusted": true
30+
},
31+
"outputs": [],
32+
"execution_count": 1
33+
},
34+
{
35+
"id": "cacaa0a8-27c8-44de-9e37-69cd3d13408b",
36+
"cell_type": "code",
37+
"source": "from jobflow.managers.local import run_locally",
38+
"metadata": {
39+
"trusted": true
40+
},
41+
"outputs": [],
42+
"execution_count": 2
43+
},
44+
{
45+
"id": "14d87342-706e-4120-99e6-b5363f724601",
46+
"cell_type": "code",
47+
"source": "from pyiron_base import Project, job",
48+
"metadata": {
49+
"trusted": true
50+
},
51+
"outputs": [],
52+
"execution_count": 4
53+
},
54+
{
55+
"id": "a2ed2608-9e1b-4a81-81cb-5079573ea2d1",
56+
"cell_type": "code",
57+
"source": "from python_workflow_definition.pyiron_base import write_workflow_json",
58+
"metadata": {
59+
"trusted": true
60+
},
61+
"outputs": [],
62+
"execution_count": 5
63+
},
64+
{
65+
"id": "444347b0-d5ba-4903-b8d4-a9d7fc35d268",
66+
"cell_type": "code",
67+
"source": "from python_workflow_definition.jobflow import load_workflow_json",
68+
"metadata": {
69+
"trusted": true
70+
},
71+
"outputs": [],
72+
"execution_count": 6
73+
},
74+
{
75+
"id": "b75c2530-9b89-4185-838f-a17e517fa68f",
76+
"cell_type": "code",
77+
"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)",
78+
"metadata": {
79+
"trusted": true
80+
},
81+
"outputs": [],
82+
"execution_count": 7
83+
},
84+
{
85+
"id": "208ddfb8-dfda-4227-aa1f-3dc29e34ea82",
86+
"cell_type": "code",
87+
"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)",
88+
"metadata": {
89+
"trusted": true
90+
},
91+
"outputs": [],
92+
"execution_count": 8
93+
},
94+
{
95+
"id": "13debfcd-362d-4fd0-a91f-5ab33632fceb",
96+
"cell_type": "code",
97+
"source": "pr = Project(\"test\")\npr.remove_jobs(recursive=True, silently=True)",
98+
"metadata": {
99+
"trusted": true
100+
},
101+
"outputs": [
102+
{
103+
"output_type": "display_data",
104+
"data": {
105+
"text/plain": "0it [00:00, ?it/s]",
106+
"application/vnd.jupyter.widget-view+json": {
107+
"version_major": 2,
108+
"version_minor": 0,
109+
"model_id": "1bcb58b981944c688403d1eaca7b3598"
110+
}
111+
},
112+
"metadata": {}
113+
}
114+
],
115+
"execution_count": 9
116+
},
117+
{
118+
"id": "1f1cb12f-4001-478d-8ea0-b369f4f2981a",
119+
"cell_type": "code",
120+
"source": "obj = add_x_and_y(x=1, y=2, pyiron_project=pr)",
121+
"metadata": {
122+
"trusted": true
123+
},
124+
"outputs": [],
125+
"execution_count": 10
126+
},
127+
{
128+
"id": "4140f07b-af54-41ef-be22-df6b5b53bf95",
129+
"cell_type": "code",
130+
"source": "w = add_x_and_y_and_z(x=obj.output.x, y=obj.output.y, z=obj.output.z, pyiron_project=pr)",
131+
"metadata": {
132+
"trusted": true
133+
},
134+
"outputs": [],
135+
"execution_count": 11
136+
},
137+
{
138+
"id": "52646121-335f-48e6-bd5e-a1d69d00e8bc",
139+
"cell_type": "code",
140+
"source": "write_workflow_json(delayed_object=w, file_name=\"workflow_pyiron.json\")",
141+
"metadata": {
142+
"trusted": true
143+
},
144+
"outputs": [],
145+
"execution_count": 12
146+
},
147+
{
148+
"id": "72c8e6e6-8e60-4a4f-81f3-968b4b5f36ee",
149+
"cell_type": "code",
150+
"source": "!cat workflow_pyiron.json",
151+
"metadata": {
152+
"trusted": true
153+
},
154+
"outputs": [
155+
{
156+
"name": "stdout",
157+
"output_type": "stream",
158+
"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\"}]}"
159+
}
160+
],
161+
"execution_count": 13
162+
},
163+
{
164+
"id": "32fcd4b2-4f0a-442d-b098-827672823796",
165+
"cell_type": "code",
166+
"source": "flow = load_workflow_json(file_name=\"workflow_pyiron.json\")",
167+
"metadata": {
168+
"trusted": true
169+
},
170+
"outputs": [],
171+
"execution_count": 14
172+
},
173+
{
174+
"id": "a80b59bd-fe30-49c6-92ca-35ef2d77a6fb",
175+
"cell_type": "code",
176+
"source": "result = run_locally(flow)\nresult",
177+
"metadata": {
178+
"trusted": true
179+
},
180+
"outputs": [
181+
{
182+
"name": "stdout",
183+
"output_type": "stream",
184+
"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"
185+
},
186+
{
187+
"execution_count": 15,
188+
"output_type": "execute_result",
189+
"data": {
190+
"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'))}}"
191+
},
192+
"metadata": {}
193+
}
194+
],
195+
"execution_count": 15
196+
},
197+
{
198+
"id": "6a8d1a17-3698-4873-8937-616e9e7dc7ca",
199+
"cell_type": "code",
200+
"source": "",
201+
"metadata": {
202+
"trusted": true
203+
},
204+
"outputs": [],
205+
"execution_count": null
206+
}
207+
]
208+
}

0 commit comments

Comments
 (0)