From 2c88a27503f3eabb9a3b1b9f764aeb656503acca Mon Sep 17 00:00:00 2001 From: ned Date: Thu, 25 Jan 2024 11:51:30 +0100 Subject: [PATCH 1/5] Support slurm < 20.11 --- snakemake_executor_plugin_slurm/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index 6432f8d..b21dd65 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -8,6 +8,7 @@ import os import subprocess import time +from datetime import datetime, timedelta from typing import List, Generator import uuid from snakemake_interface_executor_plugins.executors.base import SubmittedJobInfo @@ -205,7 +206,8 @@ async def check_active_jobs( (status_of_jobs, sacct_query_duration) = await self.job_stati( # -X: only show main job, no substeps f"sacct -X --parsable2 --noheader --format=JobIdRaw,State " - f"--starttime now-2days --endtime now --name {self.run_uuid}" + f"--starttime {datetime.utcnow() - timedelta(days=2):%Y-%m-%dT%H} " + f"--endtime now --name {self.run_uuid}" ) if status_of_jobs is None and sacct_query_duration is None: self.logger.debug(f"could not check status of job {self.run_uuid}") From ad45bf25d84b72e41573b42e547db62266f081c9 Mon Sep 17 00:00:00 2001 From: ned Date: Mon, 29 Jan 2024 13:57:18 +0100 Subject: [PATCH 2/5] Fix timestamp 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 b21dd65..909d4a0 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -206,7 +206,7 @@ async def check_active_jobs( (status_of_jobs, sacct_query_duration) = await self.job_stati( # -X: only show main job, no substeps f"sacct -X --parsable2 --noheader --format=JobIdRaw,State " - f"--starttime {datetime.utcnow() - timedelta(days=2):%Y-%m-%dT%H} " + f"--starttime {datetime.utcnow() - timedelta(days=2):%Y-%m-%dT%H:00} " f"--endtime now --name {self.run_uuid}" ) if status_of_jobs is None and sacct_query_duration is None: From d1c1ed86eb38fd5be8d334d9ab66904580d4bec9 Mon Sep 17 00:00:00 2001 From: ned Date: Mon, 5 Feb 2024 19:56:48 +0100 Subject: [PATCH 3/5] Formatting and comment; use local time --- snakemake_executor_plugin_slurm/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index 909d4a0..40d87e3 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -199,6 +199,10 @@ async def check_active_jobs( active_jobs_ids = {job_info.external_jobid for job_info in active_jobs} active_jobs_seen_by_sacct = set() + # 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}" + # this code is inspired by the snakemake profile: # https://github.com/Snakemake-Profiles/slurm for i in range(status_attempts): @@ -206,7 +210,7 @@ async def check_active_jobs( (status_of_jobs, sacct_query_duration) = await self.job_stati( # -X: only show main job, no substeps f"sacct -X --parsable2 --noheader --format=JobIdRaw,State " - f"--starttime {datetime.utcnow() - timedelta(days=2):%Y-%m-%dT%H:00} " + f"--starttime {sacct_starttime} " f"--endtime now --name {self.run_uuid}" ) if status_of_jobs is None and sacct_query_duration is None: From a41d22aaa3f9f516d990acd67489ec0cac5493dc Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Wed, 14 Feb 2024 13:31:03 +0100 Subject: [PATCH 4/5] Update __init__.py wanted to keep original code version (outcommented) present --- snakemake_executor_plugin_slurm/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index ab754c8..f64b2e7 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -203,6 +203,10 @@ 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}" + # 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, + # the more readable version ought to be re-adapted # this code is inspired by the snakemake profile: # https://github.com/Snakemake-Profiles/slurm From 2b38093ff8541faf4cd102dacc5270d395747dd9 Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Wed, 14 Feb 2024 13:40:23 +0100 Subject: [PATCH 5/5] Update __init__.py fixed trailing white space --- 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 f64b2e7..975d5c6 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -205,7 +205,7 @@ async def check_active_jobs( 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, + # in line 218 - once v20.11 is definitively not in use any more, # the more readable version ought to be re-adapted # this code is inspired by the snakemake profile: