make
]Task automation
make
)A button to push and reproduce
make
The recipe builder
Understanding a research project (e.g. paper) as a code project: to obtain certain outcomes (e.g. final paper version), one needs to complete a series of steps in a particular order (clean data, run regressions, write paper).
Benefits:
make
Just as a “chainer” of files:
$ vim Makefile
all:
write_my_diss
pdflatex dissertation.tex
R CMD BATCH a_little_luck.R
Running make
will execute all of the three processes.
Suppose you want to have a handy shortcut for the first two only:
all:
write_my_diss
pdflatex dissertation.tex
R CMD BATCH a_little_luck.R
hardwork:
pdflatex dissertation.tex
R CMD BATCH a_little_luck.R
Running make
will still execute all of them, but running make hardwork
will only run the first two.
make
modelFor example:
dissertation.tex:write_my_diss
write_my_diss
You can chain steps and add more sources for a target:
dissertation.tex: write_my_diss
write_my_diss
phd.txt: dissertation.tex a_little_luck.R
R CMD BATCH a_little_luck.R
If phd.txt
does not exist, or dissertation.tex
and/or a_little_luck.R
have changed since last time it was produced, make
will run the R process again, which should produce a new version of phd.txt
Content by Dani Arribas-Bel and Thomas De Graaff, licensed under Creative Commons Attribution 4.0 International License.
For this session, we have borrowed important amounts of inspiration and material from Software Carpentry’s session on git and the freely available book Pro Git