Submit jobs to a remote HPC
Use neurodesk jobs in a Neurodesktop terminal to run a containerized analysis
on a Slurm cluster, such as UQ’s Bunya. The tool sends your inputs and Apptainer
image over SSH, submits the job, and brings back checksummed results as a
DataLad dataset. The cluster only needs SSH, Python 3, Slurm, and Apptainer.
You do not need DataLad or any other software installed there.
1. Connect to the cluster
Section titled “1. Connect to the cluster”Add the cluster to ~/.ssh/config in Neurodesktop. For Bunya:
Host bunya HostName bunya.rcc.uq.edu.au User YOUR_UQ_USERNAMECheck that ssh bunya works in a terminal; see the
UQ RCC documentation for SSH keys. Then
connect:
neurodesk jobs connect bunyaApprove the MFA prompt if the cluster asks; on Bunya, approve the Okta push
with the number shown. connect finds Python, your home directory, and your
scratch directory on the cluster by itself, and saves them. The login lasts
4 hours. If a later command says the connection has expired, run
neurodesk jobs connect again.
2. Prepare an analysis
Section titled “2. Prepare an analysis”This example calculates the mean of three numbers and checks the answer. Create a DataLad dataset with the inputs and scripts:
PROJECT=~/remote-jobs-demomkdir -p "$PROJECT" && cd "$PROJECT"datalad create datasetprintf '2\n4\n6\n' > dataset/numbers.txt
cat > dataset/analyze.py <<'PY'import json, math, sysfrom pathlib import Pathvalues = [float(line) for line in Path(sys.argv[1]).read_text().splitlines()]Path(sys.argv[2]).write_text(json.dumps({"count": len(values), "mean": math.fsum(values) / len(values)}))PY
cat > dataset/validate.py <<'PY'import json, math, sysfrom pathlib import Pathresult = json.loads(Path(sys.argv[1]).read_text())if result["count"] != 3 or not math.isclose(result["mean"], 4.0): raise SystemExit("Unexpected result")PY
datalad save -d dataset -m "Remote job example"Get an Apptainer image that contains your software. This example only needs Python:
apptainer pull python.sif docker://python:3.12-slimDescribe the job in request.json, outside the dataset:
{ "inputs": ["numbers.txt", "analyze.py", "validate.py"], "command": ["python3", "/inputs/analyze.py", "/inputs/numbers.txt", "/outputs/summary.json"], "validate": ["python3", "/inputs/validate.py", "/outputs/summary.json"], "outputs": ["summary.json"], "slurm": {"time": "00:10:00", "mem": "1G"}}inputsare exact file paths in the dataset; they appear read-only under/inputs. Directories and wildcards are not supported.commandandvalidateare argument lists, not shell snippets. Put a pipeline in a script.- The analysis writes to
/outputs. Each listed output must be nonempty, andvalidatemust exit with status 0. Check the science, not just that the file exists. slurmis optional. The defaults are 1 hour, 4 GB, and 1 CPU. You can also setcpus-per-task,account,partition,qos, andgres.
Freeze the inputs, scripts, and image into a run:
neurodesk jobs prepare --dataset dataset --image python.sif --request request.jsonThis prints a run_id; use it in the following commands.
3. Submit and monitor
Section titled “3. Submit and monitor”RUN_ID=PASTE_THE_RUN_IDneurodesk jobs submit "$RUN_ID"neurodesk jobs status "$RUN_ID"neurodesk jobs logs "$RUN_ID"submit uploads the run, then submits it to Slurm. An image you used before
is not uploaded again. The job runs even if you close Neurodesktop. In the
status output, scheduler.state shows the Slurm state. Each attempt reaches
site-results-available when its outputs have passed validation. To stop a
job, run neurodesk jobs cancel "$RUN_ID", then check status.
If status shows submission-unknown, Slurm may or may not have accepted the
job. Run submit again: it never submits a second copy. Do not delete the run
or prepare a new one; that could run the job twice.
4. Collect and archive the results
Section titled “4. Collect and archive the results”neurodesk jobs collect "$RUN_ID"neurodesk jobs archive "$RUN_ID"collect downloads the results, checks every file against the checksums
recorded on the cluster, and saves them as a DataLad dataset. The command
prints the dataset’s path, under
~/.local/state/neurodesk-jobs/runs/RUN_ID/output. Alongside summary.json
it holds execution.json, which records the inputs, image, command, and
compute node.
archive writes one self-contained file with the inputs, image, scripts,
results, and job records, and checks that it restores. Use --to DIRECTORY
to choose where it goes. You can restore an archive without the cluster:
neurodesk jobs restore ARCHIVE.tar.gz restoredMore information
Section titled “More information”The implementation reference covers recovery states, the site acceptance checklist, and the design. The Bunya and Sherlock guides describe running Neurodesktop itself on those clusters, which is a separate feature.