slurm-job-util
is a utility package for managing SLURM jobs on remote hosts. It provides functionalities to rsync files, submit jobs, watch job outputs, cancel jobs, and view the job queue.
- Rsync files to and from remote hosts
- Submit SLURM jobs, using a local or remote sbatch script
- Watch SLURM job outputs
- Cancel SLURM jobs
- Show my SLURM queue
- Python 3.10 or later
rsync
on local machine- remote host is a SLURM cluster
- valid entry in your
~/.ssh/config
file for the login node of the remote host
To install the package, run:
pip install .
This will install the package and make the slurm-job-util
and sju
command available.
Both commands are equivalent.
The sju
command provides several subcommands for different functionalities:
sju init <remote_host>
Initialize the config file with the remote host's SSH config entry.
When this has been run, the <remote_host>
argument can be omitted from subsequent commands.
sju show
Displays the current configuration.
sju reset
Resets the config file to empty.
sju rsync <remote_host> <local_path> <remote_path>
# or, after init
sju rsync <local_path> <remote_path>
sju submit <remote_host> <remote_or_local_script> [--kwargs key=value ...]
# or, after init
sju submit <remote_or_local_script> [--kwargs key=value ...]
Where key=value
is a key-value pair of arguments to pass to the sbatch
command.
If <remote_or_local_script>
is a local file, you will be prompted to ask if you want to rsync it to the remote host prior to submitting the job.
For example, to submit a local sbatch script as a job with 4 CPUs per task and 1GB memory per CPU, you can use:
sju submit my-remote-host /path/to/local/script.sbatch --kwargs cpus-per-task=4 mem-per-cpu=1G
# or, after init
sju submit /path/to/local/script.sbatch --kwargs cpus-per-task=4 mem-per-cpu=1G
sju output <remote_host> <job_id>
# or, after init
sju output <job_id>
sju cancel <remote_host> <job_id>
# or, after init
sju cancel <job_id>
sju queue <remote_host>
# or, after init
sju queue
# Initialize the config file
sju init my.remote.host
# Rsync a file to a remote host
sju rsync /path/to/local/file /path/to/remote/file
# Submit a SLURM job
sju submit /path/to/remote/script.sh --kwargs arg1=value1 arg2=value2
# Watch a SLURM job
sju output 12345
# Cancel a SLURM job
sju cancel 12345
# Show my SLURM queue
sju queue
This project is licensed under the MIT License.