snakemake-executor-plugin-slurm 1.2.0__tar.gz → 1.2.2__tar.gz
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-1.2.0 → snakemake_executor_plugin_slurm-1.2.2}/PKG-INFO +1 -1
- {snakemake_executor_plugin_slurm-1.2.0 → snakemake_executor_plugin_slurm-1.2.2}/pyproject.toml +1 -1
- {snakemake_executor_plugin_slurm-1.2.0 → snakemake_executor_plugin_slurm-1.2.2}/snakemake_executor_plugin_slurm/__init__.py +12 -3
- {snakemake_executor_plugin_slurm-1.2.0 → snakemake_executor_plugin_slurm-1.2.2}/snakemake_executor_plugin_slurm/utils.py +28 -9
- {snakemake_executor_plugin_slurm-1.2.0 → snakemake_executor_plugin_slurm-1.2.2}/LICENSE +0 -0
- {snakemake_executor_plugin_slurm-1.2.0 → snakemake_executor_plugin_slurm-1.2.2}/README.md +0 -0
- {snakemake_executor_plugin_slurm-1.2.0 → snakemake_executor_plugin_slurm-1.2.2}/snakemake_executor_plugin_slurm/submit_string.py +0 -0
|
@@ -261,6 +261,13 @@ class Executor(RemoteExecutor):
|
|
|
261
261
|
"- submitting without. This might or might not work on your cluster."
|
|
262
262
|
)
|
|
263
263
|
|
|
264
|
+
# fixes #40 - set ntasks regardless of mpi, because
|
|
265
|
+
# SLURM v22.05 introduced the requirement for all jobs
|
|
266
|
+
gpu_job = job.resources.get("gpu") or "gpu" in job.resources.get("gres", "")
|
|
267
|
+
if gpu_job:
|
|
268
|
+
call += f" --ntasks-per-gpu={job.resources.get('tasks', 1)}"
|
|
269
|
+
else:
|
|
270
|
+
call += f" --ntasks={job.resources.get('tasks', 1)}"
|
|
264
271
|
# MPI job
|
|
265
272
|
if job.resources.get("mpi", False):
|
|
266
273
|
if not job.resources.get("tasks_per_node") and not job.resources.get(
|
|
@@ -627,12 +634,14 @@ We leave it to SLURM to resume your job(s)"""
|
|
|
627
634
|
tries to deduce the acccount from recent jobs,
|
|
628
635
|
returns None, if none is found
|
|
629
636
|
"""
|
|
630
|
-
cmd = f'sacct -nu "{os.environ["USER"]}" -o Account%256 |
|
|
637
|
+
cmd = f'sacct -nu "{os.environ["USER"]}" -o Account%256 | tail -1'
|
|
631
638
|
try:
|
|
632
639
|
sacct_out = subprocess.check_output(
|
|
633
640
|
cmd, shell=True, text=True, stderr=subprocess.PIPE
|
|
634
641
|
)
|
|
635
|
-
|
|
642
|
+
possible_account = sacct_out.replace("(null)", "").strip()
|
|
643
|
+
if possible_account == "none": # some clusters may not use an account
|
|
644
|
+
return None
|
|
636
645
|
except subprocess.CalledProcessError as e:
|
|
637
646
|
self.logger.warning(
|
|
638
647
|
f"No account was given, not able to get a SLURM account via sacct: "
|
|
@@ -644,7 +653,7 @@ We leave it to SLURM to resume your job(s)"""
|
|
|
644
653
|
"""
|
|
645
654
|
tests whether the given account is registered, raises an error, if not
|
|
646
655
|
"""
|
|
647
|
-
cmd = "sshare -U --format Account --noheader"
|
|
656
|
+
cmd = "sshare -U --format Account%256 --noheader"
|
|
648
657
|
try:
|
|
649
658
|
accounts = subprocess.check_output(
|
|
650
659
|
cmd, shell=True, text=True, stderr=subprocess.PIPE
|
|
@@ -58,6 +58,9 @@ def set_gres_string(job: JobExecutorInterface) -> str:
|
|
|
58
58
|
gres_re = re.compile(r"^[a-zA-Z0-9_]+(:[a-zA-Z0-9_]+)?:\d+$")
|
|
59
59
|
# gpu model arguments can be of type "string"
|
|
60
60
|
gpu_model_re = re.compile(r"^[a-zA-Z0-9_]+$")
|
|
61
|
+
# any arguments should not start and end with ticks or
|
|
62
|
+
# quotation marks:
|
|
63
|
+
string_check = re.compile(r"^[^'\"].*[^'\"]$")
|
|
61
64
|
# The Snakemake resources can be only be of type "int",
|
|
62
65
|
# hence no further regex is needed.
|
|
63
66
|
|
|
@@ -81,20 +84,36 @@ def set_gres_string(job: JobExecutorInterface) -> str:
|
|
|
81
84
|
# Validate GRES format (e.g., "gpu:1", "gpu:tesla:2")
|
|
82
85
|
gres = job.resources.gres
|
|
83
86
|
if not gres_re.match(gres):
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
if not string_check.match(gres):
|
|
88
|
+
raise WorkflowError(
|
|
89
|
+
"GRES format should not be a nested string (start "
|
|
90
|
+
"and end with ticks or quotation marks). "
|
|
91
|
+
"Expected format: "
|
|
92
|
+
"'<name>:<number>' or '<name>:<type>:<number>' "
|
|
93
|
+
"(e.g., 'gpu:1' or 'gpu:tesla:2')"
|
|
94
|
+
)
|
|
95
|
+
else:
|
|
96
|
+
raise WorkflowError(
|
|
97
|
+
f"Invalid GRES format: {gres}. Expected format: "
|
|
98
|
+
"'<name>:<number>' or '<name>:<type>:<number>' "
|
|
99
|
+
"(e.g., 'gpu:1' or 'gpu:tesla:2')"
|
|
100
|
+
)
|
|
89
101
|
return f" --gres={job.resources.gres}"
|
|
90
102
|
|
|
91
103
|
if gpu_model and gpu_string:
|
|
92
104
|
# validate GPU model format
|
|
93
105
|
if not gpu_model_re.match(gpu_model):
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
106
|
+
if not string_check.match(gpu_model):
|
|
107
|
+
raise WorkflowError(
|
|
108
|
+
"GPU model format should not be a nested string (start "
|
|
109
|
+
"and end with ticks or quotation marks). "
|
|
110
|
+
"Expected format: '<name>' (e.g., 'tesla')"
|
|
111
|
+
)
|
|
112
|
+
else:
|
|
113
|
+
raise WorkflowError(
|
|
114
|
+
f"Invalid GPU model format: {gpu_model}."
|
|
115
|
+
" Expected format: '<name>' (e.g., 'tesla')"
|
|
116
|
+
)
|
|
98
117
|
return f" --gpus={gpu_model}:{gpu_string}"
|
|
99
118
|
elif gpu_model and not gpu_string:
|
|
100
119
|
raise WorkflowError("GPU model is set, but no GPU number is given")
|
|
File without changes
|
|
File without changes
|