Skip to content

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.

Add the cluster to ~/.ssh/config in Neurodesktop. For Bunya:

Host bunya
HostName bunya.rcc.uq.edu.au
User YOUR_UQ_USERNAME

Check that ssh bunya works in a terminal; see the UQ RCC documentation for SSH keys. Then connect:

Terminal window
neurodesk jobs connect bunya

Approve 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.

This example calculates the mean of three numbers and checks the answer. Create a DataLad dataset with the inputs and scripts:

Terminal window
PROJECT=~/remote-jobs-demo
mkdir -p "$PROJECT" && cd "$PROJECT"
datalad create dataset
printf '2\n4\n6\n' > dataset/numbers.txt
cat > dataset/analyze.py <<'PY'
import json, math, sys
from pathlib import Path
values = [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, sys
from pathlib import Path
result = 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:

Terminal window
apptainer pull python.sif docker://python:3.12-slim

Describe 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"}
}
  • inputs are exact file paths in the dataset; they appear read-only under /inputs. Directories and wildcards are not supported.
  • command and validate are argument lists, not shell snippets. Put a pipeline in a script.
  • The analysis writes to /outputs. Each listed output must be nonempty, and validate must exit with status 0. Check the science, not just that the file exists.
  • slurm is optional. The defaults are 1 hour, 4 GB, and 1 CPU. You can also set cpus-per-task, account, partition, qos, and gres.

Freeze the inputs, scripts, and image into a run:

Terminal window
neurodesk jobs prepare --dataset dataset --image python.sif --request request.json

This prints a run_id; use it in the following commands.

Terminal window
RUN_ID=PASTE_THE_RUN_ID
neurodesk 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.

Terminal window
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:

Terminal window
neurodesk jobs restore ARCHIVE.tar.gz restored

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.