Skip to content

Commit b1a363b

Browse files
committed
feat: will reject jobs, which attempt setting job names by 'slurm_extra'
1 parent 2e5d308 commit b1a363b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

snakemake_executor_plugin_slurm/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import csv
77
from io import StringIO
88
import os
9+
import re
910
import subprocess
1011
import time
1112
from datetime import datetime, timedelta
@@ -134,6 +135,7 @@ def run_job(self, job: JobExecutorInterface):
134135
call += f" --cpus-per-task={get_cpus_per_task(job)}"
135136

136137
if job.resources.get("slurm_extra"):
138+
self.check_slurm_extra()
137139
call += f" {job.resources.slurm_extra}"
138140

139141
exec_job = self.format_job_exec(job)
@@ -479,3 +481,15 @@ def get_default_partition(self, job):
479481
"'slurm_partition=<your default partition>'."
480482
)
481483
return ""
484+
485+
def check_slurm_extra(self):
486+
jobname = re.compile(r"--job-name[=?|\s+]|-J\s?")
487+
if re.search(jobname, job.resources.slurm_extra):
488+
raise WorkflowError(
489+
"The --job-name option is not allowed in the 'slurm_extra' "
490+
"parameter. The job name is set by snakemake and must not be "
491+
"overwritten. It is internally used to check the stati of the "
492+
"all submitted jobs by this workflow."
493+
"Please consult the documentation if you are unsure how to "
494+
"query the status of your jobs."
495+
)

0 commit comments

Comments
 (0)