Support for dynamic rule naming

Create issue
Issue #793 new
Former user created an issue

I am dynamically creating rules in a for loop, and would like to give them a placeholder name. Right now, I do something like that:

for id, output_files in ARCHIVE_CONTENTS.items():
   rule:
     input: 
       'archives/{id}.tar.gz'.format(id=id)
     output:
       expand('extracted/{outfile}', outfile=output_files)

The length of output_files is varying, so I cannot replace this with a single rule. Everything works fine, but the created rules are just numbered, leading to output like this:

count jobs
1        6
1        7

I would like to propose a feature to create placeholder names, maybe like this:

for id, output_files in ARCHIVE_CONTENTS.items():
  rule 'extract_{id}'.format(id=id):

Alternatively, it would be sufficient to be able to specify a rule name prefix for rules that are otherwise unnamed:

rule:
   name_prefix: extract_

leading rules to be named extract_1, extract_2, ...

If you let me know where to make the changes and which design you'd like to go for, I can help with the implementation.

Comments (1)

  1. Enrico Bothmann

    This would also be very useful for me, as I'm also creating rules in a dynamic way as above.

  2. Log in to comment