Skip to main content

Slurm scripts for Apptainer jobs

PyPI Version PyPI Status PyPI Versions

CI Documentation Status

Contents

Overview

slappt generates and submits Slurm job scripts for Apptainer workflows. Jobs can be configured in YAML or via CLI.

Requirements

slappt requires Python3.8+ and a few core dependencies, including click, pyaml, paramiko, and requests, among others.

To submit a job script, the host machine must either run slurmctld with standard commands available, or must be able to connect via key- or password-authenticated SSH to the target cluster.

Installation

slappt is available on the Python Package Index and can be installed with pip:

pip install slappt

Quickstart

Say you have access to a Slurm cluster with apptainer installed, and you have permission to submit to the batch partition.

Copy the hello.yaml file from the examples directory to your current working directory, then run:

slappt hello.yaml > job.sh

Alternatively, without the configuration file:

slappt --image docker://alpine \
       --shell sh \
       --partition batch \
       --entrypoint "echo 'hello world'" > hello.sh

Your hello.sh script should now contain:

#!/bin/bash
#SBATCH --job-name=0477f4b9-e119-4354-8384-f50d7a96adad
#SBATCH --output=slappt.0477f4b9-e119-4354-8384-f50d7a96adad.%j.out
#SBATCH --error=slappt.0477f4b9-e119-4354-8384-f50d7a96adad.%j.err
#SBATCH --partition=batch
#SBATCH -c 1
#SBATCH -N 1
#SBATCH --ntasks=1
#SBATCH --time=01:00:00
#SBATCH --mem=1GB
apptainer exec docker://alpine sh -c "echo 'hello world'"

If already on the cluster, use the --submit flag to submit the job directly. (Standard Slurm commands must be available for this to work.) In this case the job ID is shown if submission was successful.

You can provide authentication information to submit the script to remote clusters over SSH. For instance, assuming you have key authentication set up and your key is ~/.ssh/id_rsa:

slappt ... --host <cluster IP or FQDN> --username <username>

Caveats

There are a few things to note about the example above.

Shell selection

For most image definitions, specifying the shell is likely not necessary, as the default is bash. However, for images that don't have bash installed (e.g., alphine only has sh) a different shell must be selected.

Singularity support

If your cluster still uses singularity, pass the --singularity flag (or set the singularity key in the configuration file to true) to substitute singularity for apptainer in the command wrapping your workflow entrypoint.

Pre-commands

Note: if apptainer or singularity are not available by default on your cluster's compute nodes, you may need to add --pre commands (or a pre section to the configuration file), for instance --pre "module load apptainer", or:

...
pre:
  - module load apptainer
...

Documentation

Documentation is available at slappt.readthedocs.io.

Disclaimer

This project is not affiliated with Slurm, Apptainer or Singularity and cannot guarantee compatibility with all cluster configurations.

Metadata

Release files for slappt 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slappt 0.0.3
File Size Uploaded
slappt-0.0.3.tar.gz 18.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for slappt 0.0.3
File Interpreter ABI Platform
slappt-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 38.6 kB

Release files / slappt-0.0.3.tar.gz

Download URL slappt-0.0.3.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ac4cca927c4c2344cb6d88b735c68edfc2aee1cc94df0cf929f737e06a12d872
BLAKE2b-256 checksum
How to use checksums
756765ce8bde81b3ebb008df229647786553445a5903e9b831ac8a1788ca0b28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.15

Release files / slappt-0.0.3-py3-none-any.whl

Download URL slappt-0.0.3-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be4fbf0140879fbebe609e9da4a5c553d4e2779a9a1a5b9d43cccb76841ae14d
BLAKE2b-256 checksum
How to use checksums
615beb8cdf32cb01b160a6b8d4a78f66052b65fc125d8ef3df28e150b5324f4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.15

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page