reprex
我使用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 包(v0.3.0)于 2019 年 9 月 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
自己运行并发布结果:
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")