Search code examples
snakemake

Default memory request with possibility of override in a Snakefile?


I have a Snakefile with several rules and only a few need more than 1 GB/core to run on a cluster. The resources directive is great for this, but I can't find a way of setting a default value. I would prefer not having to write resources: mem_per_cpu = 1024 for every rule that doesn't need more than the default.

I realize that I could get what I want using __default__ in a cluster config file and overriding the mem_per_cpu value for specific rules. I hesitate to do this because the memory requirements are platform-independent, so I would prefer including them in the Snakefile itself. It would also prevent me from being able to specify local resource limits using the --resources command-line option.

Is there a simple solution with Snakemake that would help me here? Thanks!


Solution

  • I was reading the changelog of the Snakemake and I came across this:

    Add –default-resources flag, that allows to define default resources for jobs (e.g. mem_mb, disk_mb), see docs.