Open
Description
cli_progress_step()
is an excellent solution for easy-to-use progress updates, so first thank you!
Do you have any recommendations about how to handle nested progress steps? I find that the progress steps work well when called linearly, but when nested the outer steps don't always perform as expected. On CI logs (like GHA) the outer steps are repeated with every progress bar update, and interactively sometimes the outer step isn't displayed.
library(cli)
outer <- function(batches = 1:2) {
for (batch in batches) {
cli_progress_step("Batch {batch}")
Sys.sleep(0.25)
inner(batch)
}
}
inner <- function(batch) {
cli_progress_step("Batch {batch} step 1")
Sys.sleep(runif(1))
cli_progress_step("Batch {batch} step 2")
Sys.sleep(runif(1))
}
When called locally, I see something like this. Notice the missing Batch 1
updates.
outer(1:2)
#> ✔ Batch 1 step 1 [404ms]
#> ✔ Batch 1 step 2 [1s]
#> ✔ Batch 2 [1.8s]
#> ✔ Batch 2 step 1 [203ms]
#> ✔ Batch 2 step 2 [675ms]
#> ✔ Batch 2 [1.2s]
On CI, I see something like this:
outer(1:2)
#> ℹ Batch 1
#> ℹ Batch 1 step 1
#> ✔ Batch 1 step 1 [244ms]
#>
#> ℹ Batch 1
#> ℹ Batch 1 step 2
#> ✔ Batch 1 step 2 [975ms]
#>
#> ℹ Batch 1
#> ✔ Batch 2 [1.5s]
#>
#> ℹ Batch 2
#> ℹ Batch 2 step 1
#> ✔ Batch 2 step 1 [946ms]
#>
#> ℹ Batch 2
#> ℹ Batch 2 step 2
#> ✔ Batch 2 step 2 [27ms]
#>
#> ℹ Batch 2
#> ✔ Batch 2 [1.3s]
I'd really like to achieve something closer to this:
outer(1:2)
#> ℹ Batch 1
#> ℹ Batch 1 step 1
#> ✔ Batch 1 step 1 [244ms]
#> ℹ Batch 1 step 2
#> ✔ Batch 1 step 2 [975ms]
#> ✔ Batch 2 [1.5s]
#> ℹ Batch 2
#> ℹ Batch 2 step 1
#> ✔ Batch 2 step 1 [946ms]
#> ℹ Batch 2 step 2
#> ✔ Batch 2 step 2 [27ms]
#> ✔ Batch 2 [1.3s]