Nick Ulle
Nick Ulle

Reputation: 419

Automatically run rule when file changes in Snakemake

When working on compiled documents (LaTeX, RMarkdown, etc), I usually set up a rule for make using inotifywait to watch the input files and automatically rebuild the output file whenever the input files change.

For example:

dependencies = main.tex

main.pdf: $(dependencies)
    latexmk -lualatex --shell-escape $<

watch:
    while true; do inotifywait --event modify $(dependencies); $(MAKE); done

I'm now trying to migrate from make to snakemake. How can I set up something similar with snakemake?

Upvotes: 0

Views: 191

Answers (1)

Dmitry Kuzminov
Dmitry Kuzminov

Reputation: 6584

Using Snakemake you get the power of Python. For example, you can use inotify python module to wait for updates and run the snakemake.snakemake function each time you detect updates. But it would be much easier to reuse the bash script that you have already: while true; do inotifywait --event modify $(dependencies); snakemake; done.

Upvotes: 1

Related Questions