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

tar_quarto_rep doesn't work on reports in subdirectories #144

Closed
1 task done
joelnitta opened this issue Apr 12, 2023 · 2 comments
Closed
1 task done

tar_quarto_rep doesn't work on reports in subdirectories #144

joelnitta opened this issue Apr 12, 2023 · 2 comments

Comments

@joelnitta
Copy link

Discussed in ropensci/targets#1046

Originally posted by joelnitta April 12, 2023

Help

Description

This is a slight modification of the example code for tar_quarto_rep() that puts the Qmd file in a subdirectory. It results in an error ERROR: --output option cannot specify a relative or absolute path

targets::tar_dir({ # tar_dir() runs code from a temporary directory.
# Parameterized Quarto:
lines <- c(
  "---",
  "title: 'report.qmd file'",
  "output_format: html_document",
  "params:",
  "  par: \"default value\"",
  "---",
  "Assume these lines are in a file called report.qmd.",
  "```{r}",
  "print(params$par)",
  "```"
)
dir.create("reports/")
writeLines(lines, "reports/report.qmd") # In tar_dir(), not the user's file space.
# The following pipeline will run the report for each row of params.
targets::tar_script({
  library(tarchetypes)
  list(
    tar_quarto_rep(
      report,
      path = "reports/report.qmd",
      execute_params = tibble::tibble(par = c(1, 2)),
      quiet = FALSE
    )
  )
}, ask = FALSE)
targets::tar_make()
# Then, run the targets pipeline as usual.
})
#> • start target report_params
#> • built target report_params [0.007 seconds]
#> • start branch report_c45b815a
#> �[91mERROR: --output option cannot specify a relative or absolute path�[39m
#> ✖ error branch report_c45b815a
#> • end pipeline [0.435 seconds]
#> Error:
#> ! Error running targets::tar_make()
#>   Error messages: targets::tar_meta(fields = error, complete_only = TRUE)
#>   Debugging guide: https://books.ropensci.org/targets/debugging.html
#>   How to ask for help: https://books.ropensci.org/targets/help.html
#>   Last error: ! ! System command 'quarto' failed

#> Backtrace:
#>     ▆
#>  1. └─targets::tar_make()
#>  2.   └─targets:::callr_outer(...)
#>  3.     ├─targets:::if_any(...)
#>  4.     └─targets:::callr_error(condition = out, fun = fun)
#>  5.       └─targets::tar_throw_run(message, class = class(condition))
#>  6.         └─targets::tar_error(...)
#>  7.           └─rlang::abort(message = message, class = class, call = tar_empty_envir)

