Skip to content

Commit 0295262

Browse files
committed
Adding python files used for being able to enter debugger. Remove once everything works.
1 parent 9a5585b commit 0295262

File tree

5 files changed

+574
-0
lines changed

5 files changed

+574
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# %%
2+
from python_workflow_definition.aiida import write_workflow_json, construct_wg_qe
3+
from python_workflow_definition.jobflow import load_workflow_json
4+
from jobflow.managers.local import run_locally
5+
6+
from aiida import load_profile
7+
load_profile()
8+
9+
workflow_json_filename = "workflow_qe_aiida.json"
10+
11+
from aiida_workgraph import WorkGraph, task
12+
from typing import Any
13+
14+
from python_workflow_definition.shared import get_dict
15+
from python_workflow_definition.shared import get_list
16+
from quantum_espresso_workflow import generate_structures as _generate_structures
17+
from quantum_espresso_workflow import get_bulk_structure as _get_bulk_structure
18+
from quantum_espresso_workflow import calculate_qe as _calculate_qe
19+
from quantum_espresso_workflow import plot_energy_volume_curve as _plot_energy_volume_curve
20+
21+
from python_workflow_definition.aiida import pickle_node, construct_wg_qe
22+
23+
load_profile()
24+
25+
get_bulk_structure = task.pythonjob(outputs=['structure'])(_get_bulk_structure)
26+
generate_structures = task.pythonjob()(_generate_structures)
27+
calculate_qe = task.pythonjob(outputs=["energy", "volume", "structure"])(
28+
_calculate_qe
29+
)
30+
plot_energy_volume_curve= task.pythonjob()(_plot_energy_volume_curve)
31+
32+
strain_lst = [0.9, 0.95, 1.0, 1.05, 1.1]
33+
34+
wg = construct_wg_qe(
35+
get_dict=get_dict,
36+
get_list=get_list,
37+
get_bulk_structure=get_bulk_structure,
38+
calculate_qe=calculate_qe,
39+
generate_structures=generate_structures,
40+
plot_energy_volume_curve=plot_energy_volume_curve,
41+
strain_lst=strain_lst
42+
)
43+
44+
# wg.to_html('aiida_to_jobflow_qe.html')
45+
46+
47+
48+
# %%
49+
50+
write_workflow_json(wg=wg, file_name=workflow_json_filename)
51+
52+
# %%
53+
54+
flow = load_workflow_json(file_name=workflow_json_filename)
55+
56+
# %%
57+
result = run_locally(flow)
58+
result
59+
60+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# %%
2+
3+
from python_workflow_definition.aiida import write_workflow_json
4+
from python_workflow_definition.jobflow import load_workflow_json
5+
from aiida_workgraph import task, WorkGraph
6+
7+
from aiida import load_profile
8+
load_profile()
9+
10+
# %%
11+
from simple_workflow import (
12+
add_x_and_y as _add_x_and_y,
13+
add_x_and_y_and_z as _add_x_and_y_and_z,
14+
)
15+
16+
# %%
17+
from aiida import orm
18+
19+
add_x_and_y = task.pythonjob(outputs=["x", "y", "z"])(_add_x_and_y)
20+
add_x_and_y_and_z = task.pythonjob()(_add_x_and_y_and_z)
21+
22+
# workgraph = write_workflow_json(filename='workflow_simple.json')
23+
24+
# TODO: Create inputs rather than tasks out of data nodes
25+
wg = WorkGraph('wg-simple')
26+
27+
add_x_and_y_task = wg.add_task(
28+
add_x_and_y,
29+
name='add_x_and_y',
30+
x=orm.Int(1),
31+
y=orm.Int(2),
32+
)
33+
34+
add_x_and_y_and_z_task = wg.add_task(
35+
add_x_and_y_and_z,
36+
name='add_x_and_y_and_z',
37+
x=add_x_and_y_task.outputs.x,
38+
y=add_x_and_y_task.outputs.y,
39+
z=add_x_and_y_task.outputs.z,
40+
)
41+
42+
wg
43+
44+
# %%
45+
def pickle_node(value):
46+
"""Handle data nodes"""
47+
return value
48+
49+
helper_1 = task.pythonjob()(pickle_node)
50+
helper_2 = task.pythonjob()(pickle_node)
51+
52+
add_x_and_y = task.pythonjob(outputs=["x", "y", "z"])(_add_x_and_y)
53+
add_x_and_y_and_z = task.pythonjob()(_add_x_and_y_and_z)
54+
55+
# workgraph = write_workflow_json(filename='workflow_simple.json')
56+
57+
# TODO: Create inputs rather than tasks out of data nodes
58+
wg = WorkGraph('wg-simple')
59+
60+
helper_task1 = wg.add_task(
61+
helper_1,
62+
name="x",
63+
value=1
64+
)
65+
66+
helper_task2 = wg.add_task(
67+
helper_2,
68+
name="y",
69+
value=2
70+
)
71+
72+
add_x_and_y_task = wg.add_task(
73+
add_x_and_y,
74+
name='add_x_and_y',
75+
x=helper_task1.outputs.result,
76+
y=helper_task2.outputs.result,
77+
)
78+
79+
add_x_and_y_and_z_task = wg.add_task(
80+
add_x_and_y_and_z,
81+
name='add_x_and_y_and_z',
82+
x=add_x_and_y_task.outputs.x,
83+
y=add_x_and_y_task.outputs.y,
84+
z=add_x_and_y_task.outputs.z,
85+
)
86+
87+
wg
88+
89+
# %%
90+
write_workflow_json(wg=wg, file_name="workflow_simple_aiida.json")
91+
92+
93+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# %%
2+
from python_workflow_definition.aiida import write_workflow_json, construct_wg_qe
3+
from python_workflow_definition.pyiron_base import load_workflow_json
4+
from pyiron_base import Project
5+
6+
from aiida import load_profile
7+
8+
load_profile()
9+
10+
workflow_json_filename = "workflow_qe_aiida.json"
11+
12+
from aiida_workgraph import WorkGraph, task
13+
from typing import Any
14+
15+
from quantum_espresso_workflow import generate_structures as _generate_structures
16+
from quantum_espresso_workflow import get_bulk_structure as _get_bulk_structure
17+
from quantum_espresso_workflow import calculate_qe as _calculate_qe
18+
from quantum_espresso_workflow import (
19+
plot_energy_volume_curve as _plot_energy_volume_curve,
20+
)
21+
22+
from python_workflow_definition.aiida import pickle_node, construct_wg_qe
23+
24+
load_profile()
25+
26+
get_bulk_structure = task.pythonjob(outputs=["structure"])(_get_bulk_structure)
27+
generate_structures = task.pythonjob()(_generate_structures)
28+
calculate_qe = task.pythonjob(outputs=["energy", "volume", "structure"])(_calculate_qe)
29+
plot_energy_volume_curve = task.pythonjob()(_plot_energy_volume_curve)
30+
31+
strain_lst = [0.9, 0.95, 1.0, 1.05, 1.1]
32+
33+
wg = construct_wg_qe(
34+
get_bulk_structure=get_bulk_structure,
35+
calculate_qe=calculate_qe,
36+
generate_structures=generate_structures,
37+
plot_energy_volume_curve=plot_energy_volume_curve,
38+
strain_lst=strain_lst,
39+
)
40+
41+
# raise SystemExit()
42+
43+
# %%
44+
45+
write_workflow_json(wg=wg, file_name=workflow_json_filename)
46+
wg.to_html('workflow_qe_aiida.html')
47+
48+
wg.run()
49+
50+
# %%
51+
52+
pr = Project("test")
53+
pr.remove_jobs(recursive=True, silently=True)
54+
55+
56+
delayed_object = load_workflow_json(project=pr, file_name=workflow_json_filename)
57+
delayed_object.draw()
58+
59+
60+
delayed_object.pull()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# %%
2+
from python_workflow_definition.aiida import load_workflow_json
3+
4+
# %%
5+
workgraph = load_workflow_json(filename='workflow_qe.json')
6+
7+
# %%
8+
9+
# TODO: Create inputs rather than tasks out of data nodes
10+
# workgraph
11+
12+
# %%
13+
workgraph.tasks.get_bulk_structure.inputs.element
14+
15+
# %%
16+
from aiida import load_profile
17+
load_profile()
18+
19+
workgraph.run()
20+
21+
22+
# %%
23+
24+
25+

0 commit comments

Comments
 (0)