Intuitive syntax for build targets

Create issue
Issue #1213 new
Tomas Fiers created an issue

Feature proposal: Intuitive syntax for build targets

Example

Current syntax:

rule all:
    input:
        "plots/quals.svg",
        "plots/matrix.svg"

...

Proposed syntax:

target:
    "plots/quals.svg",
    "plots/matrix.svg"

...

The first time(s) I came upon the Snakemake documentation, I found the former syntax confusing.
(This might have been a reason I initially chose other solutions, such as Luigi).

Implementation

An extension of the grammar:

snakemake = statement | rule | include | workdir | target
target = "target" ":" parameter_list

This is simply syntactic sugar for a leading rule: input: parameter_list.
This means that when the "target" statement is not present,
Snakemake's behaviour does not change, ensuring backwards compatibility.

If this feature is desirable, I’d gladly write a PR.

Comments (2)

  1. J.D. Matthews

    I would second this, it took me hours of confusion reading snakefiles to realise that rule all: input: ... represents the outputs. I read the tutorial a few times but the input/output substitution seemed to break my brain. Could anyone suggest a mental model so this makes sense?

  2. Johannes Köster

    I hear you. Once one understands how snakemake works, it feels quite logical to define targets like that though. However, it would indeed lower the learning curve to have an explicit syntax for targets. Yes, a PR would be welcome, and I think it only has to touch the parser.

  3. Log in to comment