Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: job arrays #174

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions snakemake_executor_plugin_slurm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import csv
from io import StringIO
from itertools import groupby
import os
import re
import shlex
Expand Down Expand Up @@ -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 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:
# 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.
Expand Down
Loading