diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index e0b1efd1..9b214c02 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -42,6 +42,18 @@ class ExecutorSettings(ExecutorSettingsBase): "required": False, }, ) + requeue: bool = field( + default=False, + metadata={ + "help": """ + Allow requeuing preempted of failed jobs, + if no cluster default. Results in `sbatch ... --requeue ...` + This flag has no effect, if not set. + """, + "env_var": False, + "required": False, + }, + ) # Required: @@ -79,8 +91,6 @@ def __post_init__(self): self._fallback_account_arg = None self._fallback_partition = None self._preemption_warning = False # no preemption warning has been issued - # providing a short-hand, even if subsequent calls seem redundant - self.settings: ExecutorSettings = self.workflow.executor_settings def warn_on_jobcontext(self, done=None): if not done: @@ -145,6 +155,9 @@ def run_job(self, job: JobExecutorInterface): call += self.get_account_arg(job) call += self.get_partition_arg(job) + if self.workflow.executor_settings.requeue: + call += " --requeue" + if job.resources.get("clusters"): call += f" --clusters {job.resources.clusters}" diff --git a/tests/tests.py b/tests/tests.py index 71670396..3d234dc1 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -2,12 +2,19 @@ import snakemake.common.tests from snakemake_interface_executor_plugins.settings import ExecutorSettingsBase +from snakemake_executor_plugin_slurm import ExecutorSettings -class TestWorkflowsBase(snakemake.common.tests.TestWorkflowsLocalStorageBase): + +class TestWorkflows(snakemake.common.tests.TestWorkflowsLocalStorageBase): __test__ = True def get_executor(self) -> str: return "slurm" def get_executor_settings(self) -> Optional[ExecutorSettingsBase]: - return None + return ExecutorSettings() + + +class TestWorkflowsRequeue(TestWorkflows): + def get_executor_settings(self) -> Optional[ExecutorSettingsBase]: + return ExecutorSettings(requeue=True)