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

Avoid dots in target name when .id is a character #847

Closed
joelnitta opened this issue Apr 17, 2019 · 4 comments
Closed

Avoid dots in target name when .id is a character #847

joelnitta opened this issue Apr 17, 2019 · 4 comments

Comments

@joelnitta
Copy link

Prework

Description

This is just a minor request.

Can we get rid of the periods in the target name when using a character vector for .id?

library(drake)

drake_plan(
  data = target(
    get_data(param1, param2, param3),
    transform = map(
      param1 = c(123, 456),
      param2 = c(7, 9),
      param3 = c('abc', 'xyz'),
      .id = param3
    )
  )
)
#> # A tibble: 2 x 2
#>   target     command                
#>   <chr>      <expr>                 
#> 1 data_.abc. get_data(123, 7, "abc")
#> 2 data_.xyz. get_data(456, 9, "xyz")

Created on 2019-04-17 by the reprex package (v0.2.1)

Session info
devtools::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.5.3 (2019-03-11)
#>  os       Debian GNU/Linux 9 (stretch)
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Etc/UTC                     
#>  date     2019-04-17                  
#> 
#> ─ Packages ──────────────────────────────────────────────────────────────
#>  package     * version    date       lib source                        
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 3.5.3)                
#>  backports     1.1.3      2018-12-14 [1] CRAN (R 3.5.3)                
#>  base64url     1.4        2018-05-14 [1] CRAN (R 3.5.3)                
#>  callr         3.2.0      2019-03-15 [1] CRAN (R 3.5.3)                
#>  cli           1.1.0      2019-03-19 [1] CRAN (R 3.5.3)                
#>  crayon        1.3.4      2017-09-16 [1] CRAN (R 3.5.3)                
#>  desc          1.2.0      2018-05-01 [1] CRAN (R 3.5.3)                
#>  devtools      2.0.1      2018-10-26 [1] CRAN (R 3.5.3)                
#>  digest        0.6.18     2018-10-10 [1] CRAN (R 3.5.3)                
#>  drake       * 7.0.0      2019-03-10 [1] CRAN (R 3.5.3)                
#>  evaluate      0.13       2019-02-12 [1] CRAN (R 3.5.3)                
#>  fansi         0.4.0      2018-10-05 [1] CRAN (R 3.5.3)                
#>  fs            1.2.7      2019-03-19 [1] CRAN (R 3.5.3)                
#>  glue          1.3.1      2019-03-12 [1] CRAN (R 3.5.3)                
#>  highr         0.8        2019-03-20 [1] CRAN (R 3.5.3)                
#>  htmltools     0.3.6      2017-04-28 [1] CRAN (R 3.5.3)                
#>  igraph        1.2.4      2019-02-13 [1] CRAN (R 3.5.3)                
#>  knitr         1.22       2019-03-08 [1] CRAN (R 3.5.3)                
#>  magrittr      1.5        2014-11-22 [1] CRAN (R 3.5.3)                
#>  memoise       1.1.0      2017-04-21 [1] CRAN (R 3.5.3)                
#>  pillar        1.3.1      2018-12-15 [1] CRAN (R 3.5.3)                
#>  pkgbuild      1.0.3      2019-03-20 [1] CRAN (R 3.5.3)                
#>  pkgconfig     2.0.2      2018-08-16 [1] CRAN (R 3.5.3)                
#>  pkgload       1.0.2      2018-10-29 [1] CRAN (R 3.5.3)                
#>  prettyunits   1.0.2      2015-07-13 [1] CRAN (R 3.5.3)                
#>  processx      3.3.0      2019-03-10 [1] CRAN (R 3.5.3)                
#>  ps            1.3.0      2018-12-21 [1] CRAN (R 3.5.3)                
#>  R6            2.4.0      2019-02-14 [1] CRAN (R 3.5.3)                
#>  Rcpp          1.0.1      2019-03-17 [1] CRAN (R 3.5.3)                
#>  remotes       2.0.2.9000 2019-03-31 [1] Github (r-lib/remotes@bc90281)
#>  rlang         0.3.3      2019-03-29 [1] CRAN (R 3.5.3)                
#>  rmarkdown     1.12       2019-03-14 [1] CRAN (R 3.5.3)                
#>  rprojroot     1.3-2      2018-01-03 [1] CRAN (R 3.5.3)                
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 3.5.3)                
#>  storr         1.2.1      2018-10-18 [1] CRAN (R 3.5.3)                
#>  stringi       1.4.3      2019-03-12 [1] CRAN (R 3.5.3)                
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 3.5.3)                
#>  testthat      2.0.1      2018-10-13 [1] CRAN (R 3.5.3)                
#>  tibble        2.1.1      2019-03-16 [1] CRAN (R 3.5.3)                
#>  usethis       1.4.0      2018-08-14 [1] CRAN (R 3.5.3)                
#>  utf8          1.1.4      2018-05-24 [1] CRAN (R 3.5.3)                
#>  withr         2.1.2      2018-03-15 [1] CRAN (R 3.5.3)                
#>  xfun          0.5        2019-02-20 [1] CRAN (R 3.5.3)                
#>  yaml          2.2.0      2018-07-25 [1] CRAN (R 3.5.3)                
#> 
#> [1] /usr/local/lib/R/site-library
#> [2] /usr/local/lib/R/library
@b-coli
Copy link

