futureverse / futureverse/progressr

IDEA: Transform progress::progress_bar() updates to progression updates on the fly

Open
#54 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
299
Forks
11
PR merge metrics
No merged PRs in 30d

Description

Would it be possible to listen to `progress::progress_bar()` update messages and translate those into proper `progression` conditions? It looks tricky and would rely on knowing what output to expect from `progress_bar()`. For example,

```r
> library(progress)
> pb <- progress_bar$new(total = 10)
> msg <- NULL
> withCallingHandlers(invisible(pb$tick()), message = function(m) msg <<- m)
> str(msg)
NULL
> withCallingHandlers(invisible(pb$tick()), message = function(m) msg <<- m)
[=============>---------------------------------------------------------] 20%>
> str(msg)
List of 2
$ message: chr "[=============>---------------------------------------------------------] 20%"
$ call : NULL
- attr(*, "class")= chr [1:2] "message" "condition"
```

As a starter, if all `progress_bar()` calls would make use of the new `message_class`, then it would possible to identify progress_bar message from regular messages, e.g.
```r
> library(progress)
> pb <- progress_bar$new(total = 10, message_class = "progress_bar")
> msg <- NULL
> withCallingHandlers(invisible(pb$tick()), message = function(m) msg <<- m)
> str(msg)
NULL
> withCallingHandlers(invisible(pb$tick()), message = function(m) msg <<- m)
[=============>---------------------------------------------------------] 20%>
> str(msg)
List of 2
$ message: chr "[=============>---------------------------------------------------------] 20%"
$ call : NULL
- attr(*, "class")= chr [1:3] "progress_bar" "message" "condition"
```

Yet, it'll be hard to parse those message strings to reverse engineer the underlying progress state, especially since we don't know what `progress_bar(format = ...)` has been set. Although, we could possibly be able to infer it after having received a few updates.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.