Skip to content

Commit

Permalink
fix: allow to use {wildcards} for group jobs in cluster config (#1555)
Browse files Browse the repository at this point in the history
* Add merged wildcards to group job formatting rule

* fixes, as suggested by @twillis209
  • Loading branch information
johanneskoester committed Aug 25, 2022
1 parent 2b32bba commit f0ec73d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions snakemake/jobs.py
Expand Up @@ -1437,15 +1437,27 @@ def priority(self):
def is_local(self):
return all(job.is_local for job in self.jobs)

def merged_wildcards(self):
jobs = iter(self.jobs)
merged_wildcards = Wildcards(toclone=next(jobs).wildcards)
for job in jobs:
for name, value in job.wildcards.items():
if name not in merged_wildcards.keys():
merged_wildcards.append(value)
merged_wildcards._add_name(name)
return merged_wildcards

def format_wildcards(self, string, **variables):
"""Format a string with variables from the job."""

_variables = dict()
_variables.update(self.dag.workflow.globals)
_variables.update(
dict(
input=self.input,
output=self.output,
threads=self.threads,
wildcards=self.merged_wildcards(),
jobid=self.jobid,
name=self.name,
rule="GROUP",
Expand Down

0 comments on commit f0ec73d

Please sign in to comment.