Skip to content

feat: added requeue option to client #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 27, 2024
17 changes: 15 additions & 2 deletions snakemake_executor_plugin_slurm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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}"

Expand Down
11 changes: 9 additions & 2 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading