Skip to content

Commit aa701fa

Browse files
Add tutorial for to setting up an external computer (#214)
Co-authored-by: Elliott Kasoar <[email protected]>
1 parent 721f786 commit aa701fa

File tree

11 files changed

+255
-4
lines changed

11 files changed

+255
-4
lines changed
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "afe742d7",
6+
"metadata": {},
7+
"source": [
8+
"# Setting up an external computer"
9+
]
10+
},
11+
{
12+
"cell_type": "markdown",
13+
"id": "927e4a25",
14+
"metadata": {},
15+
"source": [
16+
"## Aim"
17+
]
18+
},
19+
{
20+
"cell_type": "markdown",
21+
"id": "1c46a870",
22+
"metadata": {},
23+
"source": [
24+
"This tutorial walks through the steps that may be required to submit AiiDA jobs to an external computer, including configuring a new profile, setting up the remote computer, configuring the transport layer and creating an external code."
25+
]
26+
},
27+
{
28+
"cell_type": "markdown",
29+
"id": "1ab75593",
30+
"metadata": {},
31+
"source": [
32+
"## Setup"
33+
]
34+
},
35+
{
36+
"cell_type": "markdown",
37+
"id": "e7ba5ac9",
38+
"metadata": {},
39+
"source": [
40+
"For this tutorial we will assume you have:\n",
41+
"\n",
42+
"<ul>\n",
43+
" <li>AiiDA installed locally</li>\n",
44+
" <li>Quantum Espresso installed on the remote computer</li>\n",
45+
"</ul>"
46+
]
47+
},
48+
{
49+
"cell_type": "markdown",
50+
"id": "f16a8c8e",
51+
"metadata": {},
52+
"source": [
53+
"### Profile"
54+
]
55+
},
56+
{
57+
"cell_type": "markdown",
58+
"id": "01a1e762",
59+
"metadata": {},
60+
"source": [
61+
"For simplicity, we will use `verdi presto` to set up our profile, which creates a profile and default user, sets up the localhost computer, and configures the database. \n",
62+
"\n",
63+
"By default, this will use SQLite for the database, and RabbitMQ will be configured if it is discoverable, but it is not required.\n",
64+
"\n",
65+
"\n",
66+
"For production work, PostgreSQL and RabbitMQ are both strongly recommended, which can be configured either through `verdi presto`, or manually through `verdi profile setup`.\n",
67+
"\n",
68+
"Please refer to the [AiiDA's \"Create a Profile\" documentation](https://aiida.readthedocs.io/projects/aiida-core/en/stable/installation/guide_complete.html#create-a-profile) for more details."
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": null,
74+
"id": "1bdc9a19",
75+
"metadata": {},
76+
"outputs": [],
77+
"source": [
78+
"! verdi presto -p scarf"
79+
]
80+
},
81+
{
82+
"cell_type": "markdown",
83+
"id": "a4c7c122",
84+
"metadata": {},
85+
"source": [
86+
"### Computer"
87+
]
88+
},
89+
{
90+
"cell_type": "markdown",
91+
"id": "a6696a1e",
92+
"metadata": {},
93+
"source": [
94+
"We will set up the remote computer, STFC's [SCARF HPC cluster](https://www.scarf.rl.ac.uk) in this example. The values in square brackets should be changed as required for your remote system.\n",
95+
"\n",
96+
"For more information on these settings, refer to the [AiiDA's \"Computer Setup\" documentation](https://aiida.readthedocs.io/projects/aiida-core/en/stable/howto/run_codes.html#computer-setup).\n",
97+
"\n",
98+
"**Note:** We are loading the module we want in `prepend_text`. As we will be needing Quantum Espresso to load the code in the later steps we will load it now, otherwise you can leave it empty (`prepend_text: ''`)"
99+
]
100+
},
101+
{
102+
"cell_type": "code",
103+
"execution_count": null,
104+
"id": "65057015",
105+
"metadata": {},
106+
"outputs": [],
107+
"source": [
108+
"%%writefile ~/computer.yaml\n",
109+
"label: [scarf]\n",
110+
"description: [https://www.scarf.rl.ac.uk/index.html]\n",
111+
"hostname: [ui1.scarf.rl.ac.uk]\n",
112+
"transport: core.ssh\n",
113+
"scheduler: core.slurm\n",
114+
"shebang: '#!/bin/bash'\n",
115+
"work_dir: [/work4/scd/scarf/aiida]\n",
116+
"mpirun_command: srun -u -n {tot_num_mpiprocs}\n",
117+
"mpiprocs_per_machine: 32\n",
118+
"use_double_quotes: False\n",
119+
"prepend_text: |\n",
120+
" module load amd-modules\n",
121+
" module load QuantumESPRESSO/7.2-foss-2023a\n",
122+
"append_text: ''"
123+
]
124+
},
125+
{
126+
"cell_type": "markdown",
127+
"id": "c7b34fe6",
128+
"metadata": {},
129+
"source": [
130+
"Run the following commands. First we set up the computer."
131+
]
132+
},
133+
{
134+
"cell_type": "code",
135+
"execution_count": null,
136+
"id": "811e10d3",
137+
"metadata": {},
138+
"outputs": [],
139+
"source": [
140+
"! verdi computer setup -n --config ~/computer.yaml"
141+
]
142+
},
143+
{
144+
"cell_type": "markdown",
145+
"id": "963d43fa",
146+
"metadata": {},
147+
"source": [
148+
"If you have an SSH config file setup in ~/.ssh/config, AiiDA can automatically parse most of the required information to set up the transport layer, as described in the [\"AiiDA Configuration\" documentation](https://aiida.readthedocs.io/projects/aiida-core/en/stable/howto/ssh.html#id1).\n",
149+
"\n",
150+
"If not, we can configure the computer for the ssh transport manually. Make sure to change the settings in square brackets with your settings.\n",
151+
"\n",
152+
"[AiiDA's \"Computer Connection Configuration\" documentation](https://aiida.readthedocs.io/projects/aiida-core/en/stable/howto/run_codes.html#computer-connection-configuration) goes over how to configure a computer in more detail."
153+
]
154+
},
155+
{
156+
"cell_type": "code",
157+
"execution_count": null,
158+
"id": "eaf2e067",
159+
"metadata": {},
160+
"outputs": [],
161+
"source": [
162+
"! verdi computer configure core.ssh [scarf] -n --username [scarf] --key-filename ['/path/to/ssh/key'] --key-policy AutoAddPolicy --safe-interval 30.0"
163+
]
164+
},
165+
{
166+
"cell_type": "markdown",
167+
"id": "a8fccf0e",
168+
"metadata": {},
169+
"source": [
170+
"Once the computer is set up, you can test the connection"
171+
]
172+
},
173+
{
174+
"cell_type": "code",
175+
"execution_count": null,
176+
"id": "ce2132c3",
177+
"metadata": {},
178+
"outputs": [],
179+
"source": [
180+
"! verdi computer test [scarf]"
181+
]
182+
},
183+
{
184+
"cell_type": "markdown",
185+
"id": "25efa7b3",
186+
"metadata": {},
187+
"source": [
188+
"### External Code"
189+
]
190+
},
191+
{
192+
"cell_type": "markdown",
193+
"id": "c376a8be",
194+
"metadata": {},
195+
"source": [
196+
"If you want to run a calculation that is only available on the external machine, you can set up a code which accesses the external library. For more information, use `verdi code create -h`, or refer to the [AiiDA \"Create a Code\" documentation](https://aiida.readthedocs.io/projects/aiida-core/en/stable/howto/run_codes.html#how-to-create-a-code)"
197+
]
198+
},
199+
{
200+
"cell_type": "code",
201+
"execution_count": null,
202+
"id": "475b35b9",
203+
"metadata": {},
204+
"outputs": [],
205+
"source": [
206+
"%%writefile ~/qe_code.yaml\n",
207+
"label: qe\n",
208+
"description: Quantum ESPRESSO pw.x\n",
209+
"default_calc_job_plugin: quantumespresso.pw\n",
210+
"computer: scarf\n",
211+
"filepath_executable: /work4/scd/scarf562/eb-amd/software/QuantumESPRESSO/7.2-foss-2023a/bin/pw.x\n",
212+
"use_double_quotes: true\n",
213+
"prepend_text: ''\n",
214+
"append_text: ''"
215+
]
216+
},
217+
{
218+
"cell_type": "code",
219+
"execution_count": null,
220+
"id": "c354f007",
221+
"metadata": {},
222+
"outputs": [],
223+
"source": [
224+
"! verdi code create core.code.installed -n --config ~/qe_code.yaml"
225+
]
226+
}
227+
],
228+
"metadata": {
229+
"kernelspec": {
230+
"display_name": "aiida-mlip (3.12.3)",
231+
"language": "python",
232+
"name": "python3"
233+
},
234+
"language_info": {
235+
"codemirror_mode": {
236+
"name": "ipython",
237+
"version": 3
238+
},
239+
"file_extension": ".py",
240+
"mimetype": "text/x-python",
241+
"name": "python",
242+
"nbconvert_exporter": "python",
243+
"pygments_lexer": "ipython3",
244+
"version": "3.12.3"
245+
}
246+
},
247+
"nbformat": 4,
248+
"nbformat_minor": 5
249+
}
File renamed without changes.

