futureverse / futureverse/progressr
Creating a progressor object outside `with_progress()`?
- Dominant language
- R
- Stars
- 299
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
So I've deprecated `.progress` in furrr, and was planning on writing a vignette on using progressr.
My first thought was to create an example like the one below, but it errors. It seems like the `progressor()` call _must_ be called from within `with_progress()`. Is that right? I tried to look around for documentation about this but I can't find anything, maybe I'm just missing it.
I know there is a developer/user separation of the APIs, but as of right now I think that this is how users might want to construct progress enabled functions to pass to `future_map()`. Does this seem reasonable?
```r
library(progressr)
#> Warning: package 'progressr' was built under R version 4.0.2
library(purrr)
set.seed(123)
x <- replicate(n = 10, runif(20), simplify = FALSE)
p <- progressor(steps = length(x))
slow_fn <- function(x) {
p()
Sys.sleep(.1)
sum(x)
}
with_progress({
map(x, slow_fn)
})
#> Error in error("length(timestamp) == 0L") :
#> .validate_internal_state(‘handler(type=update) ... end’): length(timestamp) == 0L
#> Error in error("length(timestamp) == 0L") :
#> .validate_internal_state(‘reporter_args() ... begin’): length(timestamp) == 0L
```
Contributor guide
Assessment
This issue has not been assessed yet.