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

Format of error message is wrong #66

Open
joelnitta opened this issue Feb 4, 2025 · 2 comments
Open

Format of error message is wrong #66

joelnitta opened this issue Feb 4, 2025 · 2 comments

Comments

@joelnitta
Copy link
Collaborator

joelnitta commented Feb 4, 2025

In Episode 6, Best Practices for targets Project Organization the error message that is output (intentionally, for demonstration purposes during the lesson) by targets stretches across multiple code chunks.

The relevant code is here:

```{r}
#| echo: FALSE
#| label: example-bad-pipeline-hide
#| error: true
tar_dir({
write_example_plan(chunk = "example-bad-pipeline-show")
tar_make()
})
```

Image

@joelnitta
Copy link
Collaborator Author

The actual error in R looks like this:

Error:
! targets::tar_make() error

── General debugging ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    • tar_errored()
    • tar_meta(fields = any_of("error"), complete_only = TRUE)
    • tar_workspace()
    • tar_workspaces()

── How to ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    • Debug: https://books.ropensci.org/targets/debugging.html
    • Help: https://books.ropensci.org/targets/help.html

── Last error message ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    duplicated target names: height

── Last error traceback ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    base::tryCatch(base::withCallingHandlers({ NULL base::saveRDS(base::do.c...
    tryCatchList(expr, classes, parentenv, handlers)
    tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), na...
    doTryCatch(return(expr), name, parentenv, handler)
    tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
    tryCatchOne(expr, names, parentenv, handlers[[1L]])
    doTryCatch(return(expr), name, parentenv, handler)
    base::withCallingHandlers({ NULL base::saveRDS(base::do.call(base::do.ca...
    base::saveRDS(base::do.call(base::do.call, base::c(base::readRDS("/var/f...
    base::do.call(base::do.call, base::c(base::readRDS("/var/folders/gp/h665...
    (function (what, args, quote = FALSE, envir = parent.frame()) { if (!is....
    (function (targets_function, targets_arguments, options, envir = NULL, s...
    tryCatch(out <- withCallingHandlers(targets::tar_callr_inner_try(targets...
    tryCatchList(expr, classes, parentenv, handlers)
    tryCatchOne(expr, names, parentenv, handlers[[1L]])
    doTryCatch(return(expr), name, parentenv, handler)
    withCallingHandlers(targets::tar_callr_inner_try(targets_function = targ...
    targets::tar_callr_inner_try(targets_function = targets_function, target...
    pipeline_from_list(targets)
    pipeline_from_list.default(targets)
    pipeline_init(out)
    pipeline_targets_init(targets, clone_targets)
    tar_assert_unique_targets(names)
    tar_throw_validate(message)
    tar_error(message = paste0(...), class = c("tar_condition_validate", "ta...
    rlang::abort(message = message, class = class, call = tar_empty_envir)
    signal_abort(cnd, .file)

@tobyhodges
Copy link
Member

tobyhodges commented Feb 4, 2025

Running knitr::knit('organization.Rmd') gives me an organization.md output that includes this:

[ ...snip... ]

You would get an error if you tried to run the equivalent targets pipeline:


``` r
tar_plan(
    height = 160,
    height = height / 2.54
)
```


```
## 
-

\

|

 
```

```
## 
```

```
## ── Debugging ─────────────────────────────────────────────────────────────────────────────────────────────────────
```

```
## 
```

```
## ── How to ────────────────────────────────────────────────────────────────────────────────────────────────────────
```

```
## 
```

```
## ── Last error message ────────────────────────────────────────────────────────────────────────────────────────────
```

```
## 
```

```
## ── Last error traceback ──────────────────────────────────────────────────────────────────────────────────────────
```

```
## Error:
## ! targets::tar_make() error
##     • tar_errored()
##     • tar_meta(fields = any_of("error"), complete_only = TRUE)
##     • tar_workspace()
##     • tar_workspaces()
##     • Debug: �]8;;https://books.ropensci.org/targets/debugging.html�https://books.ropensci.org/targets/debugging.html�]8;;�
##     • Help: �]8;;https://books.ropensci.org/targets/help.html�https://books.ropensci.org/targets/help.html�]8;;�
##     duplicated target names: height
##     base::tryCatch(base::withCallingHandlers({ NULL base::saveRDS(base::do.c...
##     tryCatchList(expr, classes, parentenv, handlers)
##     tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), na...
##     doTryCatch(return(expr), name, parentenv, handler)
##     tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
##     tryCatchOne(expr, names, parentenv, handlers[[1L]])
##     doTryCatch(return(expr), name, parentenv, handler)
##     base::withCallingHandlers({ NULL base::saveRDS(base::do.call(base::do.ca...
##     base::saveRDS(base::do.call(base::do.call, base::c(base::readRDS("/var/f...
##     base::do.call(base::do.call, base::c(base::readRDS("/var/folders/rj/3gf6...
##     (function (what, args, quote = FALSE, envir = parent.frame()) { if (!is....
##     (function (targets_function, targets_arguments, options, envir = NULL, s...
##     tryCatch(out <- withCallingHandlers(targets::tar_callr_inner_try(targets...
##     tryCatchList(expr, classes, parentenv, handlers)
##     tryCatchOne(expr, names, parentenv, handlers[[1L]])
##     doTryCatch(return(expr), name, parentenv, handler)
##     withCallingHandlers(targets::tar_callr_inner_try(targets_function = targ...
##     targets::tar_callr_inner_try(targets_function = targets_function, target...
##     pipeline_from_list(targets)
##     pipeline_from_list.default(targets)
##     pipeline_init(out)
##     pipeline_targets_init(targets, clone_targets)
##     tar_assert_unique_targets(names)
##     tar_throw_validate(message)
##     tar_error(message = paste0(...), class = c("tar_condition_validate", "ta...
##     rlang::abort(message = message, class = class, call = tar_envir_base)
##     signal_abort(cnd, .file)
```

[... snip ...]

I may be wrong, but my interpretation of this is that the issue is not specific to sandpaper exactly: there is something that knitr does not like about the output of that code chunk, which causes incorrect Markdown to be built from the R Markdown...

Fair to say that I do not have a complete understanding of targets, knitr, or sandpaper but, if I had to place a bet, I predict that the problem stems from the links in the error message (note the character encoding errors next to "Debug" and "Help" in the output...)

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