|
8 | 8 | import os
|
9 | 9 | import subprocess
|
10 | 10 | import time
|
| 11 | +from datetime import datetime, timedelta |
11 | 12 | from typing import List, Generator
|
12 | 13 | import uuid
|
13 | 14 | from snakemake_interface_executor_plugins.executors.base import SubmittedJobInfo
|
@@ -199,14 +200,23 @@ async def check_active_jobs(
|
199 | 200 | active_jobs_ids = {job_info.external_jobid for job_info in active_jobs}
|
200 | 201 | active_jobs_seen_by_sacct = set()
|
201 | 202 |
|
| 203 | + # We use this sacct syntax for argument 'starttime' to keep it compatible |
| 204 | + # with slurm < 20.11 |
| 205 | + sacct_starttime = f"{datetime.now() - timedelta(days=2):%Y-%m-%dT%H:00}" |
| 206 | + # previously we had |
| 207 | + # f"--starttime now-2days --endtime now --name {self.run_uuid}" |
| 208 | + # in line 218 - once v20.11 is definitively not in use any more, |
| 209 | + # the more readable version ought to be re-adapted |
| 210 | + |
202 | 211 | # this code is inspired by the snakemake profile:
|
203 | 212 | # https://github.com/Snakemake-Profiles/slurm
|
204 | 213 | for i in range(status_attempts):
|
205 | 214 | async with self.status_rate_limiter:
|
206 | 215 | (status_of_jobs, sacct_query_duration) = await self.job_stati(
|
207 | 216 | # -X: only show main job, no substeps
|
208 | 217 | f"sacct -X --parsable2 --noheader --format=JobIdRaw,State "
|
209 |
| - f"--starttime now-2days --endtime now --name {self.run_uuid}" |
| 218 | + f"--starttime {sacct_starttime} " |
| 219 | + f"--endtime now --name {self.run_uuid}" |
210 | 220 | )
|
211 | 221 | if status_of_jobs is None and sacct_query_duration is None:
|
212 | 222 | self.logger.debug(f"could not check status of job {self.run_uuid}")
|
|
0 commit comments