Skip to content

Procedurally generated rules are registered with a number instead of the defined name #3741

@daherb

Description

@daherb

Snakemake version

> snakemake --version
9.11.2

Describe the bug

When procedurally generating rules the rules are registered in the Rules object with numbers as name and not with the defined names and cannot easily be referenced, e.g. in dependencies

Logs

> snakemake --cores=1
Registered rules: dict_keys(['1', '2'])
WorkflowError in file "/tmp/bug/Snakefile", line 15:
Rule run_task1 is not defined in this workflow. Available rules: 1, 2

Minimal example

tasks = ["task1", "task2"]

for task in tasks:
    rule:
        name: f"run_{task}"
        output:
            "{task}.txt"
        shell:
            "touch {output}"

print("Registered rules: " + str(rules._rules.keys()))

rule run:
    input:
        rules.run_task1.output
    shell:
        "cat {input}"

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions