You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I thought it would be useful to add a method for updating the total on the fly.
But Why?
Here is an example use case:
already_processed <- rep(FALSE, 100)
pb <- progress_bar$new(
format = "[:bar] :current / :total :eta",
clear = FALSE, total = 100
)
for (i in 1:100) {
if (already_processed[i]) {
pb$tick(1)
next
}
Sys.sleep(1)
already_processed[i] <- TRUE
pb$tick(1)
}
This is a progress bar for 100 tasks, with each task taking a long time. It is set to one second here but it can be hours in real use. I'm using this to get an ETA.
When the code is run from scratch, it gives an accurate ETA.
However, when I break the loop midwhile because I need to pause it to take a look at it or do something else, say at i = 20, once I restart the code, it will give an inaccurate ETA because it instantaneously skipped the first already processed 20 tasks, throwing the prediction off.
As a workaround I am currently doing the below:
already_processed <- rep(FALSE, 100)
pb <- progress_bar$new(
format = "[:bar] :current / :total :eta",
clear = FALSE, total = 100
)
for (i in 1:100) {
if (already_processed[i]) {
pb$.__enclos_env__$private$total <-
pb$.__enclos_env__$private$total - 1
pb$tick(0)
next
}
Sys.sleep(1)
already_processed[i] <- TRUE
pb$tick(1)
}
which decreases the total for every already completed task. This gives an accurate ETA in the above scenario.
But pb$.__enclos_env__$private$total <- pb$.__enclos_env__$private$total - 1 is just.. ugly, so I propose making this into something like pb$change_total_by(-1). Or more properly pb$tick(1, exclude_from_eta = TRUE) could be nice.
Of course, I could do this in a way that sets the right amount of total at the time pb is first initialized. This is doable in this scenario but may not be always doable in every scenario.
The text was updated successfully, but these errors were encountered:
I believe this is already with the progress bars in the cli package, which we are focusing on currently, so it is unlikely that we'll implement it in the progress package.
Description
I thought it would be useful to add a method for updating the total on the fly.
But Why?
Here is an example use case:
This is a progress bar for 100 tasks, with each task taking a long time. It is set to one second here but it can be hours in real use. I'm using this to get an ETA.
When the code is run from scratch, it gives an accurate ETA.
However, when I break the loop midwhile because I need to pause it to take a look at it or do something else, say at
i = 20
, once I restart the code, it will give an inaccurate ETA because it instantaneously skipped the first already processed 20 tasks, throwing the prediction off.As a workaround I am currently doing the below:
which decreases the total for every already completed task. This gives an accurate ETA in the above scenario.
But
pb$.__enclos_env__$private$total <- pb$.__enclos_env__$private$total - 1
is just.. ugly, so I propose making this into something likepb$change_total_by(-1)
. Or more properlypb$tick(1, exclude_from_eta = TRUE)
could be nice.Of course, I could do this in a way that sets the right amount of
total
at the timepb
is first initialized. This is doable in this scenario but may not be always doable in every scenario.The text was updated successfully, but these errors were encountered: