-
Notifications
You must be signed in to change notification settings - Fork 0
Running Snakemake with SLURM (using profile)
This guide explains how to set up and run Snakemake (tested version 8.14.0) on an SLURM-based cluster using the snakemake-executor-plugin-slurm.
This guide is based on my GitHub comment on the Snakemake repository.
Install Snakemake and the SLURM executor plugin via Conda:
conda install -y -c bioconda -c conda-forge snakemake=8.14.0 snakemake-executor-plugin-slurmBefore running, your directory should look like this:
test_run/
├── one.txt
├── profiles/
│ └── work_profile/
│ └── config.v8+.yaml
└── Snakefilewhere the contents of files are:
profiles/work_profile/config.v8+.yaml
executor: slurm
default-resources:
slurm_account: "account_name"
slurm_partition: "queue_name"
runtime: 2h
mem_mb: 4096
slurm_extra: "'--mail-type=END --mail-user=first.last@mail.com -o logs/smk.%N.%j.out -e logs/smk.%N.%j.err'"
printshellcmds: True
jobs: 100
restart-times: 3
latency-wait: 60
rerun-incomplete: True
use-conda: false
set-threads:
rule1: 1
rule2: 2
test: 4
set-resources:
test:
slurm_partition: "queue_name"
runtime: 4h
mem_mb: 4096See Snakemake profiles documentation for more info.
Snakefile
rule all:
input:
"done.txt"
rule test:
input:
"one.txt"
output:
"done.txt"
log:
"test.log"
shell:
"""
echo "Processing data with {threads} threads" > {log}
cp {input} {output}
/usr/bin/time -v sleep 10
echo "Processing complete" >> {log}
"""one.txt
Just a placeholder file:
empty fileNow we can execute snakemake on SLURM using the profiles/work_profile.
From within the test_run/ directory:
$ cd test_run
$ snakemake --profile profiles/work_profile --snakefile Snakefile
Building DAG of jobs...
SLURM run ID: 952ada6a-70b3-44b8-b6d9-30c2ee2fc421
Using shell: /usr/bin/bash
Provided remote nodes: 100
Job stats:
job count
----- -------
all 1
test 1
total 2
Select jobs to execute...
Execute 1 jobs...
...
...
Finished job 0.
2 of 2 steps (100%) done
Complete log: .snakemake/log/2024-06-28T103831.904550.snakemake.logAfter execution, your directory will look like:
test_run/
├── one.txt
├── profiles/
│ └── work_profile/
│ └── config.v8+.yaml
├── Snakefile
├── logs/
│ ├── smk.e512n47.1118341.err
│ └── smk.e512n47.1118341.out
├── test.log
└── done.txtsnakemake==8.14.0
snakemake-executor-plugin-slurm==0.7.0
snakemake-executor-plugin-slurm-jobstep==0.2.1
snakemake-interface-common==1.17.2
snakemake-interface-executor-plugins==9.1.1
snakemake-interface-report-plugins==1.0.0
snakemake-interface-storage-plugins==3.2.2In Snakemake (v8.14.0), SLURM jobs are named using UUIDs. To view the rule name/wildcards in your SLURM queue, Snakemake now adds that information to the --comments section.
References:
Use the following squeue command to display comments:
We need to add %k to the squeue command to see the --comments section
squeue -u $(whoami) -o "%.14i %.8u %.20k %.20j"That’s it!
You now have a working Snakemake setup with SLURM executor integration.
- Induction
- HPC Best practice
- Job Arrays - RC documentation
- Methods to Improve I/O Performance - RC documentation
- Customising your bash profile for ease and efficiency
- Customise bash profile: Logging Your Command History Automatically
- Using the ei-gpu partition on the Earlham Institute computing cluster
- Using the GPUs at EI
- HPC Job Summary Tool
- EI Cloud (CyVerse)
- Git and GitHub
- Worked examples
- Job Arrays
- Using Parabricks on the GPUs
- dependencies
- Software installations
- Workflow management system
- Transfers
- Local (mounting HPC storage)
- Remote - <1gb (ood)
- Remote - <50gb (nbi drop off)
- Remote - No limit (globus)
- mv command
- The nbi-download partition (retrieving external datasets)