richfitz / remake

Make-like declarative workflows in R
Other
340 stars 32 forks source link

manuscript not rebuilt when figures updated #153

Open fmichonneau opened 7 years ago

fmichonneau commented 7 years ago

let's say I have this as remake.yml

  all:
    depends: manuscript.pdf

  figures:
    depends:
      - figure1.pdf
      - figure2.pdf

  figure1.pdf:
    command: make_figure1()
    plot: true

  figure2.pdf:
    command: make_figure2()
    plot: true

  manuscript.md:
    knitr: true

  manuscript.pdf:
    depends:
      - figures
    command: render("manuscript.md")

this as functions.R

myplot <- function(n, col = "blue")  {
    ggplot(data.frame(x = rnorm(n),
                      y = rnorm(n))) +
        geom_point(aes(x = x, y = y), color = col)
}

make_figure1 <- function() {
    myplot(100, "red")
}

make_figure2 <- function() {
    myplot(100, "gray50")
}

and this as manuscript.Rmd

---
output: pdf_document
---

![wow](figure1.pdf)

![such](figure2.pdf)

editing the code of make_figure1 or make_figure2 properly triggers re-building the corresponding PDF file (figure1.pdf or figure2.pdf) but not of manuscript.md:

First time this is run:

> make()
<  MAKE > all
[  PLOT ] figure1.pdf    |  make_figure1() # ==> figure1.pdf
[  PLOT ] figure2.pdf    |  make_figure2() # ==> figure2.pdf
[ ----- ] figures
[  KNIT ] manuscript.md  |  knitr::knit("manuscript.Rmd", "manuscript.md")
[ BUILD ] manuscript.pdf |  render("manuscript.md")
/usr/bin/pandoc +RTS -K512m -RTS manuscript.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output manuscript.pdf --template /home/francois/.R/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in' 

Output created: manuscript.pdf
[ ----- ] all

2nd time without changing anything:

> make()
<  MAKE > all
[    OK ] figure1.pdf
[    OK ] figure2.pdf
[ ----- ] figures
[    OK ] manuscript.md
[    OK ] manuscript.pdf
[ ----- ] all

after editing the content of make_figure2():

> make()
[  READ ]                |  # loading sources
<  MAKE > all
[    OK ] figure1.pdf
[  PLOT ] figure2.pdf    |  make_figure2() # ==> figure2.pdf
[ ----- ] figures
[    OK ] manuscript.md
[    OK ] manuscript.pdf
[ ----- ] all
fmichonneau commented 7 years ago

this is with current github version:

> packageDescription("remake")
Package: remake
Title: Make-like build management
Version: 0.3.0
Authors@R: "Rich FitzJohn <rich.fitzjohn@gmail.com> [aut, cre]"
Description: Make-like build management in R.  The idea is to have some
        sort of declarative programming to build analysis pipelines,
        without having to use/install make.
Depends: R (>= 3.0.0)
License: BSD_2_clause + file LICENSE
LazyData: true
Imports: R6 (>= 2.0.0), crayon, digest, optparse, storr (>= 0.5.0),
        yaml
Suggests: DiagrammeR, devtools, knitr, testthat
RoxygenNote: 5.0.1.9000
RemoteType: github
RemoteHost: api.github.com
RemoteRepo: remake
RemoteUsername: richfitz
RemoteRef: master
RemoteSha: 902ec7a3b584dd672e048b656ebe1e6a56418e46
GithubRepo: remake
GithubUsername: richfitz
GithubRef: master
GithubSHA1: 902ec7a3b584dd672e048b656ebe1e6a56418e46
Author: "Rich FitzJohn" [aut, cre]
Maintainer: "Rich FitzJohn" <rich.fitzjohn@gmail.com>
Built: R 3.3.2; ; 2017-02-15 20:48:00 UTC; unix

-- File: /home/francois/.R/library/remake/Meta/package.rds 
richfitz commented 7 years ago

This is the same issue as #129 I think, and is a bug. I got part way through a solution to this before getting derailed again; it's a little subtle but it really should be fixed