Closed tripartio closed 8 months ago
This is a limitation in R that progressr cannot work around. It's possible that knitr can provide a workaround. I've posted "WISH: Make it possible to call globalCallingHandlers() in a chunk" (https://github.com/yihui/knitr/issues/2324) to propose this.
Forgot to say:
As far as I can tell,
progressr::handlers(global = TRUE)
is for interactive use.
No, it's not only for interactive use. It also works in batch mode, e.g. Rscript script.R
. The problem is that it does not work when called within things such as withCallingHandlers()
, tryCatch()
, ..., and that's the problem in several case, including knitr, rmarkdown, etc.
@HenrikBengtsson Thanks for the response. Oh well.
So, I'll do the next best thing: in every vignette and website article, before loading my package, I briefly explain to users how to activate the package. But I place these in Rmd with the eval = FALSE
chunk option, like so:
```{r enable progressr, eval = FALSE} progressr::handlers(global = TRUE) progressr::handlers('cli') ```
It's not quite ideal, but the trade-off for getting to use your great package is worth it. Thanks again!
In trying to demonstrate the functionality of my package to users, I want to make progress bars as invisible as possible. Yet, using the fantastic progressr implementation, I need to show users how to activate global handling of progress bars. But how can I do this in an R Markdown (Rmd) file for a vignette? Even this very minimal example crashes:
In the [progressr] package documentation, we are told "In such cases, the global progress handler has to be enabled prior to processing the document, e.g."
But how is that possible in standard package documentation? As far as I can tell,
progressr::handlers(global = TRUE)
is for interactive use. I do not see how a package developer can easily communicate this information to their package users. I would appreciate any help with this.