Skip to content

Commit

Permalink
Update snakemake docs for snakemake 8 and slurm executor plugin (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
tedil authored Oct 23, 2024
1 parent 4d8804e commit b33714d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bih-cluster/docs/slurm/snakemake.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ This page describes how to use Snakemake with Slurm.

We first create a new environment `snakemake-slurm` and activate it.
We need the `snakemake` package for this.
For snakemake 8, we additionally need [`snakemake-executor-plugin-slurm`](https://snakemake.github.io/snakemake-plugin-catalog/plugins/executor/slurm.html).

```bash
host:~$ conda create -y -n snakemake-slurm snakemake
host:~$ conda create -y -n snakemake-slurm 'snakemake>=8.24.1' snakemake-executor-plugin-slurm
[...]
#
# To activate this environment, use
Expand All @@ -40,7 +41,7 @@ rule default:
rule mkresult:
output: "the-result.txt"
shell: r"sleep 1m; touch the-result.txt"
shell: r"sleep 2m; touch the-result.txt"
EOF
host:snake-slurm$ snakemake --cores=1
[...]
Expand All @@ -51,12 +52,12 @@ host:snake-slurm$ rm the-result.txt

## Snakemake and :tada: Slurm

You have two options:
Simply use `snakemake --profile=cubi-v1` and the Snakemake resource configuration as shown below.
This works for both snakemake version 7 *and* 8.

1. Simply use `snakemake --profile=cubi-v1` and the Snakemake resource configuration as shown below. **STRONGLY PREFERRED**
2. Use the `snakemake --cluster='sbatch ...'` command.
(For version 7, you can also use `snakemake --cluster='sbatch ...'` command instead, but this is discouraged.)

Note that we sneaked in a `sleep 1m`? In a second terminal session, we can see that the job has been submitted to SLURM indeed.
Note that we sneaked in a `sleep 2m`? In a second terminal session, we can see that the job has been submitted to SLURM indeed.

```bash
host:~$ squeue -u holtgrem_c
Expand All @@ -78,10 +79,12 @@ The `cubi-v1` profile (stored in `/etc/xdg/snakemake/cubi-v1` on all cluster nod

You will need Snakemake >=7.0.2 for this.

For more information on resources, see [snakemake resources](https://snakemake.readthedocs.io/en/latest/snakefiles/rules.html#standard-resources) and [slurm resources](https://snakemake.github.io/snakemake-plugin-catalog/plugins/executor/slurm.html#advanced-resource-specifications).

Here is how to call Snakemake:

```bash
# snakemake --profile=cubi-v1 -j1
# snakemake --profile=cubi-v1 --cores 1
```

To set rule-specific resources:
Expand Down

0 comments on commit b33714d

Please sign in to comment.