Created on 2023-04-12 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.3 (2023-03-15)
#>  os       macOS Big Sur ... 10.16
#>  system   x86_64, darwin17.0
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Asia/Tokyo
#>  date     2023-04-12
#>  pandoc   2.19.2 @ /usr/local/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version date (UTC) lib source
#>  P backports     1.4.1   2021-12-13 [?] CRAN (R 4.2.0)
#>  P base64url     1.4     2018-05-14 [?] CRAN (R 4.2.0)
#>  P callr         3.7.2   2022-08-22 [?] CRAN (R 4.2.0)
#>  P cli           3.4.1   2022-09-23 [?] CRAN (R 4.2.0)
#>  P codetools     0.2-19  2023-02-01 [3] CRAN (R 4.2.3)
#>  P data.table    1.14.4  2022-10-17 [?] CRAN (R 4.2.1)
#>  P digest        0.6.30  2022-10-18 [?] CRAN (R 4.2.1)
#>  P evaluate      0.17    2022-10-07 [?] CRAN (R 4.2.1)
#>  P fansi         1.0.3   2022-03-24 [?] CRAN (R 4.2.0)
#>  P fastmap       1.1.0   2021-01-25 [?] CRAN (R 4.2.0)
#>  P fs            1.5.2   2021-12-08 [?] CRAN (R 4.2.0)
#>  P glue          1.6.2   2022-02-24 [?] CRAN (R 4.2.0)
#>  P highr         0.9     2021-04-16 [?] CRAN (R 4.2.0)
#>    htmltools     0.5.5   2023-03-23 [1] CRAN (R 4.2.0)
#>  P igraph        1.3.5   2022-09-22 [?] CRAN (R 4.2.0)
#>  P knitr         1.40    2022-08-24 [?] CRAN (R 4.2.0)
#>  P lifecycle     1.0.3   2022-10-07 [?] CRAN (R 4.2.0)
#>  P magrittr      2.0.3   2022-03-30 [?] CRAN (R 4.2.0)
#>  P pillar        1.8.1   2022-08-19 [?] CRAN (R 4.2.0)
#>  P pkgconfig     2.0.3   2019-09-22 [?] CRAN (R 4.2.0)
#>  P processx      3.8.0   2022-10-26 [?] CRAN (R 4.2.0)
#>  P ps            1.7.2   2022-10-26 [?] CRAN (R 4.2.0)
#>  P purrr         0.3.5   2022-10-06 [?] CRAN (R 4.2.0)
#>    R.cache       0.16.0  2022-07-21 [1] CRAN (R 4.2.0)
#>    R.methodsS3   1.8.2   2022-06-13 [1] CRAN (R 4.2.0)
#>    R.oo          1.25.0  2022-06-12 [1] CRAN (R 4.2.0)
#>    R.utils       2.12.2  2022-11-11 [1] CRAN (R 4.2.0)
#>  P R6            2.5.1   2021-08-19 [?] CRAN (R 4.2.0)
#>  P reprex        2.0.2   2022-08-17 [?] CRAN (R 4.2.0)
#>  P rlang         1.0.6   2022-09-24 [?] CRAN (R 4.2.0)
#>  P rmarkdown     2.17    2022-10-07 [?] CRAN (R 4.2.0)
#>    sessioninfo   1.2.2   2021-12-06 [3] CRAN (R 4.2.0)
#>  P stringi       1.7.8   2022-07-11 [?] CRAN (R 4.2.0)
#>  P stringr       1.4.1   2022-08-20 [?] CRAN (R 4.2.0)
#>    styler        1.8.1   2022-11-07 [1] CRAN (R 4.2.0)
#>  P targets       0.14.3  2023-03-08 [?] CRAN (R 4.2.0)
#>  P tibble        3.1.8   2022-07-22 [?] CRAN (R 4.2.0)
#>  P tidyselect    1.2.0   2022-10-10 [?] CRAN (R 4.2.0)
#>  P utf8          1.2.2   2021-07-24 [?] CRAN (R 4.2.0)
#>  P vctrs         0.5.0   2022-10-22 [?] CRAN (R 4.2.0)
#>  P withr         2.5.0   2022-03-03 [?] CRAN (R 4.2.0)
#>  P xfun          0.34    2022-10-18 [?] CRAN (R 4.2.1)
#>  P yaml          2.3.6   2022-10-18 [?] CRAN (R 4.2.1)
#> 
#>  [1] /Users/joelnitta/repos/ppg-import/renv/library/R-4.2/x86_64-apple-darwin17.0
#>  [2] /Users/joelnitta/repos/ppg-import/renv/sandbox/R-4.2/x86_64-apple-darwin17.0/84ba8b13
#>  [3] /Library/Frameworks/R.framework/Versions/4.2/Resources/library
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────
@joelnitta joelnitta changed the title [help] tar_quarto_rep doesn't work on reports in subdirectories tar_quarto_rep doesn't work on reports in subdirectories Apr 12, 2023
@wlandau
Copy link
Collaborator

wlandau commented Apr 12, 2023

This was an issue in tarchetypes which I fixed in 68e9ea1. Just in case, I tried your example again, and it turns out I also needed dde6288 to send the output files to the right place when the source document is also in a subdirectory.

@wlandau wlandau closed this as completed Apr 12, 2023
@joelnitta
Copy link
Author

Ah sorry I should have posted to {tarchetypes}. Installing the dev version of {tarchetypes} fixes it. Thanks!

@wlandau wlandau transferred this issue from ropensci/targets Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants