Skip to content
Cookiecutter for snakemake slurm profile
Python Shell
Branch: master
Clone or download
This branch is 2 commits ahead of percyfal:master.

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Update circleci snakemake image to 5.13 Mar 30, 2020
tests Remove min function call from timeout rule Mar 30, 2020
.gitignore Normalise code with Black (snakemake default). Feb 29, 2020
LICENSE Initial commit Dec 7, 2017 Update changelog Mar 31, 2020
cookiecutter.json Fix boolean conversion of advanced_argument_conversion cookiecutter o… Mar 6, 2020
test-environment.yml Update snakemake test version Mar 30, 2020



This profile configures Snakemake to run on the SLURM Workload Manager


Deploy profile

To deploy this profile, run

mkdir -p ~/.config/snakemake
cd ~/.config/snakemake

Then, you can run Snakemake with

snakemake --profile slurm ...

Cookiecutter options

  • profile_name : A name to address the profile via the --profile Snakemake option.
  • sbatch_defaults : List of default arguments to sbatch, e.g.: qos=short time=60. This is a convenience argument to avoid cluster_config for a few aruments.
  • cluster_config : Path to a YAML or JSON configuration file analogues to the Snakemake --cluster-config option. Path may relative to the profile directory or absolute including environment variables (e.g. $PROJECT_ROOT/config/slurm_defaults.yaml).
  • advanced_argument_conversion : If True, try to adjust/constrain mem, time, nodes and ntasks (i.e. cpus) to parsed or default partition after converting resources. This may fail due to heterogeneous slurm setups, i.e. code adjustments will likely be necessary.

Default snakemake arguments

Default arguments to snakemake maybe adjusted in the <profile path>/config.yaml file.

Parsing arguments to SLURM (sbatch)

Arguments are overridden in the following order and must be named according to sbatch long option names:

  1. sbatch_defaults cookiecutter option
  2. Profile cluster_config file __default__ entries
  3. Snakefile threads and resources (time, mem)
  4. Profile cluster_config file entries
  5. --cluster-config parsed to Snakemake (deprecated since Snakemake 5.10)
  6. Any other argument conversion (experimental, currently time, ntasks and mem) if advanced_argument_conversion is True.


Resources specified in Snakefiles must all be in the correct unit/format as expected by sbatch. The implemented resource names are given (and may be adjusted) in the slurm_utils.RESOURCE_MAPPING global. This is intended for system agnostic resources such as time and memory.

Cluster configuration file

The profile supports setting default and per-rule options in either the cluster_config file and the --cluster-config file parsed to snakemake (the latter is deprecated since snakemake 5.10). The __default__ entry will apply to all jobs. Both may be YAML (see example below) or JSON files.

  account: staff
  constraint: mem2000MB
  ntasks: 16


Test-driven development is enabled through the tests folder. Provided that the user has installed docker and enabled docker swarm (docker swarm init), the SLURM tests will download two images:

  2. giovtorres/docker-centos7-slurm

and testing of the cookiecutter template itself is enabled through the pytest plugin for Cookiecutters. You can run the tests by issuing

pytest -v -s



  • map threads to --cpus-per-task (#35)
  • rewrite some tests to address changes


  • major rewrite and merge of the script to support any sbatch argument
  • parse any argument via the sbatch_defaults option and
  • enable per-profile cluster (YAML/JSON) config file
  • make experimental sbatch argument adjustments optional via the advanced_argument_conversion option


  • add qos option


  • replace pytest_namespace with pytest_configure
  • make days optional (#18)


  • add cookiecutter options to set sbatch output and error defaults


  • add support for mem_mb in resources
  • add support for cluster configuration file
  • add advanced slurm-submit file
  • adjust resource requirements if they exceed partition configuration settings (#11)
You can’t perform that action at this time.