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

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

Open
HenrikBengtsson opened this issue Jun 14, 2019 · 0 comments

Comments

@HenrikBengtsson
Copy link
Collaborator

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,

> 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.

> 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.

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

1 participant