Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
6 tasks done
gorgitko opened this issue Jul 27, 2021 · 2 comments
Closed
6 tasks done
Assignees

Comments

@gorgitko
Copy link

Prework

  • Read and agree to the code of conduct and contributing guidelines.
  • If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
  • Post a minimal reproducible example so the maintainer can troubleshoot the problems you identify. A reproducible example is:
    • Runnable: post enough R code and data so any onlooker can create the error on their own computer.
    • Minimal: reduce runtime wherever possible and remove complicated details that are irrelevant to the issue at hand.
    • Readable: format your code according to the tidyverse style guide.

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 🙂

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! 😊

@wlandau
Copy link
Member

wlandau commented Jul 27, 2021

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

@gorgitko
Copy link
Author

Thanks a lot, works like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants