Skip to content

Commit df2fd3d

Browse files
cmeestersfgvieira
andauthored
feat: will reject jobs, which attempt setting job names by 'slurm_extra' (#93)
Occasionally, users reported that their attempt to overwrite SLURM job names leads to faulty behaviour (job status does not get queried properly, and a workflow will stall). This is understandable from the code and documented accordingly. The PR checks for the job status using a regex - simple string matching might be too error-prone (e.g. "-J" can be part of a wildcard). The decision is here, that the workflow will abort (raising WorkflowError and explaining and pointing to the docs). Please check whether this is "likeable". I do not know how to implement a test. The other executors leave me clueless. --------- Co-authored-by: Filipe G. Vieira <1151762+fgvieira@users.noreply.github.com>
1 parent 4c6107e commit df2fd3d

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
@@ -143,6 +144,7 @@ def run_job(self, job: JobExecutorInterface):
143144
call += f" --cpus-per-task={get_cpus_per_task(job)}"
144145

145146
if job.resources.get("slurm_extra"):
147+
self.check_slurm_extra(job)
146148
call += f" {job.resources.slurm_extra}"
147149

148150
exec_job = self.format_job_exec(job)
@@ -488,3 +490,15 @@ def get_default_partition(self, job):
488490
"'slurm_partition=<your default partition>'."
489491
)
490492
return ""
493+
494+
def check_slurm_extra(self, job):
495+
jobname = re.compile(r"--job-name[=?|\s+]|-J\s?")
496+
if re.search(jobname, job.resources.slurm_extra):
497+
raise WorkflowError(
498+
"The '--job-name' option is not allowed in the 'slurm_extra' "
499+
"parameter. The job name is set by snakemake and must not be "
500+
"overwritten. It is internally used to check the stati of all "
501+
"submitted jobs by this workflow."
502+
"Please consult the documentation if you are unsure how to "
503+
"query the status of your jobs."
504+
)

0 commit comments

Comments
 (0)