Reputation: 75
Is there a way to get the rules submitted to the cluster to inherit the parent command singularity container? I'm running the base snakemake within a container for portability with most rules using other conda envs. So I can create the base conda env with snakemake and all the rule conda envs within the container. This works fine for running everything locally, all the rule conda envs were created within the container, so can be found. But when using cluster submission, the shell script is executed independent from the parent container, so fails. Is there a way to pass the parent singularity container to the submitted jobs?
Do I need a custom cluster submission script?
The alternatives are using individual singularity containers for each rule or containerize for the whole workflow, but this doesn't include the parent snakemake env itself.
Upvotes: 1
Views: 80
Reputation: 509
In your case, the best/easiest solution is to call snakemake on the host and set up global container in your snakemake file:
container: "docker://<user>/<repo_name>:<versionID>"
With this setting, all the rules will be executed in the assigned container. If you use the latest version of snakemake (v8), you also need to install snakemake-executor-plugin-cluster-generic
for the python environment for snakemake on your host.
In your command line for running snakemake, you can add --profile <cluster.yaml>
Here is an example of the yaml file:
jobs: 100
restart-times: 0
cluster-generic-submit-cmd: "sbatch --nodes=1 --ntasks={threads} --mem={resources.mem_mb} --time={resources.runtime} --partition={resources.slurm_partition}"
max-jobs-per-second: 1
max-status-checks-per-second: 10
local-cores: 1
latency-wait: 60
show-failed-logs: True
keep-going: True
printshellcmds: True
use-singularity: True
## You can mount multiple paths below.
singularity-args: ' "--cleanenv --no-home -B <path1 to mount> -B <path2 to mount> " '
rerun-trigger: mtime # the traditional way of just considering file modification dates
# Equavalent of cluster.json in previous version of snakemake
default-resources:
runtime: 7200
mem_mb: 100000
disk_mb: 1000000
slurm_partition: "norm"
# set-threads: map rule names to threads
set-threads:
count: 8
arc_count: 16
# set-resources: map rule names to resources in general
set-resources:
count:
mem_mb:
600000
arc_count:
mem_gb:
128
Upvotes: 0