Skip to content

Commit aab9872

Browse files
committed
wip
1 parent 514684b commit aab9872

29 files changed

+3649
-242
lines changed

.bak/pwd-recursive-while/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Python Workflow Definition - Recursive While
2+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jan-janssen/pwd-recursive-while/HEAD)
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "0",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"from aiida_workgraph import task\n",
11+
"from aiida import load_profile"
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": null,
17+
"id": "1",
18+
"metadata": {},
19+
"outputs": [],
20+
"source": [
21+
"load_profile()"
22+
]
23+
},
24+
{
25+
"cell_type": "code",
26+
"execution_count": null,
27+
"id": "2",
28+
"metadata": {},
29+
"outputs": [],
30+
"source": [
31+
"@task\n",
32+
"def add(x, y):\n",
33+
" return x + y"
34+
]
35+
},
36+
{
37+
"cell_type": "code",
38+
"execution_count": null,
39+
"id": "3",
40+
"metadata": {},
41+
"outputs": [],
42+
"source": [
43+
"@task.graph\n",
44+
"def WhileLoop(n, m):\n",
45+
" if m >= n:\n",
46+
" return m\n",
47+
" m = add(x=m, y=1).result\n",
48+
" return WhileLoop(n=n, m=m)"
49+
]
50+
},
51+
{
52+
"cell_type": "code",
53+
"execution_count": null,
54+
"id": "4",
55+
"metadata": {},
56+
"outputs": [],
57+
"source": [
58+
"wg = WhileLoop.build(n=4, m=0)"
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": null,
64+
"id": "5",
65+
"metadata": {},
66+
"outputs": [],
67+
"source": [
68+
"wg.run()"
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": null,
74+
"id": "6",
75+
"metadata": {},
76+
"outputs": [],
77+
"source": []
78+
}
79+
],
80+
"metadata": {
81+
"kernelspec": {
82+
"display_name": "Python 3 (ipykernel)",
83+
"language": "python",
84+
"name": "python3"
85+
},
86+
"language_info": {
87+
"codemirror_mode": {
88+
"name": "ipython",
89+
"version": 3
90+
},
91+
"file_extension": ".py",
92+
"mimetype": "text/x-python",
93+
"name": "python",
94+
"nbconvert_exporter": "python",
95+
"pygments_lexer": "ipython3",
96+
"version": "3.12.12"
97+
}
98+
},
99+
"nbformat": 4,
100+
"nbformat_minor": 5
101+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
channels:
2+
- conda-forge
3+
dependencies:
4+
- python =3.12
5+
- jobflow =0.2.0
6+
- aiida-workgraph =0.7.3
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "0",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"from jobflow import job, Flow, Response\n",
11+
"from jobflow.managers.local import run_locally"
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": null,
17+
"id": "1",
18+
"metadata": {},
19+
"outputs": [],
20+
"source": [
21+
"@job\n",
22+
"def while_loop(n, m):\n",
23+
" if m > n: \n",
24+
" return m\n",
25+
" m += 1\n",
26+
" job_1 = while_loop(n=n, m=m)\n",
27+
" return Response(replace=job_1, output=job_1.output)"
28+
]
29+
},
30+
{
31+
"cell_type": "code",
32+
"execution_count": null,
33+
"id": "2",
34+
"metadata": {},
35+
"outputs": [],
36+
"source": [
37+
"flow = Flow([while_loop(n=5, m=0)])\n",
38+
"run_locally(flow)"
39+
]
40+
},
41+
{
42+
"cell_type": "code",
43+
"execution_count": null,
44+
"id": "3",
45+
"metadata": {},
46+
"outputs": [],
47+
"source": []
48+
}
49+
],
50+
"metadata": {
51+
"kernelspec": {
52+
"display_name": "Python 3 (ipykernel)",
53+
"language": "python",
54+
"name": "python3"
55+
},
56+
"language_info": {
57+
"codemirror_mode": {
58+
"name": "ipython",
59+
"version": 3
60+
},
61+
"file_extension": ".py",
62+
"mimetype": "text/x-python",
63+
"name": "python",
64+
"nbconvert_exporter": "python",
65+
"pygments_lexer": "ipython3",
66+
"version": "3.13.8"
67+
}
68+
},
69+
"nbformat": 4,
70+
"nbformat_minor": 5
71+
}

0 commit comments

Comments
 (0)