0

最近在德雷克计划上运行 make() 后,我注意到我给其中一个目标指定了错误的名称。不幸的是,这也恰好是运行时间较长的目标之一。有没有办法在德雷克计划中重命名目标而不导致目标过时?

4

2 回答 2

1

编辑 2019-07-23

现在可以在最新的 CRAN 版本 (7.5.2) 中重命名。有关详细信息,请参阅https://github.com/ropensci/drake/blob/master/README.md#reproducible-data-recovery-and-renaming

编辑 2019-07-18

实际上,在某些情况下,重命名可能是个好主意。在https://github.com/ropensci/drake/pull/952之后,drake将支持通过make(recover = TRUE). 但是,默认情况下它将被禁用,您必须使用与上次相同的目标种子。

编辑 2019-07-16

不幸的是,重命名目标在drake本质上是有问题的。如果您在可重现的工作流程中生成随机数,请不要尝试重命名目标。

为什么?因为随机数生成器 (RNG) 种子。seed每个目标的 RNG 种子是根据目标名称和全局种子(的参数)确定性计算的make()。所以如果你重命名目标,你改变了种子应该是什么,这会使目标的值无效。

原帖

等等……居然办法!请参阅https://github.com/ropensci/drake/issues/935。只要知道重命名目标下游的目标很可能会失效。防止下游失效是极其困难的部分,我不太可能实现它。

library(drake)

plan <- drake_plan(
  temp = target(
    matrix(runif(10 ^ 3) + t, ncol = 5),
    transform = map(t = c(2, 5))
  )
)

config <- drake_config(plan)
make(plan)
#> target temp_2
#> target temp_5
outdated(config)
#> character(0)

plan <- drake_plan(
  temp = target(
    matrix(runif(10 ^ 3) + t, ncol = ncol),
    transform = cross(
      ncol = c(5, 2), # Let's switch the order of ncol and t.
      t = c(2, 5)
    )
  )
)

# All 4 targets are out of date because the names are different.
config <- drake_config(plan)

# ncol is the first index.
outdated(config)
#> [1] "temp_2_2" "temp_2_5" "temp_5_2" "temp_5_5"

# Let's rename the original targets.
for (ns in c("objects", "meta")) {
  config$cache$duplicate("temp_2", "temp_5_2", namespace = ns)
  config$cache$duplicate("temp_5", "temp_5_5", namespace = ns)
}

outdated(config)
#> [1] "temp_2_2" "temp_2_5"
make(plan)
#> target temp_2_2
#> target temp_2_5

reprex 包(v0.3.0)于 2019 年 7 月 10 日创建

于 2019-07-10T10:51:37.043 回答
0

drake目前没有这样的功能。这并非不可能,但实施起来将极具挑战性和复杂性。不过我会考虑的。这是一个好主意,我肯定看到了实用程序。

于 2019-06-28T00:10:58.157 回答