`r_make()` 和 `make()` 在 r-drake 中不一致
`r_make()` and `make()` not consistent in r-drake
我正在使用 RStudio 来完成相关工作。以前一直用drake::make()
忽略提示用r_make()
直到昨天决定试一试
现在,我有点不知所措。不确定我做了什么/如果我发现了错误。
我的项目计划不大,但目标构建很大(每次拉取 10-20 分钟的数据)。我已经 运行 使用来自 RStudio 控制台的 make()
端到端。一切都是最新的。即使我在终端中打开一个单独的 R
会话,并且 运行 outdated()
,我也没有看到任何过时的东西。
但是,从 Rstudio 控制台 运行ning r_make()
,或从 R
在单独的终端中导致许多目标已过时。
而且无论我运行r_make()
多少次,这些对象都没有更新。
我不知道如何进行。我想继续使用 r_make()
,但我卡住了。
更新
https://gitlab.com/rsangole/drake-test
处的可重现示例
更新 2
运行ning @landau 的 reprex
示例,输出在这里。它工作正常,正如 Will 使用此脚本获得的那样:https://gitlab.com/rsangole/drake-test/snippets/1894934
然而...
如果我 运行 https://gitlab.com/rsangole/drake-test/blob/master/make.R 在 RStudio 的交互模式下,我可以重现我的情况。重现:
- 打开新的 Rstudio,清理环境
- 在 https://gitlab.com/rsangole/drake-test
中下载可重现的示例
- 运行 https://gitlab.com/rsangole/drake-test/blob/master/make.R
- 预期输出如 https://gitlab.com/rsangole/drake-test/snippets/1894937
甚至在将 drake
更新到最新的前沿版本后仍然出现同样的问题
如果我 运行 make.R
通过 zsh
中的 R
从而完全绕过 RStudio,也能够复制问题。
我创建了一个 reprex
using https://gitlab.com/rsangole/drake-test,但无法重现您所看到的内容。您使用 drake
的方式是否与以下代码不同?
library(drake)
# Write script files
package_code <- quote({
library(data.table)
library(drake)
})
function_code <- quote(
make_data <- function(download_date){
data.table(
dt = download_date,
x = runif(n = 1e5),
y = sample(letters,size = 1e5,replace = T)
)
}
)
plan_code <- quote(
plan <- drake_plan(
download_date = "2019-09-08",
x = make_data(download_date)
)
)
writeLines(deparse(package_code), "packages.R")
writeLines(deparse(function_code), "functions.R")
writeLines(deparse(plan_code), "plan.R")
# Run make()
source("packages.R")
source("functions.R")
source("plan.R")
make(
plan,
verbose = 2,
parallelism = "future",
jobs = 4L,
lock_envir = FALSE
)
#>
target download_date
#>
target x
make(
plan,
verbose = 2,
parallelism = "future",
jobs = 4L,
lock_envir = FALSE
)
#>
All targets are already up to date.
config <- drake_config(plan)
outdated(config)
#> character(0)
# Write _drake.R
drake_code <- quote({
source("packages.R")
source("functions.R")
source("plan.R")
drake_config(
plan,
verbose = 2,
jobs = 3L,
lock_envir = FALSE,
parallelism = "future"
)
})
writeLines(deparse(drake_code), "_drake.R")
# Run r_make()
r_make()
#>
#> ..
[34mAll targets are already up to date.[39m
r_make()
#>
#> .
[34mAll targets are already up to date.[39m
r_outdated()
#>
#> .
#> character(0)
由 reprex package (v0.3.0)
于 2019-09-13 创建
devtools::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#> setting value
#> version R version 3.6.1 (2019-07-05)
#> os Ubuntu 18.04.2 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2019-09-13
#>
#> ─ Packages ──────────────────────────────────────────────────────────────
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.1)
#> backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.1)
#> base64url 1.4 2018-05-14 [1] CRAN (R 3.6.1)
#> callr 3.3.1 2019-07-18 [1] CRAN (R 3.6.1)
#> cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.1)
#> codetools 0.2-16 2018-12-24 [1] CRAN (R 3.6.1)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.1)
#> data.table * 1.12.2 2019-04-07 [1] CRAN (R 3.6.1)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.1)
#> devtools 2.2.0 2019-09-07 [1] CRAN (R 3.6.1)
#> digest 0.6.20 2019-07-04 [1] CRAN (R 3.6.1)
#> drake * 7.6.1 2019-08-19 [1] CRAN (R 3.6.1)
#> DT 0.8 2019-08-07 [1] CRAN (R 3.6.1)
#> ellipsis 0.2.0.1 2019-07-02 [1] CRAN (R 3.6.1)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.1)
#> filelock 1.0.2 2018-10-05 [1] CRAN (R 3.6.1)
#> fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.1)
#> future 1.14.0 2019-07-02 [1] CRAN (R 3.6.1)
#> globals 0.12.4 2018-10-11 [1] CRAN (R 3.6.1)
#> glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.1)
#> highr 0.8 2019-03-20 [1] CRAN (R 3.6.1)
#> htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.6.1)
#> htmlwidgets 1.3 2018-09-30 [1] CRAN (R 3.6.1)
#> igraph 1.2.4.1 2019-04-22 [1] CRAN (R 3.6.1)
#> knitr 1.24 2019-08-08 [1] CRAN (R 3.6.1)
#> listenv 0.7.0 2018-01-21 [1] CRAN (R 3.6.1)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.1)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.1)
#> pillar 1.4.2 2019-06-29 [1] CRAN (R 3.6.1)
#> pkgbuild 1.0.5 2019-08-26 [1] CRAN (R 3.6.1)
#> pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.6.1)
#> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.1)
#> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.1)
#> processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.1)
#> ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.1)
#> R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.1)
#> Rcpp 1.0.2 2019-07-25 [1] CRAN (R 3.6.1)
#> remotes 2.1.0 2019-06-24 [1] CRAN (R 3.6.1)
#> rlang 0.4.0 2019-06-25 [1] CRAN (R 3.6.1)
#> rmarkdown 1.15 2019-08-21 [1] CRAN (R 3.6.1)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.1)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.1)
#> storr 1.2.1 2018-10-18 [1] CRAN (R 3.6.1)
#> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.1)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.1)
#> testthat 2.2.1 2019-07-25 [1] CRAN (R 3.6.1)
#> tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.1)
#> txtq 0.1.5 2019-08-19 [1] CRAN (R 3.6.1)
#> usethis 1.5.1 2019-07-04 [1] CRAN (R 3.6.1)
#> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.1)
#> xfun 0.9 2019-08-21 [1] CRAN (R 3.6.1)
#> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.1)
#>
#> [1] /home/landau/R/R-3.6.1/library
更新
请 运行 这个 reprex
你自己和 post 结果:
reprex::reprex({
library(drake)
# Write script files
package_code <- c(
"library(data.table)",
"library(drake)"
)
function_code <- c(
"make_data <- function(download_date){",
" data.table(",
" dt = download_date,",
" x = runif(n = 1e5),",
" y = sample(letters,size = 1e5,replace = T)",
" )",
"}"
)
plan_code <- c(
"plan <- drake_plan(",
" download_date = \"2019-09-08\",",
" x = make_data(download_date)",
")"
)
drake_code <- c(
"source(\"packages.R\")",
"source(\"functions.R\")",
"source(\"plan.R\")",
"drake_config(",
" plan,",
" verbose = 2,",
" jobs = 3L,",
" lock_envir = FALSE,",
" parallelism = \"future\",",
" console_log_file = \"r_make.log\"",
")"
)
writeLines(package_code, "packages.R")
writeLines(function_code, "functions.R")
writeLines(plan_code, "plan.R")
writeLines(drake_code, "_drake.R")
# Check that we wrote the scripts properly
cat(readLines("packages.R"), sep = "\n")
cat(readLines("functions.R"), sep = "\n")
cat(readLines("plan.R"), sep = "\n")
cat(readLines("_drake.R"), sep = "\n")
# Is there already .drake/ cache somewhere?
list.files()
find_cache()
# If so, this reprex is not clean.
for (i in seq_len(10)) {
clean(destroy = TRUE)
}
# Get ready
source("packages.R")
source("functions.R")
source("plan.R")
config <- drake_config(plan)
# Run make() and r_make()
make(
plan,
verbose = 2,
parallelism = "future",
jobs = 4L,
lock_envir = FALSE,
console_log_file = "make.log"
)
outdated(config)
r_make()
r_outdated()
make(
plan,
verbose = 2,
parallelism = "future",
jobs = 4L,
lock_envir = FALSE,
console_log_file = "make.log"
)
outdated(config)
r_make()
r_outdated()
# Check the log files to see what triggered the targets.
cat(readLines("make.log"), sep = "\n")
cat(readLines("r_make.log"), sep = "\n")
}, si = TRUE, venue = "so")
我发现了问题。我使用的是“2019-06-01”-ish 的 MRAN 快照。将所有软件包升级到 10 月 10 日的 MRAN 修复了所有问题。
我正在使用 RStudio 来完成相关工作。以前一直用drake::make()
忽略提示用r_make()
直到昨天决定试一试
现在,我有点不知所措。不确定我做了什么/如果我发现了错误。
我的项目计划不大,但目标构建很大(每次拉取 10-20 分钟的数据)。我已经 运行 使用来自 RStudio 控制台的 make()
端到端。一切都是最新的。即使我在终端中打开一个单独的 R
会话,并且 运行 outdated()
,我也没有看到任何过时的东西。
但是,从 Rstudio 控制台 运行ning r_make()
,或从 R
在单独的终端中导致许多目标已过时。
而且无论我运行r_make()
多少次,这些对象都没有更新。
我不知道如何进行。我想继续使用 r_make()
,但我卡住了。
更新
https://gitlab.com/rsangole/drake-test
处的可重现示例更新 2
运行ning @landau 的 reprex
示例,输出在这里。它工作正常,正如 Will 使用此脚本获得的那样:https://gitlab.com/rsangole/drake-test/snippets/1894934
然而...
如果我 运行 https://gitlab.com/rsangole/drake-test/blob/master/make.R 在 RStudio 的交互模式下,我可以重现我的情况。重现:
- 打开新的 Rstudio,清理环境
- 在 https://gitlab.com/rsangole/drake-test 中下载可重现的示例
- 运行 https://gitlab.com/rsangole/drake-test/blob/master/make.R
- 预期输出如 https://gitlab.com/rsangole/drake-test/snippets/1894937
甚至在将 drake
更新到最新的前沿版本后仍然出现同样的问题
如果我 运行 make.R
通过 zsh
中的 R
从而完全绕过 RStudio,也能够复制问题。
我创建了一个 reprex
using https://gitlab.com/rsangole/drake-test,但无法重现您所看到的内容。您使用 drake
的方式是否与以下代码不同?
library(drake)
# Write script files
package_code <- quote({
library(data.table)
library(drake)
})
function_code <- quote(
make_data <- function(download_date){
data.table(
dt = download_date,
x = runif(n = 1e5),
y = sample(letters,size = 1e5,replace = T)
)
}
)
plan_code <- quote(
plan <- drake_plan(
download_date = "2019-09-08",
x = make_data(download_date)
)
)
writeLines(deparse(package_code), "packages.R")
writeLines(deparse(function_code), "functions.R")
writeLines(deparse(plan_code), "plan.R")
# Run make()
source("packages.R")
source("functions.R")
source("plan.R")
make(
plan,
verbose = 2,
parallelism = "future",
jobs = 4L,
lock_envir = FALSE
)
#>
target download_date
#>
target x
make(
plan,
verbose = 2,
parallelism = "future",
jobs = 4L,
lock_envir = FALSE
)
#>
All targets are already up to date.
config <- drake_config(plan)
outdated(config)
#> character(0)
# Write _drake.R
drake_code <- quote({
source("packages.R")
source("functions.R")
source("plan.R")
drake_config(
plan,
verbose = 2,
jobs = 3L,
lock_envir = FALSE,
parallelism = "future"
)
})
writeLines(deparse(drake_code), "_drake.R")
# Run r_make()
r_make()
#>
#> ..
[34mAll targets are already up to date.[39m
r_make()
#>
#> .
[34mAll targets are already up to date.[39m
r_outdated()
#>
#> .
#> character(0)
由 reprex package (v0.3.0)
于 2019-09-13 创建devtools::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#> setting value
#> version R version 3.6.1 (2019-07-05)
#> os Ubuntu 18.04.2 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2019-09-13
#>
#> ─ Packages ──────────────────────────────────────────────────────────────
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.1)
#> backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.1)
#> base64url 1.4 2018-05-14 [1] CRAN (R 3.6.1)
#> callr 3.3.1 2019-07-18 [1] CRAN (R 3.6.1)
#> cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.1)
#> codetools 0.2-16 2018-12-24 [1] CRAN (R 3.6.1)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.1)
#> data.table * 1.12.2 2019-04-07 [1] CRAN (R 3.6.1)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.1)
#> devtools 2.2.0 2019-09-07 [1] CRAN (R 3.6.1)
#> digest 0.6.20 2019-07-04 [1] CRAN (R 3.6.1)
#> drake * 7.6.1 2019-08-19 [1] CRAN (R 3.6.1)
#> DT 0.8 2019-08-07 [1] CRAN (R 3.6.1)
#> ellipsis 0.2.0.1 2019-07-02 [1] CRAN (R 3.6.1)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.1)
#> filelock 1.0.2 2018-10-05 [1] CRAN (R 3.6.1)
#> fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.1)
#> future 1.14.0 2019-07-02 [1] CRAN (R 3.6.1)
#> globals 0.12.4 2018-10-11 [1] CRAN (R 3.6.1)
#> glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.1)
#> highr 0.8 2019-03-20 [1] CRAN (R 3.6.1)
#> htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.6.1)
#> htmlwidgets 1.3 2018-09-30 [1] CRAN (R 3.6.1)
#> igraph 1.2.4.1 2019-04-22 [1] CRAN (R 3.6.1)
#> knitr 1.24 2019-08-08 [1] CRAN (R 3.6.1)
#> listenv 0.7.0 2018-01-21 [1] CRAN (R 3.6.1)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.1)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.1)
#> pillar 1.4.2 2019-06-29 [1] CRAN (R 3.6.1)
#> pkgbuild 1.0.5 2019-08-26 [1] CRAN (R 3.6.1)
#> pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.6.1)
#> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.1)
#> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.1)
#> processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.1)
#> ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.1)
#> R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.1)
#> Rcpp 1.0.2 2019-07-25 [1] CRAN (R 3.6.1)
#> remotes 2.1.0 2019-06-24 [1] CRAN (R 3.6.1)
#> rlang 0.4.0 2019-06-25 [1] CRAN (R 3.6.1)
#> rmarkdown 1.15 2019-08-21 [1] CRAN (R 3.6.1)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.1)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.1)
#> storr 1.2.1 2018-10-18 [1] CRAN (R 3.6.1)
#> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.1)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.1)
#> testthat 2.2.1 2019-07-25 [1] CRAN (R 3.6.1)
#> tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.1)
#> txtq 0.1.5 2019-08-19 [1] CRAN (R 3.6.1)
#> usethis 1.5.1 2019-07-04 [1] CRAN (R 3.6.1)
#> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.1)
#> xfun 0.9 2019-08-21 [1] CRAN (R 3.6.1)
#> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.1)
#>
#> [1] /home/landau/R/R-3.6.1/library
更新
请 运行 这个 reprex
你自己和 post 结果:
reprex::reprex({
library(drake)
# Write script files
package_code <- c(
"library(data.table)",
"library(drake)"
)
function_code <- c(
"make_data <- function(download_date){",
" data.table(",
" dt = download_date,",
" x = runif(n = 1e5),",
" y = sample(letters,size = 1e5,replace = T)",
" )",
"}"
)
plan_code <- c(
"plan <- drake_plan(",
" download_date = \"2019-09-08\",",
" x = make_data(download_date)",
")"
)
drake_code <- c(
"source(\"packages.R\")",
"source(\"functions.R\")",
"source(\"plan.R\")",
"drake_config(",
" plan,",
" verbose = 2,",
" jobs = 3L,",
" lock_envir = FALSE,",
" parallelism = \"future\",",
" console_log_file = \"r_make.log\"",
")"
)
writeLines(package_code, "packages.R")
writeLines(function_code, "functions.R")
writeLines(plan_code, "plan.R")
writeLines(drake_code, "_drake.R")
# Check that we wrote the scripts properly
cat(readLines("packages.R"), sep = "\n")
cat(readLines("functions.R"), sep = "\n")
cat(readLines("plan.R"), sep = "\n")
cat(readLines("_drake.R"), sep = "\n")
# Is there already .drake/ cache somewhere?
list.files()
find_cache()
# If so, this reprex is not clean.
for (i in seq_len(10)) {
clean(destroy = TRUE)
}
# Get ready
source("packages.R")
source("functions.R")
source("plan.R")
config <- drake_config(plan)
# Run make() and r_make()
make(
plan,
verbose = 2,
parallelism = "future",
jobs = 4L,
lock_envir = FALSE,
console_log_file = "make.log"
)
outdated(config)
r_make()
r_outdated()
make(
plan,
verbose = 2,
parallelism = "future",
jobs = 4L,
lock_envir = FALSE,
console_log_file = "make.log"
)
outdated(config)
r_make()
r_outdated()
# Check the log files to see what triggered the targets.
cat(readLines("make.log"), sep = "\n")
cat(readLines("r_make.log"), sep = "\n")
}, si = TRUE, venue = "so")
我发现了问题。我使用的是“2019-06-01”-ish 的 MRAN 快照。将所有软件包升级到 10 月 10 日的 MRAN 修复了所有问题。