如何参考德雷克先前的目标? [英] How to refer to previous targets in drake?

查看:67
本文介绍了如何参考德雷克先前的目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用通配符生成一堆目标,然后使用另一组目标引用那些原始目标.我认为这个例子代表了我的想法:

I would like to use the wildcard to generate a bunch of targets, and then have another set of targets that refers to those original targets. I think this example represents my idea:

plan <- drake_plan(
  sub_task = runif(1000, min = mean__, max = 50),
  full_task = sub_task * 2
)
step <- 1:4

full_plan <- evaluate_plan(
  plan,
  rules = list(
    mean__ = step
  ) 
)

所以我现在得到的是5个目标,4个子任务和一个final_task.我正在寻找的是获得8个目标. 4个子任务(很好),还有4个基于这4个好的子任务.

So what I get now is 5 targets, 4 sub_tasks and a single final_task. What I'm looking for is to get 8 targets. The 4 sub_tasks (that are good), and 4 more that are based on those 4 good sub_tasks.

推荐答案

这个问题经常出现,我喜欢您的措辞.

This question comes up regularly, and I like how you phrased it.

对于围观者,我将打印出当前(有问题的)工作流程的计划和图表.

For onlookers, I will print out the plan and the graph of the current (problematic) workflow.

library(drake)
plan <- drake_plan(
  sub_task = runif(1000, min = mean__, max = 50),
  full_task = sub_task * 2
)
step <- 1:4
full_plan <- evaluate_plan(
  plan,
  rules = list(
    mean__ = step
  ) 
)

full_plan
#> # A tibble: 5 x 2
#>   target     command                       
#>   <chr>      <chr>                         
#> 1 sub_task_1 runif(1000, min = 1, max = 50)
#> 2 sub_task_2 runif(1000, min = 2, max = 50)
#> 3 sub_task_3 runif(1000, min = 3, max = 50)
#> 4 sub_task_4 runif(1000, min = 4, max = 50)
#> 5 full_task  sub_task * 2

config <- drake_config(full_plan)
vis_drake_graph(config)

reprex软件包(v0.2.1)于2018年12月18日创建

Created on 2018-12-18 by the reprex package (v0.2.1)

正如您所说,我们希望full_task_*个目标依赖于它们相应的single_task_*个目标.为此,我们还需要在full_task_*命令中使用mean__通配符.通配符是基于文本替换的早期接口,因此它们本身不必是独立变量名.

As you say, we want full_task_* targets that depend on their corresponding single_task_* targets. to accomplish this, we need to use the mean__ wildcard in the full_task_* commands as well. Wildcards are an early-days interface based on text replacement, so they do not need to be independent variable names in their own right.

library(drake)
plan <- drake_plan(
  sub_task = runif(1000, min = mean__, max = 50),
  full_task = sub_task_mean__ * 2
)
step <- 1:4
full_plan <- evaluate_plan(
  plan,
  rules = list(
    mean__ = step
  ) 
)

full_plan
#> # A tibble: 8 x 2
#>   target      command                       
#>   <chr>       <chr>                         
#> 1 sub_task_1  runif(1000, min = 1, max = 50)
#> 2 sub_task_2  runif(1000, min = 2, max = 50)
#> 3 sub_task_3  runif(1000, min = 3, max = 50)
#> 4 sub_task_4  runif(1000, min = 4, max = 50)
#> 5 full_task_1 sub_task_1 * 2                
#> 6 full_task_2 sub_task_2 * 2                
#> 7 full_task_3 sub_task_3 * 2                
#> 8 full_task_4 sub_task_4 * 2

config <- drake_config(full_plan)
vis_drake_graph(config)

reprex软件包(v0.2.1)于2018年12月18日创建

Created on 2018-12-18 by the reprex package (v0.2.1)

这篇关于如何参考德雷克先前的目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