examples/tutorials/high-throughput-screening.ipynb renamed to examples/tutorials/calculations/high-throughput-screening.ipynb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@
8080
"outputs": [],
8181
"source": [
8282
"Calculation = CalculationFactory(\"mlip.sp\")\n",
83-
"model = ModelData.from_local(\"mlips/mace_mp/mace_mp_small.model\", architecture=\"mace_mp\")\n",
83+
"uri = \"https://github.com/stfc/janus-core/raw/main/tests/models/mace_mp_small.model\"\n",
84+
"model = ModelData.from_uri(uri, architecture=\"mace_mp\")\n",
85+
"# model = ModelData.from_local(\"path/to/model\", architecture=\"mace_mp\")\n",
8486
"metadata = {\"options\": {\"resources\": {\"num_machines\": 1}}}\n",
8587
"code = load_code(\"janus@localhost\")"
8688
]
@@ -98,7 +100,7 @@
98100
"metadata": {},
99101
"outputs": [],
100102
"source": [
101-
"conf = JanusConfigfile(\"/home/jovyan/config_sp.yaml\")"
103+
"conf = JanusConfigfile(Path(\"config_sp.yaml\").absolute())"
102104
]
103105
},
104106
{
@@ -274,7 +276,7 @@
274276
"provenance": []
275277
},
276278
"kernelspec": {
277-
"display_name": "Python 3 (ipykernel)",
279+
"display_name": "aiida-mlip (3.12.3)",
278280
"language": "python",
279281
"name": "python3"
280282
},
@@ -288,7 +290,7 @@
288290
"name": "python",
289291
"nbconvert_exporter": "python",
290292
"pygments_lexer": "ipython3",
291-
"version": "3.9.13"
293+
"version": "3.12.3"
292294
}
293295
},
294296
"nbformat": 4,

0 commit comments

Comments
 (0)