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() always ends normally for quarto project even if there is error #103

Closed
7 tasks done
psychelzh opened this issue Aug 22, 2022 · 3 comments
Closed
7 tasks done

Comments

@psychelzh
Copy link

Prework

  • Read and agree to the code of conduct and contributing guidelines.
  • Confirm that your issue is a genuine bug in tarchetypes and not a known limitation, usage error, or issue from another package that tarchetypes depends on. If you are unsure, please submit a discussion thread instead.
  • If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
  • 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

The pipeline will always ends normally even if quarto_render() errored. When setting quiet = TRUE, users will not notice that!

Reproducible example

The pipeline ends normally.

targets::tar_dir({  # tar_dir() runs code from a temporary directory.
  # Unparameterized Quarto document:
  lines <- c(
    "---",
    "title: report.qmd source file",
    "output_format: html",
    "---",
    "Assume these lines are in report.qmd.",
    "```{r}",
    "stop()",
    "```"
  )
  writeLines(lines, "report.qmd")
  writeLines(
    c("project:", "  type: website"),
    "_quarto.yml"
  )
  # Include the report in a pipeline as follows.
  targets::tar_script({
    library(tarchetypes)
    list(
      tar_quarto(report, path = ".")
    )
  }, ask = FALSE)
  targets::tar_make()
})
#> • start target report
#> • built target report
#> • end pipeline: 1.76 seconds

Created on 2022-08-22 with reprex v2.0.2

But there is error (set quiet = FALSE):

targets::tar_dir({  # tar_dir() runs code from a temporary directory.
  # Unparameterized Quarto document:
  lines <- c(
    "---",
    "title: report.qmd source file",
    "output_format: html",
    "---",
    "Assume these lines are in report.qmd.",
    "```{r}",
    "stop()",
    "```"
  )
  writeLines(lines, "report.qmd")
  writeLines(
    c("project:", "  type: website"),
    "_quarto.yml"
  )
  # Include the report in a pipeline as follows.
  targets::tar_script({
    library(tarchetypes)
    list(
      tar_quarto(report, path = ".", quiet = F)
    )
  }, ask = FALSE)
  targets::tar_make()
})
#> • start target report
#> �[31m
#> 
#> processing file: report.qmd
#> �[39m  |                                                                              |                                                                      |   0%  |                                                                              |.......................                                               |  33%
#>   ordinary text without R code
#> 
#>   |                                                                              |...............................................                       |  67%
#> label: unnamed-chunk-1
#> �[31mQuitting from lines 7-8 (report.qmd) 
#> �[39m�[31mError in eval(expr, envir, enclos) : 
#> Calls: .main ... withVisible -> eval_with_user_handlers -> eval -> eval
#> �[39m
#> �[31mExecution halted
#> �[39m• built target report
#> • end pipeline: 1.81 seconds

Created on 2022-08-22 with reprex v2.0.2

Expected result

Errors should be signalled.

@wlandau
Copy link
Member

wlandau commented Aug 22, 2022

The problem is that Quarto on Windows is apparently not forwarding errors back to R.

lines <- c(
  "---",
  "title: report",
  "output_format: html",
  "---",
  "```{r}",
  "stop(\"this is an error\")",
  "```"
)
writeLines(lines, "report.qmd")
tryCatch({
    quarto::quarto_render("report.qmd", as_job = FALSE, quiet = TRUE)
    message("missed error")
  },
  error = function(condition) message("caught error")
)
#> missed error

Created on 2022-08-22 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.1 (2022-06-23 ucrt)
#>  os       Windows 10 x64 (build 19044)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United States.utf8
#>  ctype    English_United States.utf8
#>  tz       America/New_York
#>  date     2022-08-22
#>  pandoc   2.18 @ C:/Program Files/RStudio/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cli           3.3.0   2022-04-25 [1] CRAN (R 4.2.1)
#>  digest        0.6.29  2021-12-01 [1] CRAN (R 4.2.1)
#>  evaluate      0.16    2022-08-09 [1] CRAN (R 4.2.1)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.2.1)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.2.1)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.2.1)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.2.1)
#>  htmltools     0.5.3   2022-07-18 [1] CRAN (R 4.2.1)
#>  jsonlite      1.8.0   2022-02-22 [1] CRAN (R 4.2.1)
#>  knitr         1.39    2022-04-26 [1] CRAN (R 4.2.1)
#>  later         1.3.0   2021-08-18 [1] CRAN (R 4.2.1)
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.2.1)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.2.1)
#>  processx      3.7.0   2022-07-07 [1] CRAN (R 4.2.1)
#>  ps            1.7.1   2022-06-18 [1] CRAN (R 4.2.1)
#>  quarto        1.2     2022-07-06 [1] CRAN (R 4.2.1)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.2.1)
#>  Rcpp          1.0.9   2022-07-08 [1] CRAN (R 4.2.1)
#>  reprex        2.0.2   2022-08-17 [1] CRAN (R 4.2.1)
#>  rlang         1.0.4   2022-07-12 [1] CRAN (R 4.2.1)
#>  rmarkdown     2.15    2022-08-16 [1] CRAN (R 4.2.1)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.2.1)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.2.1)
#>  stringi       1.7.8   2022-07-11 [1] CRAN (R 4.2.1)
#>  stringr       1.4.1   2022-08-20 [1] CRAN (R 4.2.1)
#>  withr         2.5.0   2022-03-03 [1] CRAN (R 4.2.1)
#>  xfun          0.32    2022-08-10 [1] CRAN (R 4.2.1)
#>  yaml          2.3.5   2022-02-21 [1] CRAN (R 4.2.1)
#> 
#>  [1] C:/Users/landau/AppData/Local/R/win-library/4.2
#>  [2] C:/Program Files/R/R-4.2.1/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

