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

list output of dynamic target work #1103

Closed
3 tasks done
kendonB opened this issue Dec 10, 2019 · 1 comment
Closed
3 tasks done

list output of dynamic target work #1103

kendonB opened this issue Dec 10, 2019 · 1 comment
Assignees

Comments

@kendonB
Copy link
Contributor

kendonB commented Dec 10, 2019

Prework

Description

When I try to run bind_rows on a dynamic target without readd it fails.

Reproducible example

library(drake)
library(tidyverse)

plan <- drake_plan(
  foo = rep(list(iris), 4),
  bar = target(
    foo[[1]],
    dynamic = map(foo)
  ),
  bah = bind_rows(bar) %>% as_tibble()
)

make(plan)
#> target foo
#> dynamic bar
#> subtarget bar_45aef32a
#> subtarget bar_45aef32a_2
#> subtarget bar_45aef32a_3
#> subtarget bar_45aef32a_4
#> aggregate bar
#> target bah
#> fail bah
#> Error: Target `bah` failed. Call `diagnose(bah)` for details. Error message:
#>   Argument 1 must have names

# works
readd(bar) %>%
  bind_rows() %>% 
  as_tibble()
#> # A tibble: 600 x 5
#>    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#>           <dbl>       <dbl>        <dbl>       <dbl> <fct>  
#>  1          5.1         3.5          1.4         0.2 setosa 
#>  2          4.9         3            1.4         0.2 setosa 
#>  3          4.7         3.2          1.3         0.2 setosa 
#>  4          4.6         3.1          1.5         0.2 setosa 
#>  5          5           3.6          1.4         0.2 setosa 
#>  6          5.4         3.9          1.7         0.4 setosa 
#>  7          4.6         3.4          1.4         0.3 setosa 
#>  8          5           3.4          1.5         0.2 setosa 
#>  9          4.4         2.9          1.4         0.2 setosa 
#> 10          4.9         3.1          1.5         0.1 setosa 
#> # … with 590 more rows

