snakemake-executor-plugin-slurm 0.6.0__py3-none-any.whl → 0.8.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of snakemake-executor-plugin-slurm might be problematic. Click here for more details.
- snakemake_executor_plugin_slurm/__init__.py +42 -8
- {snakemake_executor_plugin_slurm-0.6.0.dist-info → snakemake_executor_plugin_slurm-0.8.0.dist-info}/METADATA +1 -1
- snakemake_executor_plugin_slurm-0.8.0.dist-info/RECORD +5 -0
- snakemake_executor_plugin_slurm-0.6.0.dist-info/RECORD +0 -5
- {snakemake_executor_plugin_slurm-0.6.0.dist-info → snakemake_executor_plugin_slurm-0.8.0.dist-info}/LICENSE +0 -0
- {snakemake_executor_plugin_slurm-0.6.0.dist-info → snakemake_executor_plugin_slurm-0.8.0.dist-info}/WHEEL +0 -0
|
@@ -9,12 +9,16 @@ import os
|
|
|
9
9
|
import re
|
|
10
10
|
import subprocess
|
|
11
11
|
import time
|
|
12
|
+
from dataclasses import dataclass, field
|
|
12
13
|
from datetime import datetime, timedelta
|
|
13
|
-
from typing import List, Generator
|
|
14
|
+
from typing import List, Generator, Optional
|
|
14
15
|
import uuid
|
|
15
16
|
from snakemake_interface_executor_plugins.executors.base import SubmittedJobInfo
|
|
16
17
|
from snakemake_interface_executor_plugins.executors.remote import RemoteExecutor
|
|
17
|
-
from snakemake_interface_executor_plugins.settings import
|
|
18
|
+
from snakemake_interface_executor_plugins.settings import (
|
|
19
|
+
ExecutorSettingsBase,
|
|
20
|
+
CommonSettings,
|
|
21
|
+
)
|
|
18
22
|
from snakemake_interface_executor_plugins.jobs import (
|
|
19
23
|
JobExecutorInterface,
|
|
20
24
|
)
|
|
@@ -22,6 +26,21 @@ from snakemake_interface_common.exceptions import WorkflowError
|
|
|
22
26
|
from snakemake_executor_plugin_slurm_jobstep import get_cpus_per_task
|
|
23
27
|
|
|
24
28
|
|
|
29
|
+
@dataclass
|
|
30
|
+
class ExecutorSettings(ExecutorSettingsBase):
|
|
31
|
+
init_seconds_before_status_checks: Optional[int] = field(
|
|
32
|
+
default=40,
|
|
33
|
+
metadata={
|
|
34
|
+
"help": """
|
|
35
|
+
Defines the time in seconds before the first status
|
|
36
|
+
check is performed after job submission.
|
|
37
|
+
""",
|
|
38
|
+
"env_var": False,
|
|
39
|
+
"required": False,
|
|
40
|
+
},
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
25
44
|
# Required:
|
|
26
45
|
# Specify common settings shared by various executors.
|
|
27
46
|
common_settings = CommonSettings(
|
|
@@ -50,10 +69,25 @@ common_settings = CommonSettings(
|
|
|
50
69
|
# Implementation of your executor
|
|
51
70
|
class Executor(RemoteExecutor):
|
|
52
71
|
def __post_init__(self):
|
|
72
|
+
# run check whether we are running in a SLURM job context
|
|
73
|
+
self.warn_on_jobcontext()
|
|
53
74
|
self.run_uuid = str(uuid.uuid4())
|
|
54
75
|
self.logger.info(f"SLURM run ID: {self.run_uuid}")
|
|
55
76
|
self._fallback_account_arg = None
|
|
56
77
|
self._fallback_partition = None
|
|
78
|
+
# providing a short-hand, even if subsequent calls seem redundant
|
|
79
|
+
self.settings: ExecutorSettings = self.workflow.executor_settings
|
|
80
|
+
|
|
81
|
+
def warn_on_jobcontext(self, done=None):
|
|
82
|
+
if not done:
|
|
83
|
+
if "SLURM_JOB_ID" in os.environ:
|
|
84
|
+
self.logger.warning(
|
|
85
|
+
"You are running snakemake in a SLURM job context. "
|
|
86
|
+
"This is not recommended, as it may lead to unexpected behavior."
|
|
87
|
+
"Please run Snakemake directly on the login node."
|
|
88
|
+
)
|
|
89
|
+
time.sleep(5)
|
|
90
|
+
done = True
|
|
57
91
|
|
|
58
92
|
def additional_general_args(self):
|
|
59
93
|
return "--executor slurm-jobstep --jobs 1"
|
|
@@ -127,7 +161,7 @@ class Executor(RemoteExecutor):
|
|
|
127
161
|
if job.resources.get("nodes", False):
|
|
128
162
|
call += f" --nodes={job.resources.get('nodes', 1)}"
|
|
129
163
|
|
|
130
|
-
# fixes #40 - set ntasks
|
|
164
|
+
# fixes #40 - set ntasks regardless of mpi, because
|
|
131
165
|
# SLURM v22.05 will require it for all jobs
|
|
132
166
|
call += f" --ntasks={job.resources.get('tasks', 1)}"
|
|
133
167
|
# MPI job
|
|
@@ -182,7 +216,6 @@ class Executor(RemoteExecutor):
|
|
|
182
216
|
self, active_jobs: List[SubmittedJobInfo]
|
|
183
217
|
) -> Generator[SubmittedJobInfo, None, None]:
|
|
184
218
|
# Check the status of active jobs.
|
|
185
|
-
|
|
186
219
|
# You have to iterate over the given list active_jobs.
|
|
187
220
|
# For jobs that have finished successfully, you have to call
|
|
188
221
|
# self.report_job_success(job).
|
|
@@ -393,6 +426,7 @@ class Executor(RemoteExecutor):
|
|
|
393
426
|
account = self.get_account()
|
|
394
427
|
if account:
|
|
395
428
|
self.logger.warning(f"Guessed SLURM account: {account}")
|
|
429
|
+
self.test_account(f"{account}")
|
|
396
430
|
self._fallback_account_arg = f" -A {account}"
|
|
397
431
|
else:
|
|
398
432
|
self.logger.warning(
|
|
@@ -430,7 +464,7 @@ class Executor(RemoteExecutor):
|
|
|
430
464
|
sacct_out = subprocess.check_output(
|
|
431
465
|
cmd, shell=True, text=True, stderr=subprocess.PIPE
|
|
432
466
|
)
|
|
433
|
-
return sacct_out.strip()
|
|
467
|
+
return sacct_out.replace("(null)", "").strip()
|
|
434
468
|
except subprocess.CalledProcessError as e:
|
|
435
469
|
self.logger.warning(
|
|
436
470
|
f"No account was given, not able to get a SLURM account via sacct: "
|
|
@@ -495,10 +529,10 @@ class Executor(RemoteExecutor):
|
|
|
495
529
|
jobname = re.compile(r"--job-name[=?|\s+]|-J\s?")
|
|
496
530
|
if re.search(jobname, job.resources.slurm_extra):
|
|
497
531
|
raise WorkflowError(
|
|
498
|
-
"The
|
|
532
|
+
"The --job-name option is not allowed in the 'slurm_extra' "
|
|
499
533
|
"parameter. The job name is set by snakemake and must not be "
|
|
500
|
-
"overwritten. It is internally used to check the stati of
|
|
501
|
-
"submitted jobs by this workflow."
|
|
534
|
+
"overwritten. It is internally used to check the stati of the "
|
|
535
|
+
"all submitted jobs by this workflow."
|
|
502
536
|
"Please consult the documentation if you are unsure how to "
|
|
503
537
|
"query the status of your jobs."
|
|
504
538
|
)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
snakemake_executor_plugin_slurm/__init__.py,sha256=GC5yU3EsnBJBC9Z6gIQdt2GHK3QLdF0sQj5TDI6VDLo,22851
|
|
2
|
+
snakemake_executor_plugin_slurm-0.8.0.dist-info/LICENSE,sha256=YVc4xTLWMqGfFL36120k7rzXtsT6e4RkJsh68VVn12s,1076
|
|
3
|
+
snakemake_executor_plugin_slurm-0.8.0.dist-info/METADATA,sha256=S2aTNWZg3rDSECsTQISccHHvxkc83YyPLugtIuHKdUk,1380
|
|
4
|
+
snakemake_executor_plugin_slurm-0.8.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
5
|
+
snakemake_executor_plugin_slurm-0.8.0.dist-info/RECORD,,
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
snakemake_executor_plugin_slurm/__init__.py,sha256=tYTHco7vGZ6OtU-Cxfdy9PUJX8z-Svs7exL8x8bYBLk,21575
|
|
2
|
-
snakemake_executor_plugin_slurm-0.6.0.dist-info/LICENSE,sha256=YVc4xTLWMqGfFL36120k7rzXtsT6e4RkJsh68VVn12s,1076
|
|
3
|
-
snakemake_executor_plugin_slurm-0.6.0.dist-info/METADATA,sha256=R-SvE45vFNUtJVfJjF_qOQjoSojYkKGxGsIe5kaZz-8,1380
|
|
4
|
-
snakemake_executor_plugin_slurm-0.6.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
5
|
-
snakemake_executor_plugin_slurm-0.6.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|