Skip to content

Commit 83f1d79

Browse files
authored
Add files via upload
1 parent a454bfe commit 83f1d79

File tree

2 files changed

+2
-410
lines changed

2 files changed

+2
-410
lines changed

aiida_to_jobflow_simple.ipynb

Lines changed: 1 addition & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1 @@
1-
{
2-
"cells": [
3-
{
4-
"cell_type": "code",
5-
"execution_count": null,
6-
"metadata": {},
7-
"outputs": [
8-
{
9-
"name": "stderr",
10-
"output_type": "stream",
11-
"text": [
12-
"/home/geiger_j/.aiida_venvs/adis/lib/python3.10/site-packages/paramiko/pkey.py:82: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.\n",
13-
" \"cipher\": algorithms.TripleDES,\n",
14-
"/home/geiger_j/.aiida_venvs/adis/lib/python3.10/site-packages/paramiko/transport.py:253: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.\n",
15-
" \"class\": algorithms.TripleDES,\n"
16-
]
17-
}
18-
],
19-
"source": [
20-
"from python_workflow_definition.aiida import write_workflow_json, construct_wg_simple\n",
21-
"from python_workflow_definition.jobflow import load_workflow_json\n",
22-
"from jobflow.managers.local import run_locally\n",
23-
"\n",
24-
"from aiida import load_profile\n",
25-
"load_profile()\n",
26-
"\n",
27-
"workflow_json_filename = \"aiida_to_jobflow_simple.json\""
28-
]
29-
},
30-
{
31-
"cell_type": "code",
32-
"execution_count": 2,
33-
"metadata": {},
34-
"outputs": [],
35-
"source": [
36-
"from simple_workflow import add_x_and_y, add_x_and_y_and_z"
37-
]
38-
},
39-
{
40-
"cell_type": "code",
41-
"execution_count": 3,
42-
"metadata": {},
43-
"outputs": [],
44-
"source": [
45-
"wg = construct_wg_simple(\n",
46-
" add_x_and_y_func=add_x_and_y, add_x_and_y_and_z_func=add_x_and_y_and_z\n",
47-
")"
48-
]
49-
},
50-
{
51-
"cell_type": "code",
52-
"execution_count": 4,
53-
"metadata": {},
54-
"outputs": [
55-
{
56-
"data": {
57-
"text/plain": [
58-
"{'nodes': {0: 1,\n",
59-
" 1: 2,\n",
60-
" 2: 'simple_workflow.add_x_and_y',\n",
61-
" 3: 'simple_workflow.add_x_and_y_and_z'},\n",
62-
" 'edges': [{'source': 0,\n",
63-
" 'target': 2,\n",
64-
" 'sourceHandle': None,\n",
65-
" 'targetHandle': 'x'},\n",
66-
" {'source': 1, 'target': 2, 'sourceHandle': None, 'targetHandle': 'y'},\n",
67-
" {'source': 2, 'target': 3, 'sourceHandle': 'x', 'targetHandle': 'x'},\n",
68-
" {'source': 2, 'target': 3, 'sourceHandle': 'y', 'targetHandle': 'y'},\n",
69-
" {'source': 2, 'target': 3, 'sourceHandle': 'z', 'targetHandle': 'z'}]}"
70-
]
71-
},
72-
"execution_count": 4,
73-
"metadata": {},
74-
"output_type": "execute_result"
75-
}
76-
],
77-
"source": [
78-
"write_workflow_json(wg=wg, file_name=workflow_json_filename)\n"
79-
]
80-
},
81-
{
82-
"cell_type": "code",
83-
"execution_count": 5,
84-
"metadata": {},
85-
"outputs": [],
86-
"source": [
87-
"\n",
88-
"flow = load_workflow_json(file_name=workflow_json_filename)"
89-
]
90-
},
91-
{
92-
"cell_type": "code",
93-
"execution_count": 6,
94-
"metadata": {},
95-
"outputs": [
96-
{
97-
"name": "stdout",
98-
"output_type": "stream",
99-
"text": [
100-
"2025-03-17 09:34:31,257 INFO Started executing jobs locally\n",
101-
"2025-03-17 09:34:31,421 INFO Starting job - add_x_and_y (a59c5b32-bfb1-4696-85c0-5b850df6d774)\n",
102-
"2025-03-17 09:34:31,424 INFO Finished job - add_x_and_y (a59c5b32-bfb1-4696-85c0-5b850df6d774)\n",
103-
"2025-03-17 09:34:31,425 INFO Starting job - add_x_and_y_and_z (d321223d-6de2-42b9-8f75-4675733c78d6)\n",
104-
"2025-03-17 09:34:31,426 INFO Finished job - add_x_and_y_and_z (d321223d-6de2-42b9-8f75-4675733c78d6)\n",
105-
"2025-03-17 09:34:31,427 INFO Finished executing jobs locally\n"
106-
]
107-
},
108-
{
109-
"data": {
110-
"text/plain": [
111-
"{'a59c5b32-bfb1-4696-85c0-5b850df6d774': {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/geiger_j/aiida_projects/adis/git-repos/python-workflow-definition'))},\n",
112-
" 'd321223d-6de2-42b9-8f75-4675733c78d6': {1: Response(output=6, detour=None, addition=None, replace=None, stored_data=None, stop_children=False, stop_jobflow=False, job_dir=PosixPath('/home/geiger_j/aiida_projects/adis/git-repos/python-workflow-definition'))}}"
113-
]
114-
},
115-
"execution_count": 6,
116-
"metadata": {},
117-
"output_type": "execute_result"
118-
}
119-
],
120-
"source": [
121-
"result = run_locally(flow)\n",
122-
"result"
123-
]
124-
}
125-
],
126-
"metadata": {
127-
"kernelspec": {
128-
"display_name": "ADIS",
129-
"language": "python",
130-
"name": "python3"
131-
},
132-
"language_info": {
133-
"codemirror_mode": {
134-
"name": "ipython",
135-
"version": 3
136-
},
137-
"file_extension": ".py",
138-
"mimetype": "text/x-python",
139-
"name": "python",
140-
"nbconvert_exporter": "python",
141-
"pygments_lexer": "ipython3",
142-
"version": "3.10.12"
143-
}
144-
},
145-
"nbformat": 4,
146-
"nbformat_minor": 2
147-
}
1+
{"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3 (ipykernel)","language":"python"},"language_info":{"name":"python","version":"3.12.8","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"from python_workflow_definition.aiida import write_workflow_json\nfrom python_workflow_definition.jobflow import load_workflow_json\nfrom jobflow.managers.local import run_locally\n\nfrom aiida_workgraph import WorkGraph, task\nfrom aiida import load_profile\nload_profile()\n\nworkflow_json_filename = \"aiida_to_jobflow_simple.json\"","metadata":{"trusted":true},"outputs":[{"name":"stderr","output_type":"stream","text":"/srv/conda/envs/notebook/lib/python3.12/site-packages/paramiko/pkey.py:82: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.\n \"cipher\": algorithms.TripleDES,\n/srv/conda/envs/notebook/lib/python3.12/site-packages/paramiko/transport.py:253: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from cryptography.hazmat.primitives.ciphers.algorithms in 48.0.0.\n \"class\": algorithms.TripleDES,\n"}],"execution_count":1},{"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":2},{"cell_type":"code","source":"@task.pythonjob()\ndef pickle_node(value):\n \"\"\"Handle data nodes\"\"\"\n return value","metadata":{"trusted":true},"outputs":[],"execution_count":3},{"cell_type":"code","source":"add_x_and_y = task.pythonjob(outputs=[\"x\", \"y\", \"z\"])(_add_x_and_y)\nadd_x_and_y_and_z = task.pythonjob()(_add_x_and_y_and_z)","metadata":{"trusted":true},"outputs":[],"execution_count":4},{"cell_type":"code","source":"# TODO: Create inputs rather than tasks out of data nodes\nwg = WorkGraph(\"wg-simple\")","metadata":{"trusted":true},"outputs":[],"execution_count":5},{"cell_type":"code","source":"helper_task1 = wg.add_task(pickle_node, name=\"x\", value=1)\nhelper_task2 = wg.add_task(pickle_node, name=\"y\", value=2)","metadata":{"trusted":true},"outputs":[],"execution_count":6},{"cell_type":"code","source":"add_x_and_y_task = wg.add_task(\n add_x_and_y,\n name=\"add_x_and_y\",\n x=helper_task1.outputs.result,\n y=helper_task2.outputs.result,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":7},{"cell_type":"code","source":"add_x_and_y_and_z_task = wg.add_task(\n add_x_and_y_and_z,\n name=\"add_x_and_y_and_z\",\n x=add_x_and_y_task.outputs.x,\n y=add_x_and_y_task.outputs.y,\n z=add_x_and_y_task.outputs.z,\n)","metadata":{"trusted":true},"outputs":[],"execution_count":8},{"cell_type":"code","source":"write_workflow_json(wg=wg, file_name=workflow_json_filename)","metadata":{"trusted":true},"outputs":[{"execution_count":9,"output_type":"execute_result","data":{"text/plain":"{'nodes': {'0': 1,\n '1': 2,\n '2': 'simple_workflow.add_x_and_y',\n '3': 'simple_workflow.add_x_and_y_and_z'},\n 'edges': [{'target': 2,\n 'targetHandle': 'x',\n 'source': 0,\n 'sourceHandle': None},\n {'target': 2, 'targetHandle': 'y', 'source': 1, 'sourceHandle': None},\n {'target': 3, 'targetHandle': 'x', 'source': 2, 'sourceHandle': 'x'},\n {'target': 3, 'targetHandle': 'y', 'source': 2, 'sourceHandle': 'y'},\n {'target': 3, 'targetHandle': 'z', 'source': 2, 'sourceHandle': 'z'}]}"},"metadata":{}}],"execution_count":9},{"cell_type":"code","source":"flow = load_workflow_json(file_name=workflow_json_filename)","metadata":{"trusted":true},"outputs":[],"execution_count":10},{"cell_type":"code","source":"result = run_locally(flow)\nresult","metadata":{"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"2025-03-21 20:45:40,878 INFO Started executing jobs locally\n2025-03-21 20:45:41,115 INFO Starting job - add_x_and_y (ef28440e-7d32-49d3-85f5-121da0fdf65f)\n2025-03-21 20:45:41,117 INFO Finished job - add_x_and_y (ef28440e-7d32-49d3-85f5-121da0fdf65f)\n2025-03-21 20:45:41,118 INFO Starting job - add_x_and_y_and_z (c0da46a8-a430-4d88-adb6-7d5b36b8fe52)\n2025-03-21 20:45:41,119 INFO Finished job - add_x_and_y_and_z (c0da46a8-a430-4d88-adb6-7d5b36b8fe52)\n2025-03-21 20:45:41,120 INFO Finished executing jobs locally\n"},{"execution_count":11,"output_type":"execute_result","data":{"text/plain":"{'ef28440e-7d32-49d3-85f5-121da0fdf65f': {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 'c0da46a8-a430-4d88-adb6-7d5b36b8fe52': {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":11}]}

0 commit comments

Comments
 (0)