diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index 119bc76b..08ebe1ac 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -6,6 +6,7 @@ import csv from io import StringIO import os +import re import subprocess import time from datetime import datetime, timedelta @@ -143,6 +144,7 @@ def run_job(self, job: JobExecutorInterface): call += f" --cpus-per-task={get_cpus_per_task(job)}" if job.resources.get("slurm_extra"): + self.check_slurm_extra(job) call += f" {job.resources.slurm_extra}" exec_job = self.format_job_exec(job) @@ -488,3 +490,15 @@ def get_default_partition(self, job): "'slurm_partition='." ) return "" + + def check_slurm_extra(self, job): + jobname = re.compile(r"--job-name[=?|\s+]|-J\s?") + if re.search(jobname, job.resources.slurm_extra): + raise WorkflowError( + "The '--job-name' option is not allowed in the 'slurm_extra' " + "parameter. The job name is set by snakemake and must not be " + "overwritten. It is internally used to check the stati of all " + "submitted jobs by this workflow." + "Please consult the documentation if you are unsure how to " + "query the status of your jobs." + )