finally add progressr support

This commit is contained in:
Patrick Schratz 2024-09-11 00:15:18 +02:00
commit b1898f357c
Signed by: pat-s
GPG key ID: 3C6318841EF78925

View file

@ -81,16 +81,12 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
cli::cli_alert("Building binaries for {.pkg {package_name[[1]]}} with tags {.field {tag}}.")
# Set up the progress handler
# progressr::handlers(global = TRUE)
# progressr::handlers("cli", "debug")
p <- progressr::progressor(along = tag)
# out <- progressr::with_progress({
# p <- progressr::progressor(along = tag)
future.apply::future_mapply(function(x, y) {
worker_fun <- function(x, y, p) {
p()
tryCatch(
{
# p()
dump <- build_single_tag(x, y, dir_out_bin, local_clone_dir,
platform = platform, debug = debug, force = force,
install_system_dependencies = install_system_dependencies,
@ -114,9 +110,11 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
store_build_metadata(x, y, platform, error_occurred = TRUE, force = TRUE, error = e$stderr)
}
)
}, package_name, tag, future.seed = TRUE)
}
# })
future.apply::future_mapply(worker_fun, package_name, tag,
future.seed = TRUE, MoreArgs = list(p)
)
total_build_time <- round(Sys.time() - t1, 2)
cli::cli_alert("Execution time ({.pkg {package_name[[1]]}}) ({length(tag)} tags): {.strong {total_build_time} {units(difftime(Sys.time(), t1))}}.")