Skip to content

Commit 6523889

Browse files
authored
fix: add lost code back in (#254)
this PR compensates for gpu support lost between 1.1 und 1.2 Furthermore some account handling issues has been corrected: If no account is specified, it can be 'none'. This is no Python type and always the root of the SLURM account tree. Instead, upon checking 'None' is returned. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - **Improved job submission:** The scheduling system now detects GPU usage to dynamically allocate tasks with optimal settings, ensuring more precise and efficient job execution. - **Enhanced account retrieval:** The process has been updated to correctly handle scenarios where account details aren’t needed, improving compatibility across diverse cluster environments. - Overall, these updates align with current scheduling standards, resulting in a more reliable user experience. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 89ed1dd commit 6523889

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

snakemake_executor_plugin_slurm/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,13 @@ def run_job(self, job: JobExecutorInterface):
261261
"- submitting without. This might or might not work on your cluster."
262262
)
263263

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)}"
264271
# MPI job
265272
if job.resources.get("mpi", False):
266273
if not job.resources.get("tasks_per_node") and not job.resources.get(
@@ -627,12 +634,14 @@ def get_account(self):
627634
tries to deduce the acccount from recent jobs,
628635
returns None, if none is found
629636
"""
630-
cmd = f'sacct -nu "{os.environ["USER"]}" -o Account%256 | head -n1'
637+
cmd = f'sacct -nu "{os.environ["USER"]}" -o Account%256 | tail -1'
631638
try:
632639
sacct_out = subprocess.check_output(
633640
cmd, shell=True, text=True, stderr=subprocess.PIPE
634641
)
635-
return sacct_out.replace("(null)", "").strip()
642+
possible_account = sacct_out.replace("(null)", "").strip()
643+
if possible_account == "none": # some clusters may not use an account
644+
return None
636645
except subprocess.CalledProcessError as e:
637646
self.logger.warning(
638647
f"No account was given, not able to get a SLURM account via sacct: "

0 commit comments

Comments
 (0)