From 5d0310bdfb4cb4f5176d12b0eb64673d6f7ba649 Mon Sep 17 00:00:00 2001 From: "Laube, Sophie" Date: Thu, 15 Aug 2024 11:05:31 +0200 Subject: [PATCH 1/7] feat: added requeue option to cli --- snakemake_executor_plugin_slurm/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index a39936b1..d263bf67 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -40,6 +40,17 @@ class ExecutorSettings(ExecutorSettingsBase): "required": False, }, ) + requeue: Optional[bool] = field( + default=False, + metadata={ + "help": """ + Allow requeuing preempted of failed jobs, + if no cluster default. + """, + "env_var": False, + "required": False, + }, + ) # Required: @@ -141,6 +152,9 @@ def run_job(self, job: JobExecutorInterface): call += self.get_account_arg(job) call += self.get_partition_arg(job) + + if self.settings.requeue: + call += " --requeue" if job.resources.get("clusters"): call += f" --clusters {job.resources.clusters}" From b719a8e92ad0803ef913a28d3a01198f0caab83c Mon Sep 17 00:00:00 2001 From: "Laube, Sophie" Date: Thu, 15 Aug 2024 11:16:02 +0200 Subject: [PATCH 2/7] fix: format --- snakemake_executor_plugin_slurm/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index d263bf67..2cba6fb3 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -152,7 +152,7 @@ def run_job(self, job: JobExecutorInterface): call += self.get_account_arg(job) call += self.get_partition_arg(job) - + if self.settings.requeue: call += " --requeue" From 3d90e700f2506d494a4a408ace6365013b927991 Mon Sep 17 00:00:00 2001 From: meesters Date: Thu, 15 Aug 2024 13:26:37 +0200 Subject: [PATCH 3/7] fix: figured out, how a bool option is suppost to work --- snakemake_executor_plugin_slurm/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index 2cba6fb3..90722b58 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -40,7 +40,7 @@ class ExecutorSettings(ExecutorSettingsBase): "required": False, }, ) - requeue: Optional[bool] = field( + requeue: bool = field( default=False, metadata={ "help": """ From 42b44712d8f632ea7e9a6d6b93cc277bd29dcf00 Mon Sep 17 00:00:00 2001 From: meesters Date: Thu, 15 Aug 2024 13:34:02 +0200 Subject: [PATCH 4/7] fix: clearer help message --- snakemake_executor_plugin_slurm/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index 90722b58..28db3633 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -45,7 +45,8 @@ class ExecutorSettings(ExecutorSettingsBase): metadata={ "help": """ Allow requeuing preempted of failed jobs, - if no cluster default. + if no cluster default. Results in `sbatch ... --requeue ...` + This flag has no effect, if not set. """, "env_var": False, "required": False, From 1e34bac7c1898b7cd7419a89ec3ba44f0ce89078 Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Fri, 27 Sep 2024 12:00:33 +0200 Subject: [PATCH 5/7] try fix (I think the executor is instantiated before the executor settings are put into the workflow) --- snakemake_executor_plugin_slurm/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index e2dc8a17..e9d74eab 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -91,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: @@ -157,7 +155,7 @@ def run_job(self, job: JobExecutorInterface): call += self.get_account_arg(job) call += self.get_partition_arg(job) - if self.settings.requeue: + if self.workflow.settings.requeue: call += " --requeue" if job.resources.get("clusters"): From f123fd92e66d599f6da19993362651ecc758b94a Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Fri, 27 Sep 2024 12:04:20 +0200 Subject: [PATCH 6/7] fix the fix --- snakemake_executor_plugin_slurm/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index e9d74eab..9b214c02 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -155,7 +155,7 @@ def run_job(self, job: JobExecutorInterface): call += self.get_account_arg(job) call += self.get_partition_arg(job) - if self.workflow.settings.requeue: + if self.workflow.executor_settings.requeue: call += " --requeue" if job.resources.get("clusters"): From b2a44de88074fed92761b73ebac83205a0c7fc25 Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Fri, 27 Sep 2024 16:16:02 +0200 Subject: [PATCH 7/7] fix test class --- tests/tests.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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)