ropensci / drake

An R-focused pipeline toolkit for reproducibility and high-performance computing
https://docs.ropensci.org/drake
GNU General Public License v3.0
1.34k stars 128 forks source link

r_make() gets stuck if envir = getNamespace("<pkg>") is used in drake_config() #1373

Closed gorgitko closed 3 years ago

gorgitko commented 3 years ago

Prework

Description

I am making drake workflow-as-package, and so changes in package functions need to be tracked. For that, I am following the instructions in chapter 7.5 of the drake book, namely the usage of envir = getNamespace("<pkg>"). However, this only works for make(), but not for drake_config() used in _drake.R file sourced by r_make(). In the latter, pipeline execution gets stuck on a first target.

Reproducible example

For reprex I am using https://github.com/januz/drakepkg. To avoid pollution of system library, I am using renv (but it is not required to do so).

First we create a new renv project and install the required packages, including the bleeding edge version of drake:

if (!require("renv")) install.packages("renv")
renv::init()

Now restart your R session and continue:

install.packages("remotes")
remotes::install_github("januz/drakepkg")
remotes::install_github("ropensci/drake")
install.packages("callr")

Let's create _drake.R:

library(drakepkg)
plan <- get_plan()
drake::drake_config(plan, envir = getNamespace("drakepkg"))

And run the pipeline:

drake::r_make()

It gets stuck on the first target:

Loading required package: drake
▶ target report

Expected result

The execution should not get stuck :slightly_smiling_face:

Session info

Show ``` ─ Session info ─────────────────────────────────────────────────────────────── setting value version R version 4.1.0 (2021-05-18) os Gentoo/Linux system x86_64, linux-gnu ui X11 language en_US.UTF-8 collate en_US.UTF-8 ctype en_US.UTF-8 tz Europe/Prague date 2021-07-27 ─ Packages ─────────────────────────────────────────────────────────────────── ! package * version date lib source backports 1.2.1 2020-12-09 [1] CRAN (R 4.1.0) base64url 1.4 2018-05-14 [1] CRAN (R 4.1.0) P callr 3.7.0 2021-04-20 [?] CRAN (R 4.1.0) cli 3.0.1 2021-07-17 [1] CRAN (R 4.1.0) crayon 1.4.1 2021-02-08 [1] CRAN (R 4.1.0) digest 0.6.27 2020-10-24 [1] CRAN (R 4.1.0) drake * 7.13.2.9000 2021-07-27 [1] Github (ropensci/drake@7574c9c) ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.0) filelock 1.0.2 2018-10-05 [1] CRAN (R 4.1.0) glue 1.4.2 2020-08-27 [1] CRAN (R 4.1.0) hms 1.1.0 2021-05-17 [1] CRAN (R 4.1.0) igraph 1.2.6 2020-10-06 [1] CRAN (R 4.1.0) lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.1.0) magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.1.0) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.0) prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.1.0) P processx 3.5.2 2021-04-30 [?] CRAN (R 4.1.0) progress 1.2.2 2019-05-16 [1] CRAN (R 4.1.0) P ps 1.6.0 2021-02-28 [?] CRAN (R 4.1.0) purrr 0.3.4 2020-04-17 [1] CRAN (R 4.1.0) R6 2.5.0 2020-10-28 [1] CRAN (R 4.1.0) P remotes 2.4.0 2021-06-02 [?] CRAN (R 4.1.0) renv 0.13.2 2021-03-30 [1] CRAN (R 4.1.0) rlang 0.4.11 2021-04-30 [1] CRAN (R 4.1.0) P sessioninfo 1.1.1 2018-11-05 [?] CRAN (R 4.1.0) storr 1.2.5 2020-12-01 [1] CRAN (R 4.1.0) tidyselect 1.1.1 2021-04-30 [1] CRAN (R 4.1.0) txtq 0.2.4 2021-03-27 [1] CRAN (R 4.1.0) vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.1.0) withr 2.4.2 2021-04-18 [1] CRAN (R 4.1.0) [1] /home/novotnyj/tmp/envir_reprex/renv/library/R-4.1/x86_64-pc-linux-gnu [2] /tmp/RtmpBJ1igX/renv-system-library P ── Loaded and on-disk path mismatch. ```

Thanks in advance for looking into this! :blush:

wlandau commented 3 years ago

Should be fixed now. lock_envir = FALSE is also a workaround.

gorgitko commented 3 years ago

Thanks a lot, works like a charm!