Created on 2019-12-10 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.1 (2019-07-05)
#>  os       Ubuntu 18.04.3 LTS          
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language en_US                       
#>  collate  en_NZ.UTF-8                 
#>  ctype    en_NZ.UTF-8                 
#>  tz       Pacific/Auckland            
#>  date     2019-12-10                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date       lib source                      
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 3.6.1)              
#>  backports     1.1.5      2019-10-02 [1] CRAN (R 3.6.1)              
#>  base64url     1.4        2018-05-14 [1] CRAN (R 3.6.1)              
#>  broom         0.5.2      2019-04-07 [1] CRAN (R 3.6.1)              
#>  callr         3.4.0      2019-12-09 [1] CRAN (R 3.6.1)              
#>  cellranger    1.1.0      2016-07-27 [1] CRAN (R 3.6.1)              
#>  cli           2.0.0      2019-12-09 [1] CRAN (R 3.6.1)              
#>  colorspace    1.4-1      2019-03-18 [1] CRAN (R 3.6.1)              
#>  crayon        1.3.4      2017-09-16 [1] CRAN (R 3.6.1)              
#>  DBI           1.0.0      2018-05-02 [1] CRAN (R 3.6.1)              
#>  dbplyr        1.4.2      2019-06-17 [1] CRAN (R 3.6.1)              
#>  desc          1.2.0      2018-05-01 [1] CRAN (R 3.6.1)              
#>  devtools      2.2.1      2019-09-24 [1] CRAN (R 3.6.1)              
#>  digest        0.6.23     2019-11-23 [1] CRAN (R 3.6.1)              
#>  dplyr       * 0.8.3      2019-07-04 [1] CRAN (R 3.6.1)              
#>  drake       * 7.8.0      2019-12-02 [1] CRAN (R 3.6.1)              
#>  ellipsis      0.3.0      2019-09-20 [1] CRAN (R 3.6.1)              
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 3.6.1)              
#>  fansi         0.4.0      2018-10-05 [1] CRAN (R 3.6.1)              
#>  filelock      1.0.2      2018-10-05 [1] CRAN (R 3.6.1)              
#>  forcats     * 0.4.0      2019-02-17 [1] CRAN (R 3.6.1)              
#>  fs            1.3.1      2019-05-06 [1] CRAN (R 3.6.1)              
#>  generics      0.0.2      2018-11-29 [1] CRAN (R 3.6.1)              
#>  ggplot2     * 3.2.1      2019-08-10 [1] CRAN (R 3.6.1)              
#>  glue          1.3.1      2019-03-12 [1] CRAN (R 3.6.1)              
#>  gtable        0.3.0      2019-03-25 [1] CRAN (R 3.6.1)              
#>  haven         2.2.0      2019-11-08 [1] CRAN (R 3.6.1)              
#>  highr         0.8        2019-03-20 [1] CRAN (R 3.6.1)              
#>  hms           0.5.2      2019-10-30 [1] CRAN (R 3.6.1)              
#>  htmltools     0.4.0      2019-10-04 [1] CRAN (R 3.6.1)              
#>  httr          1.4.1      2019-08-05 [1] CRAN (R 3.6.1)              
#>  igraph        1.2.4.2    2019-11-27 [1] CRAN (R 3.6.1)              
#>  jsonlite      1.6        2018-12-07 [1] CRAN (R 3.6.1)              
#>  knitr         1.26       2019-11-12 [1] CRAN (R 3.6.1)              
#>  lattice       0.20-38    2018-11-04 [1] CRAN (R 3.5.1)              
#>  lazyeval      0.2.2      2019-03-15 [1] CRAN (R 3.6.1)              
#>  lifecycle     0.1.0      2019-08-01 [1] CRAN (R 3.6.1)              
#>  lubridate     1.7.4      2018-04-11 [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)              
#>  modelr        0.1.5      2019-08-08 [1] CRAN (R 3.6.1)              
#>  munsell       0.5.0      2018-06-12 [1] CRAN (R 3.6.1)              
#>  nlme          3.1-142    2019-11-07 [1] CRAN (R 3.6.1)              
#>  pillar        1.4.2      2019-06-29 [1] CRAN (R 3.6.1)              
#>  pkgbuild      1.0.6      2019-10-09 [1] CRAN (R 3.6.1)              
#>  pkgconfig     2.0.3      2019-09-22 [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)              
#>  purrr       * 0.3.3      2019-10-18 [1] CRAN (R 3.6.1)              
#>  R6            2.4.1      2019-11-12 [1] CRAN (R 3.6.1)              
#>  Rcpp          1.0.3      2019-11-08 [1] CRAN (R 3.6.1)              
#>  readr       * 1.3.1      2018-12-21 [1] CRAN (R 3.6.1)              
#>  readxl        1.3.1      2019-03-13 [1] CRAN (R 3.6.1)              
#>  remotes       2.1.0      2019-06-24 [1] CRAN (R 3.6.1)              
#>  reprex        0.3.0      2019-05-16 [1] CRAN (R 3.6.1)              
#>  rlang         0.4.2.9000 2019-12-04 [1] github (r-lib/rlang@1be25e7)
#>  rmarkdown     1.18       2019-11-27 [1] CRAN (R 3.6.1)              
#>  rprojroot     1.3-2      2018-01-03 [1] CRAN (R 3.6.1)              
#>  rvest         0.3.5      2019-11-08 [1] CRAN (R 3.6.1)              
#>  scales        1.1.0      2019-11-18 [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.3.1      2019-12-01 [1] CRAN (R 3.6.1)              
#>  tibble      * 2.1.3      2019-06-06 [1] CRAN (R 3.6.1)              
#>  tidyr       * 1.0.0      2019-09-11 [1] CRAN (R 3.6.1)              
#>  tidyselect    0.2.5      2018-10-11 [1] CRAN (R 3.6.1)              
#>  tidyverse   * 1.3.0      2019-11-21 [1] CRAN (R 3.6.1)              
#>  txtq          0.2.0      2019-10-15 [1] CRAN (R 3.6.1)              
#>  usethis       1.5.1      2019-07-04 [1] CRAN (R 3.6.1)              
#>  utf8          1.1.4      2018-05-24 [1] CRAN (R 3.6.1)              
#>  vctrs         0.2.0.9007 2019-12-10 [1] github (r-lib/vctrs@a3c4b54)
#>  withr         2.1.2      2018-03-15 [1] CRAN (R 3.6.1)              
#>  xfun          0.11       2019-11-12 [1] CRAN (R 3.6.1)              
#>  xml2          1.2.2      2019-08-09 [1] CRAN (R 3.6.1)              
#>  yaml          2.2.0      2018-07-25 [1] CRAN (R 3.6.1)              
#> 
#> [1] /media/bellk/DATADRIVE/Dropbox/projects_ac/climate_nz/renv/library/R-3.6/x86_64-pc-linux-gnu
#> [2] /tmp/RtmpWnAQWI/renv-system-library
#> [3] /usr/lib/R/library

Expected result

The bah target should be like the final df above.

@wlandau
Copy link
Member

wlandau commented Dec 10, 2019

This is a consequence of the design of the internals. Downstream targets of dynamic targets should also be dynamic except when you use readd() to get the actual values back. Related: #1064 and and #1090. I plan to discuss it in the manual (ropensci-books/drake#131) but have not gotten around to it yet.

library(drake)
library(tidyverse)

plan <- drake_plan(
  foo = rep(list(iris), 4),
  bar = target(
    foo[[1]],
    dynamic = map(foo)
  ),
  bah = bind_rows(readd(bar)) %>% as_tibble()
)

make(plan)
#> target foo
#> dynamic bar
#> subtarget bar_45aef32a
#> subtarget bar_45aef32a_2
#> subtarget bar_45aef32a_3
#> subtarget bar_45aef32a_4
#> aggregate bar
#> target bah

readd(bah)
#> # A tibble: 600 x 5
#>    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#>           <dbl>       <dbl>        <dbl>       <dbl> <fct>  
#>  1          5.1         3.5          1.4         0.2 setosa 
#>  2          4.9         3            1.4         0.2 setosa 
#>  3          4.7         3.2          1.3         0.2 setosa 
#>  4          4.6         3.1          1.5         0.2 setosa 
#>  5          5           3.6          1.4         0.2 setosa 
#>  6          5.4         3.9          1.7         0.4 setosa 
#>  7          4.6         3.4          1.4         0.3 setosa 
#>  8          5           3.4          1.5         0.2 setosa 
#>  9          4.4         2.9          1.4         0.2 setosa 
#> 10          4.9         3.1          1.5         0.1 setosa 
#> # … with 590 more rows

Created on 2019-12-09 by the reprex package (v0.3.0)

library(drake)
library(tidyverse)

plan <- drake_plan(
  foo = rep(list(iris), 4),
  bar = target(
    foo[[1]],
    dynamic = map(foo)
  ),
  bah = bind_rows(readd(bar)) %>% as_tibble()
)

make(plan)
#> target foo
#> dynamic bar
#> subtarget bar_45aef32a
#> subtarget bar_45aef32a_2
#> subtarget bar_45aef32a_3
#> subtarget bar_45aef32a_4
#> aggregate bar
#> target bah

readd(bah)
#> # A tibble: 600 x 5
#>    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#>           <dbl>       <dbl>        <dbl>       <dbl> <fct>  
#>  1          5.1         3.5          1.4         0.2 setosa 
#>  2          4.9         3            1.4         0.2 setosa 
#>  3          4.7         3.2          1.3         0.2 setosa 
#>  4          4.6         3.1          1.5         0.2 setosa 
#>  5          5           3.6          1.4         0.2 setosa 
#>  6          5.4         3.9          1.7         0.4 setosa 
#>  7          4.6         3.4          1.4         0.3 setosa 
#>  8          5           3.4          1.5         0.2 setosa 
#>  9          4.4         2.9          1.4         0.2 setosa 
#> 10          4.9         3.1          1.5         0.1 setosa 
#> # … with 590 more rows

Created on 2019-12-09 by the reprex package (v0.3.0)

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