From 3abb561b97b3dcede1aa57ae6bb89bdcc2eadda1 Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Fri, 29 Nov 2024 09:25:52 +0100 Subject: [PATCH 1/2] feat: job arrays --- snakemake_executor_plugin_slurm/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index e70b5a16..994874a7 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -5,6 +5,7 @@ import csv from io import StringIO +from itertools import groupby import os import re import shlex @@ -107,6 +108,20 @@ def warn_on_jobcontext(self, done=None): def additional_general_args(self): return "--executor slurm-jobstep --jobs 1" + def run_jobs(self, jobs: List[JobExecutorInterface]): + for _, same_rule_jobs in groupby(jobs, key=lambda job: job.rule.name): + if len(same_rule_jobs) == 1: + self.run_job(same_rule_jobs[0]) + else: + # TODO submit as array + # share code with run_job + + # TODO in the future: give a hint to the scheduler to select preferably + # many jobs from the same rule if possible, in order to have + # more efficient array jobs. This should be somehow tunable, because + # it might contradict other efficiency goals. + ... + def run_job(self, job: JobExecutorInterface): # Implement here how to run a job. # You can access the job's resources, etc. From 5e8accaf954dfda1f437cfb1c8a60e5c2daf0d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20K=C3=B6ster?= Date: Fri, 20 Dec 2024 11:29:26 +0100 Subject: [PATCH 2/2] Update snakemake_executor_plugin_slurm/__init__.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- snakemake_executor_plugin_slurm/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index 994874a7..561845af 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -109,7 +109,8 @@ def additional_general_args(self): return "--executor slurm-jobstep --jobs 1" def run_jobs(self, jobs: List[JobExecutorInterface]): - for _, same_rule_jobs in groupby(jobs, key=lambda job: job.rule.name): + for rule_name, group in groupby(jobs, key=lambda job: job.rule.name): + same_rule_jobs = list(group) # Materialize the generator if len(same_rule_jobs) == 1: self.run_job(same_rule_jobs[0]) else: @@ -121,7 +122,6 @@ def run_jobs(self, jobs: List[JobExecutorInterface]): # more efficient array jobs. This should be somehow tunable, because # it might contradict other efficiency goals. ... - def run_job(self, job: JobExecutorInterface): # Implement here how to run a job. # You can access the job's resources, etc.