I am using Snakemake to execute a workflow across multiple cluster environments. I therefore use Snakemake profiles per cluster to define CPUs, memory, etc. However, there are a few inputs that need to be run in single threaded mode.
Therefore, I'd like to have something like the following:
rule:
resource:
cpus_per_task = 1 if CONDITION else profile.default-resources.cpus_per_task
However I can't seem to access the profile default resources within Snakemake. Currently I simply create two sets of rules, one for the single-threaded, and one for the non-single threaded, but this results in quite a bit of duplicated code.
Does anyone have any advice for solving an issue like this? Happy to provide more code and context if is helps.
Solved by accessing the workflow parameters in the following manner in the Snakefile:
workflow.resource_settings.default_resources.parsed['cpus_per_task']