cli icon indicating copy to clipboard operation
cli copied to clipboard

Progress bar should use `stderr()` inside knitr documents

Open hadley opened this issue 2 years ago • 4 comments
trafficstars

e.g. create an .Rmd that contains this and knitr it from the IDE:

```{r}
cli::cli_progress_bar(total = 20)
for (i in 1:20) {
  cli::cli_progress_update()
  Sys.sleep(0.2)
}
```

The progress bar should appear in the Render pane (i.e. stderr()) rather than appearing in the output. (And I'd expect it to only be updated every 3 seconds).

hadley avatar Feb 16 '23 17:02 hadley

Same problem when I deploy to connect: https://connect.rstudioservices.com/connect/#/apps/9d8f2425-7d4b-430f-b3b1-29b328d335da/logs/3028

hadley avatar Feb 16 '23 17:02 hadley

Somewhat related to this is that if the background thread if off, like in webR, then currently there are no (timed) progress updates. If we fix the update interval here, then we might as well fix that.

gaborcsardi avatar Feb 18 '23 07:02 gaborcsardi

I can only second this issue.

It would be really nice to be able to conveniently use progress bars in via purrr.

The knitrProgressBar package works, but of course a "direct" solution would be nicer.

Currently, I am using this work-around:

pb <- knitrProgressBar::progress_estimated(100)
purrr::walk(1:100, \(i) {
  Sys.sleep(0.03)
  knitrProgressBar::update_progress(pb)      
})

sebastian-gerdes avatar Sep 17 '23 18:09 sebastian-gerdes

Is there a workaround for this? like setting an option. I feel like it should hide in non-interactive output.

olivroy avatar Dec 05 '23 21:12 olivroy