snakemake

Snakemake not re-running workflow or rule after script update


In snakemake, how do I indicate that a script is a dependency of an output file such that if the script changes, the rule will re-run?

For example, let's say this is my rule;

rule myrule:
    input:
        "foo.csv"
    output:
        "foobar.csv"
    script:
        "barfoo.py"

I assumed, wrongly I think, that if I change barfoo.py and do snakemake, that will trigger a re-run of the rule. However, that does not seem to be the case. After changes to barfoo.py and running snakemake, it says everything is up to date.

I'm new to snakemake, so I am be missing basic and fundamental. My apologies if so (I have searched and rtfm-ed). I assume there is some way to do this, like there is with GNU Make. e.g

foobar.csv: foo.csv foobar.py
    python foobar.py foo.csv foobar.csv

At present, I am doing a snakemake --foreceall after I change the script, but that seems to defeat the purpose.


Solution

  • with version 8.4.8, i can not reproduce your scenario. When I change barfoo.py snakemake will rerun and even tell me why:

    Reasons:
        (check individual jobs above for details)
        code has changed since last execution:
            myrule
    

    The command which regulates that behavior is --rerun-triggers, per default all triggers should be active, but you could try to play with it and see if it has an effect. E.g. --rerun-triggers code.

    Which snakemake version are you running?