@wlandau wlandau closed this as completed Aug 22, 2022
@wlandau
Copy link
Member

wlandau commented Aug 22, 2022

See quarto-dev/quarto-r#48

@psychelzh
Copy link
Author

psychelzh commented Aug 23, 2022

Seemingly this is solved in quarto 1.1! Thank you very much.

quarto check:

[>] Checking Quarto installation......OK
      Version: 1.1.113
      Path: C:\Users\psych\AppData\Local\Programs\Quarto\bin\
      CodePage: 936

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....(None)

      Unable to locate an installed version of Python 3.
      Install Python 3 from https://www.python.org/downloads/

[>] Checking R installation...........OK
      Version: 4.2.1
      Path: C:/PROGRA~1/R/R-42~1.1
      LibPaths:
        - C:/Users/psych/AppData/Local/R/win-library/4.2
        - C:/Program Files/R/R-4.2.1/library
      rmarkdown: 2.14

[>] Checking Knitr engine render......OK

New reprex:

targets::tar_dir({  # tar_dir() runs code from a temporary directory.
    # Unparameterized Quarto document:
    lines <- c(
        "---",
        "title: report.qmd source file",
        "output_format: html",
        "---",
        "Assume these lines are in report.qmd.",
        "```{r}",
        "stop()",
        "```"
    )
    writeLines(lines, "report.qmd")
    writeLines(
        c("project:", "  type: website"),
        "_quarto.yml"
    )
    # Include the report in a pipeline as follows.
    targets::tar_script({
        library(tarchetypes)
        list(
            tar_quarto(report, path = ".")
        )
    }, ask = FALSE)
    targets::tar_make()
})
#> • start target report
#> ✖ error target report
#> • end pipeline: 2.03 seconds
#> Error : ! System command 'quarto.cmd' failed
#> ✖ Problem with the pipeline.
#> Error:
#> ! problem with the pipeline.

Created on 2022-08-23 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.1 (2022-06-23 ucrt)
#>  os       Windows 10 x64 (build 22000)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  Chinese (Simplified)_China.utf8
#>  ctype    Chinese (Simplified)_China.utf8
#>  tz       Asia/Taipei
#>  date     2022-08-23
#>  pandoc   2.18 @ C:/Program Files/RStudio/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  backports     1.4.1   2021-12-13 [1] CRAN (R 4.2.0)
#>  base64url     1.4     2018-05-14 [1] CRAN (R 4.2.1)
#>  callr         3.7.1   2022-07-13 [1] CRAN (R 4.2.1)
#>  cli           3.3.0   2022-04-25 [1] CRAN (R 4.2.1)
#>  codetools     0.2-18  2020-11-04 [2] CRAN (R 4.2.1)
#>  data.table    1.14.2  2021-09-27 [1] CRAN (R 4.2.1)
#>  digest        0.6.29  2021-12-01 [1] CRAN (R 4.2.1)
#>  evaluate      0.16    2022-08-09 [1] CRAN (R 4.2.1)
#>  fansi         1.0.3   2022-03-24 [1] CRAN (R 4.2.1)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.2.1)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.2.1)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.2.1)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.2.1)
#>  htmltools     0.5.3   2022-07-18 [1] CRAN (R 4.2.1)
#>  igraph        1.3.4   2022-07-19 [1] CRAN (R 4.2.1)
#>  knitr         1.39    2022-04-26 [1] CRAN (R 4.2.1)
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.2.1)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.2.1)
#>  pillar        1.8.0   2022-07-18 [1] CRAN (R 4.2.1)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.2.1)
#>  processx      3.7.0   2022-07-07 [1] CRAN (R 4.2.1)
#>  ps            1.7.1   2022-06-18 [1] CRAN (R 4.2.1)
#>  purrr         0.3.4   2020-04-17 [1] CRAN (R 4.2.1)
#>  R.cache       0.16.0  2022-07-21 [1] CRAN (R 4.2.1)
#>  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.0  2022-06-28 [1] CRAN (R 4.2.1)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.2.1)
#>  reprex        2.0.1   2021-08-05 [1] CRAN (R 4.2.1)
#>  rlang         1.0.4   2022-07-12 [1] CRAN (R 4.2.1)
#>  rmarkdown     2.14    2022-04-25 [1] CRAN (R 4.2.1)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.2.1)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.2.1)
#>  stringi       1.7.8   2022-07-11 [1] CRAN (R 4.2.1)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.2.1)
#>  styler        1.7.0   2022-03-13 [1] CRAN (R 4.2.1)
#>  targets       0.13.1  2022-08-05 [1] CRAN (R 4.2.1)
#>  tibble        3.1.8   2022-07-22 [1] CRAN (R 4.2.1)
#>  tidyselect    1.1.2   2022-02-21 [1] CRAN (R 4.2.1)
#>  utf8          1.2.2   2021-07-24 [1] CRAN (R 4.2.1)
#>  vctrs         0.4.1   2022-04-13 [1] CRAN (R 4.2.1)
#>  withr         2.5.0   2022-03-03 [1] CRAN (R 4.2.1)
#>  xfun          0.32    2022-08-10 [1] CRAN (R 4.2.1)
#>  yaml          2.3.5   2022-02-21 [1] CRAN (R 4.2.1)
#> 
#>  [1] C:/Users/psych/AppData/Local/R/win-library/4.2
#>  [2] C:/Program Files/R/R-4.2.1/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

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