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

Unexpected output for dynamic target #1090

Closed
2 of 3 tasks
billdenney opened this issue Dec 4, 2019 · 1 comment
Closed
2 of 3 tasks

Unexpected output for dynamic target #1090

billdenney opened this issue Dec 4, 2019 · 1 comment
Assignees

Comments

@billdenney
Copy link
Contributor

Prework

Description

This is related to, but I think distinct from #1076.

When using the output of a dynamic target in a subsequent target, I get a hash of class drake_dynamic instead of the expected output that is a list of values.

Reproducible example

library(drake)
library(tibble)

plan <-
  drake_plan(
    foo=as.list(1:10),
    bar=target(NULL, dynamic=map(foo)),
    baz=tibble(a=bar),
    bat=tibble(b=readd(bar))
  )

make(plan)
#> target foo
#> dynamic bar
#> subtarget bar_dac543b9
#> subtarget bar_37ec99be
#> subtarget bar_e63637e0
#> subtarget bar_df839848
#> subtarget bar_b6855367
#> subtarget bar_9a0ff0f0
#> subtarget bar_61f501eb
#> subtarget bar_11c9d7ac
#> subtarget bar_edc2bd54
#> subtarget bar_a0fc5036
#> aggregate bar
#> target bat
#> target baz
readd(baz)$a
#>  [1] "88bfb3121fa29558" "88bfb3121fa29558" "88bfb3121fa29558" "88bfb3121fa29558"
#>  [5] "88bfb3121fa29558" "88bfb3121fa29558" "88bfb3121fa29558" "88bfb3121fa29558"
#>  [9] "88bfb3121fa29558" "88bfb3121fa29558"
#> attr(,"class")
#> [1] "drake_dynamic"
readd(bat)$b
#> [[1]]
#> [1] NA
#> 
#> [[2]]
#> [1] NA
#> 
#> [[3]]
#> [1] NA
#> 
#> [[4]]
#> [1] NA
#> 
#> [[5]]
#> [1] NA
#> 
#> [[6]]
#> [1] NA
#> 
#> [[7]]
#> [1] NA
#> 
#> [[8]]
#> [1] NA
#> 
#> [[9]]
#> [1] NA
#> 
#> [[10]]
#> [1] NA

Created on 2019-12-04 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       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/New_York            
#>  date     2019-12-04                  
#> 
#> - 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)
#>  callr         3.3.2   2019-09-22 [1] CRAN (R 3.6.1)
#>  cli           1.1.0   2019-03-19 [1] CRAN (R 3.6.1)
#>  crayon        1.3.4   2017-09-16 [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)
#>  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)
#>  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)
#>  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.4.0   2019-10-04 [1] CRAN (R 3.6.1)
#>  igraph        1.2.4.2 2019-11-27 [1] CRAN (R 3.6.1)
#>  knitr         1.26    2019-11-12 [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.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)
#>  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)
#>  remotes       2.1.0   2019-06-24 [1] CRAN (R 3.6.1)
#>  rlang         0.4.2   2019-11-23 [1] CRAN (R 3.6.1)
#>  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)
#>  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.0)
#>  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)
#>  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)
#>  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)
#>  yaml          2.2.0   2018-07-25 [1] CRAN (R 3.6.0)
#> 
#> [1] C:/Users/Bill Denney/Documents/R/win-library/3.6
#> [2] C:/Program Files/R/R-3.6.1/library

Expected result

readd(baz)$a == readd(bat)$b

Session info

End the reproducible example with a call to sessionInfo() in the same session (e.g. reprex(si = TRUE)) and include the output.

@wlandau
Copy link
Member

wlandau commented Dec 4, 2019

A dynamic (parent) target is just a vector of hashes by design. It's part of the implementation that makes it all work. If you use a dynamic target in the command for another target, what drake thinks you are really saying is that you want to iterate over the sub-targets. So the dynamic target should usually also go in map(), cross() or group(). In other words, downstream targets of dynamic targets should also be dynamic, except when you want to explicitly promote a group of sub-targets with readd().

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