slurm-remote
slurm-remote is for testing local code on a cluster: it syncs the project with
rsync, submits a batch script with sbatch, follows the job and fetches
results back. Everything runs through SLURM, never on the login node.
slurm-remote --host mycluster run job.sh --fetch outslurm-remote --host mycluster run job.sh -- pytest -x tests/Configuration
Section titled “Configuration”The host and remote directory come from, in order of precedence, the flags
--host and --remote-dir, the environment variables SLURM_REMOTE_HOST and
SLURM_REMOTE_DIR, and a slurm-remote.json in the project directory:
{ "host": "mycluster", "remote_dir": "~/scratch", "excludes": [".git", ".venv", "__pycache__"], "setup": ["module load python-waterboa", "source ~/venvs/dev/bin/activate"], "poll_interval": 30}The project lands in <remote_dir>/<local directory name>, so separate
worktrees do not overwrite each other. setup lines are put before a command
given to run.
Commands
Section titled “Commands”| Command | What it does |
|---|---|
sync [--delete] | Rsync the project to the cluster (.git, .venv, caches and build output are excluded by default). |
submit SCRIPT | Sync, sbatch the script and print the job id. |
status JOB_ID | Print the job state, from squeue or else sacct. |
logs JOB_ID [-f] [-n N] | Show, or follow, the job’s stdout file. |
fetch PATH... | Copy files from the remote project directory back, keeping their layout. |
run SCRIPT [--fetch PATH...] [-- COMMAND] | Sync, submit, wait, show the log tail and fetch. Exits non-zero unless the job completed. |
With -- COMMAND, run keeps the #SBATCH pragmas of the script but runs your
command (after the setup lines) instead of the script body.
Good cluster citizenship
Section titled “Good cluster citizenship”- SSH connections are multiplexed (
ControlMaster, 4 h), so you authenticate once, also with 2FA. Turn it off with--no-multiplexif your site forbids it. - Status polling is limited to at most one check per 15 s, whatever
poll_intervalsays. - Compute only happens in submitted jobs. Do not use
syncto push large environments; build them on the cluster.