b-coli commented Apr 17, 2019

I'm also experiencing a related (?) issue where the dots introduced into target names prevents them from being loaded with loadd() (including a function get_data in same example as above so it can be built with make()). If I remove the "." at the end, loadd() works, and readd() works either way.

library(drake)

get_data <- function(param1, param2, param3) {
  paste0(param1, param2, param3)
}

plan <- drake_plan(
  data = target(
    get_data(param1, param2, param3),
    transform = map(
      param1 = c(123, 456),
      param2 = c(7, 9),
      param3 = c('abc', 'xyz'),
      .id = param3
    )
  )
)

make(plan)

outputs:

> plan
# A tibble: 2 x 2
  target     command                
  <chr>      <expr>                 
1 data_.abc. get_data(123, 7, "abc")
2 data_.xyz. get_data(456, 9, "xyz")
> loadd(data_.abc.)
Error in loadd(data_.abc.) : object 'data_.abc.' not found
> loadd(data_.abc)
> readd(data_.abc.)
[1] "1237abc"
> readd(data_.abc)
[1] "1237abc"

@wlandau
Copy link
Member

wlandau commented Apr 17, 2019

@joelnitta, I agree. Those quotes are an odd quirk of the DSL, and it makes sense to remove them. This will invalidate lots of targets, but the DSL is officially still experimental, so I think we are okay. Now fixed.

library(drake)
drake_plan(
  data = target(
    get_data(param1, param2, param3),
    transform = map(
      param1 = c(123, 456),
      param2 = c("x", "y"),
      param3 = c("abc", "xyz"),
      .id = c(param2, param3)
    )
  )
)
#> # A tibble: 2 x 2
#>   target     command                  
#>   <chr>      <expr>                   
#> 1 data_x_abc get_data(123, "x", "abc")
#> 2 data_y_xyz get_data(456, "y", "xyz")

Created on 2019-04-17 by the reprex package (v0.2.1)

@wlandau wlandau reopened this Apr 17, 2019
@wlandau wlandau closed this as completed Apr 17, 2019
@wlandau
Copy link
Member

wlandau commented Apr 17, 2019

@b-coli, sorry, but I cannot reproduce the error you were seeing. Hopefully you will encounter it less often now that the target names are simplified.

@b-coli
Copy link

b-coli commented Apr 17, 2019

This resolved the issue -- thanks!!!

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

3 participants