Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.

Commit b0ff160

Browse files
slaube-jgucmeestersjohanneskoester
authored
feat: added requeue option to client (snakemake#136)
added option for users to indicate the sbatch requeue flag if the cluster configuration does no re-queuing on default this is a boolean flag. We wait for the interface_plugin to be fixed. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new option to allow requeuing of preempted or failed jobs in the job execution settings. - Added a `--requeue` flag to the job submission command for enhanced control over job handling. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: meesters <meesters@uni-mainz.de> Co-authored-by: Johannes Köster <johannes.koester@uni-due.de> Co-authored-by: Christian Meesters <cmeesters@users.noreply.github.com>
1 parent 1548d7a commit b0ff160

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

snakemake_executor_plugin_slurm/__init__.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ class ExecutorSettings(ExecutorSettingsBase):
4242
"required": False,
4343
},
4444
)
45+
requeue: bool = field(
46+
default=False,
47+
metadata={
48+
"help": """
49+
Allow requeuing preempted of failed jobs,
50+
if no cluster default. Results in `sbatch ... --requeue ...`
51+
This flag has no effect, if not set.
52+
""",
53+
"env_var": False,
54+
"required": False,
55+
},
56+
)
4557

4658

4759
# Required:
@@ -79,8 +91,6 @@ def __post_init__(self):
7991
self._fallback_account_arg = None
8092
self._fallback_partition = None
8193
self._preemption_warning = False # no preemption warning has been issued
82-
# providing a short-hand, even if subsequent calls seem redundant
83-
self.settings: ExecutorSettings = self.workflow.executor_settings
8494

8595
def warn_on_jobcontext(self, done=None):
8696
if not done:
@@ -145,6 +155,9 @@ def run_job(self, job: JobExecutorInterface):
145155
call += self.get_account_arg(job)
146156
call += self.get_partition_arg(job)
147157

158+
if self.workflow.executor_settings.requeue:
159+
call += " --requeue"
160+
148161
if job.resources.get("clusters"):
149162
call += f" --clusters {job.resources.clusters}"
150163

tests/tests.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22
import snakemake.common.tests
33
from snakemake_interface_executor_plugins.settings import ExecutorSettingsBase
44

5+
from snakemake_executor_plugin_slurm import ExecutorSettings
56

6-
class TestWorkflowsBase(snakemake.common.tests.TestWorkflowsLocalStorageBase):
7+
8+
class TestWorkflows(snakemake.common.tests.TestWorkflowsLocalStorageBase):
79
__test__ = True
810

911
def get_executor(self) -> str:
1012
return "slurm"
1113

1214
def get_executor_settings(self) -> Optional[ExecutorSettingsBase]:
13-
return None
15+
return ExecutorSettings()
16+
17+
18+
class TestWorkflowsRequeue(TestWorkflows):
19+
def get_executor_settings(self) -> Optional[ExecutorSettingsBase]:
20+
return ExecutorSettings(requeue=True)

0 commit comments

Comments
 (0)