You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/safe-haven-services/open-ondemand/apps/job-composer.md
+174Lines changed: 174 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -207,3 +207,177 @@ If you selected a back-end where your home directory is not common to both the O
207
207
```
208
208
Hello World to someuser from some-vm.nsh.loc
209
209
```
210
+
211
+
---
212
+
213
+
## Run a container example
214
+
215
+
This example demonstrates how to create and submit a Slurm job that runs a bash script that runs the 'hello TRE' container which is used within the [Getting started](../getting-started.md) and the [Run Batch Container](./batch-container-app.md) app. The container is run using the TRE Container Execution Tools' commands `ces-pull`, to pull the container, and `ces-run` to run the container.
* For `CR_TOKEN`, copy in the 'hello TRE' container's 'Container registry access token' from the [Run Batch Container](./batch-container-app.md) app's form.
258
+
* By default, `ces-run` creates directories with random names - `scratch-NNNN` and `outputs-NNNN` - and mounts these into a container at `/scratch` and `/safe_outputs`. However, `ces-run` supports `CES_SCRATCH` and `CES_SAFE_OUTPUTS` environment variables, which allow for existing directories to be used. In the script above, we create subdirectories of `$HOME` and define `CES_SCRATCH` and `CES_SAFE_OUTPUTS` to tell `ces-run` to mount these directories.
259
+
* The script creates a file, `env_file.txt`, with an environment variable to be passed to the 'hello TRE' container. The container uses the environment variable `HELLO_TRE` to customise the greeting it prints.
260
+
* The script also creates a file, `arg_file.txt`, with container-specific arguments to be passed directly to the container when it is run. The 'hello TRE' container will pause for `-d` seconds, then issue a greeting to the name cited in `-n` (here, the current user).
261
+
262
+
1. Click **Save**.
263
+
264
+
Submit job:
265
+
266
+
1. Switch to the Job Composer browser tab.
267
+
1. Click **Submit job** (green play icon).
268
+
269
+
{: class="border-img center"} ***Submit Job** button*
270
+
271
+
1. The job 'Status' should go from 'Queued' to 'Completed'.
272
+
273
+
If you selected a back-end where your home directory is common to both the Open OnDemand VM and the back-end, then:
274
+
275
+
1. Click `output.txt` under **Folder Contents**.
276
+
1. A new browser tab will appear with the contents of the file:
277
+
278
+
```text
279
+
...
280
+
Hello TRE!
281
+
...
282
+
Greetings USER!
283
+
284
+
Sleeping for 10 seconds...
285
+
1
286
+
2
287
+
3
288
+
4
289
+
5
290
+
6
291
+
7
292
+
8
293
+
9
294
+
10
295
+
...and awake!
296
+
297
+
For more container examples and ideas, visit:
298
+
https://github.com/EPCCed/tre-container-samples
299
+
Goodbye USER!
300
+
```
301
+
302
+
1. Close the tab.
303
+
304
+
If you selected a back-end where your home directory is not common to both the Open OnDemand VM and the back-end, then:
305
+
306
+
1. Click **Open Terminal** to log into the back-end on which the job was run. Once logged in, your current directory will be changed to match the job context directory.
307
+
1. View the job context directory's contents:
308
+
309
+
```bash
310
+
ls -1
311
+
```
312
+
313
+
```text
314
+
arg_file.txt
315
+
env_file.txt
316
+
main_job.sh
317
+
output.txt
318
+
```
319
+
320
+
1. View `output.txt`:
321
+
322
+
```bash
323
+
cat output.txt
324
+
```
325
+
326
+
```text
327
+
...
328
+
Hello TRE!
329
+
...
330
+
Greetings USER!
331
+
332
+
Sleeping for 10 seconds...
333
+
1
334
+
2
335
+
3
336
+
4
337
+
5
338
+
6
339
+
7
340
+
8
341
+
9
342
+
10
343
+
...and awake!
344
+
345
+
For more container examples and ideas, visit:
346
+
https://github.com/EPCCed/tre-container-samples
347
+
Goodbye USER!
348
+
```
349
+
350
+
Create a new job from the current job to run the container using Apptainer:
1. Replace use of `podman` with `apptainer` as follows:
356
+
357
+
1. Replace the `ces-pull podman` line with:
358
+
359
+
```bash
360
+
cd$HOME
361
+
ces-pull apptainer $CR_USER$CR_TOKEN$CR_URL
362
+
SIF_FILE=$HOME/epcc-ces-hello-tre:1.1.sif
363
+
cd$SLURM_SUBMIT_DIR
364
+
```
365
+
366
+
*`ces-pull apptainer` creates a SIF file in the current directory whose name is derived from the last part of the container URL. We change into `$HOME` so that the SIF file is created in`$HOME` before moving back to the directory with the job files, `$SLURM_SUBMIT_DIR`. This means we'll only ever have one copy of this SIF file in our `$HOME` directory, rather than one copy for each run of the job, which would quickly consume space!
{: class="border-img center"} ***Submit Job** button*
380
+
381
+
1. The job 'Status' should go from 'Queued' to 'Completed'.
0 commit comments