From a0d47efd64574548d3caa15b736573cb1e9b9cc2 Mon Sep 17 00:00:00 2001 From: nikostr Date: Mon, 9 Jun 2025 11:14:14 +0200 Subject: [PATCH 1/6] fix: replace WorkflowError with report_job_error for sbatch failure --- snakemake_executor_plugin_slurm/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index badda89a..047f6b8c 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -299,9 +299,8 @@ def run_job(self, job: JobExecutorInterface): process.returncode, call, output=err ) except subprocess.CalledProcessError as e: - raise WorkflowError( - f"SLURM sbatch failed. The error message was {e.output}" - ) + self.report_job_error(job) + return # any other error message indicating failure? if "submission failed" in err: raise WorkflowError( From 317018259b74c494cad59b7becbb5db2ec73be8b Mon Sep 17 00:00:00 2001 From: nikostr Date: Mon, 9 Jun 2025 11:57:42 +0200 Subject: [PATCH 2/6] fix: wrap job in SubmittedJobInfo when calling report_job_error --- 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 047f6b8c..1c8d5d6b 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -299,7 +299,7 @@ def run_job(self, job: JobExecutorInterface): process.returncode, call, output=err ) except subprocess.CalledProcessError as e: - self.report_job_error(job) + self.report_job_error(SubmittedJobInfo(job)) return # any other error message indicating failure? if "submission failed" in err: From 3553b13d4e0e47194f03c9348af647e9743cf8a4 Mon Sep 17 00:00:00 2001 From: nikostr Date: Mon, 9 Jun 2025 12:51:08 +0200 Subject: [PATCH 3/6] Add error message when reporting jobs failed due to bad sbatch call --- snakemake_executor_plugin_slurm/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index 1c8d5d6b..db1631fa 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -299,7 +299,10 @@ def run_job(self, job: JobExecutorInterface): process.returncode, call, output=err ) except subprocess.CalledProcessError as e: - self.report_job_error(SubmittedJobInfo(job)) + self.report_job_error( + SubmittedJobInfo(job), + msg=f'SLURM sbatch failed. The error message was "{e.output}". sbatch call: "{call}"', + ) return # any other error message indicating failure? if "submission failed" in err: From 87fb93c65dab390b452b8abac19b40ce3fad4925 Mon Sep 17 00:00:00 2001 From: nikostr Date: Mon, 9 Jun 2025 13:10:39 +0200 Subject: [PATCH 4/6] Improve readability of error msg for bad sbatch jobs --- 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 db1631fa..f35f16c1 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -301,7 +301,7 @@ def run_job(self, job: JobExecutorInterface): except subprocess.CalledProcessError as e: self.report_job_error( SubmittedJobInfo(job), - msg=f'SLURM sbatch failed. The error message was "{e.output}". sbatch call: "{call}"', + msg=f'SLURM sbatch failed. The error message was "{e.output}".\nsbatch call:\n{call}\n', ) return # any other error message indicating failure? From 8f1d7b63ed54f57f752e59ad6140ce5dbb95c76b Mon Sep 17 00:00:00 2001 From: nikostr Date: Fri, 4 Jul 2025 18:26:49 +0200 Subject: [PATCH 5/6] Fix lints and format msg * Fix lints * Add msg indentation * Remove extra line break from msg --- snakemake_executor_plugin_slurm/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index f35f16c1..42073736 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -301,7 +301,11 @@ def run_job(self, job: JobExecutorInterface): except subprocess.CalledProcessError as e: self.report_job_error( SubmittedJobInfo(job), - msg=f'SLURM sbatch failed. The error message was "{e.output}".\nsbatch call:\n{call}\n', + msg=( + "SLURM sbatch failed. " + f"The error message was '{e.output.strip()}'.\n" + f" sbatch call:\n {call}\n" + ) ) return # any other error message indicating failure? @@ -380,7 +384,7 @@ async def check_active_jobs( # We use this sacct syntax for argument 'starttime' to keep it compatible # with slurm < 20.11 - sacct_starttime = f"{datetime.now() - timedelta(days = 2):%Y-%m-%dT%H:00}" + sacct_starttime = f"{datetime.now() - timedelta(days=2):%Y-%m-%dT%H:00}" # previously we had # f"--starttime now-2days --endtime now --name {self.run_uuid}" # in line 218 - once v20.11 is definitively not in use any more, From d4082baa1f5fdcbe037314370a511d0c30e3b839 Mon Sep 17 00:00:00 2001 From: nikostr Date: Sun, 6 Jul 2025 21:25:22 +0200 Subject: [PATCH 6/6] Fix black formatting --- 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 3322fd84..64502deb 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -372,7 +372,7 @@ def run_job(self, job: JobExecutorInterface): "SLURM sbatch failed. " f"The error message was '{e.output.strip()}'.\n" f" sbatch call:\n {call}\n" - ) + ), ) return # any other error message indicating failure?