-
Notifications
You must be signed in to change notification settings - Fork 76
Description
Prework
- Read and agree to the code of conduct and contributing guidelines.
- Confirm that your issue is a genuine bug in the
targets
package itself and not a user error, known limitation, or issue from another package thattargets
depends on. For example, if you get errors runningtar_make_clustermq()
, try isolating the problem in a reproducible example that runsclustermq
and nottargets
. And for miscellaneous troubleshooting, please post to discussions instead of issues. - If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
- Using
targets::tar_reprex()
,reprex::reprex()
, or similar, post a minimal reproducible example like this one so the maintainer can troubleshoot the problems you identify. A reproducible example is:- Runnable: post enough R code and data so any onlooker can create the error on their own computer.
- Minimal: reduce runtime wherever possible and remove complicated details that are irrelevant to the issue at hand.
- Readable: format your code according to the tidyverse style guide.
Description
Target names generated with glue::glue()
(or other software that may add attributes to character data) will not pass tar_assert_name()
. From ropensci-books/targets@d79ceb0 it's clear that the intention is for target names to be syntactically valid, which is fine. However the check in identical(name, make.names(name))
seems to be too stringent. Since there is a character type assertion earlier, wouldn't it be okay to pass name
through as.character()
(or some other routine to strip the attributes)?
e.g.
name <- glue::glue("glue_made_tarname")
identical(as.character(name), make.names(name))
#> [1] TRUE
Created on 2022-02-02 by the reprex package (v2.0.1)
Reproducible example
targets::tar_target_raw(
glue::glue("glue_made_tarname"),
print("hello world")
)
#> Error: glue_made_tarname is not a valid symbol name.
Created on 2022-02-02 by the reprex package (v2.0.1)
Expected result
Although glue::glue("string")
may have different attributes than "string"
, targets::tar_target_raw(glue::glue("string"))
should have be able to generate the target.
Diagnostic information
sessionInfo()
#> R version 4.1.0 (2021-05-18)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Big Sur 10.16
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> loaded via a namespace (and not attached):
#> [1] knitr_1.37 magrittr_2.0.1 rlang_0.4.12 fansi_0.4.2
#> [5] stringr_1.4.0 styler_1.4.1 highr_0.8 tools_4.1.0
#> [9] xfun_0.29 utf8_1.2.1 withr_2.4.1 htmltools_0.5.1.1
#> [13] ellipsis_0.3.1 yaml_2.2.1 digest_0.6.27 tibble_3.1.0
#> [17] lifecycle_1.0.0 crayon_1.4.1 purrr_0.3.4 vctrs_0.3.7
#> [21] fs_1.5.0 glue_1.4.2 evaluate_0.14 rmarkdown_2.7
#> [25] reprex_2.0.1 stringi_1.5.3 compiler_4.1.0 pillar_1.5.1
#> [29] backports_1.2.1 pkgconfig_2.0.3
Created on 2022-02-02 by the reprex package (v2.0.1)