improve debug mode, use progress instead of cli progress report mode
This commit is contained in:
parent
0dedbdf060
commit
a3ca51c231
2 changed files with 20 additions and 6 deletions
|
|
@ -12,6 +12,7 @@ Imports:
|
||||||
dplyr,
|
dplyr,
|
||||||
future,
|
future,
|
||||||
future.apply,
|
future.apply,
|
||||||
|
future.callr,
|
||||||
gert,
|
gert,
|
||||||
lubridate,
|
lubridate,
|
||||||
magrittr,
|
magrittr,
|
||||||
|
|
|
||||||
|
|
@ -97,11 +97,16 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
|
||||||
rscript_startup = quote(options(crayon.enabled = TRUE))
|
rscript_startup = quote(options(crayon.enabled = TRUE))
|
||||||
)
|
)
|
||||||
|
|
||||||
progressr::handlers("cli")
|
# 'cli' is slow -> https://github.com/HenrikBengtsson/progressr/issues/167
|
||||||
|
if (debug) {
|
||||||
|
progressr::handlers("debug")
|
||||||
|
} else {
|
||||||
|
progressr::handlers("progress")
|
||||||
|
}
|
||||||
p <- progressr::progressor(along = tag)
|
p <- progressr::progressor(along = tag)
|
||||||
|
|
||||||
worker_fun <- function(x, y, p) {
|
worker_fun <- function(x, y, p, debug) {
|
||||||
p()
|
p(message = sprintf("Building '%s'", y))
|
||||||
tryCatch(
|
tryCatch(
|
||||||
{
|
{
|
||||||
dump <- build_single_tag(x, y, dir_out_bin, local_clone_dir,
|
dump <- build_single_tag(x, y, dir_out_bin, local_clone_dir,
|
||||||
|
|
@ -110,6 +115,8 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
|
||||||
deps_verbose = deps_verbose
|
deps_verbose = deps_verbose
|
||||||
)
|
)
|
||||||
|
|
||||||
|
p(message = sprintf("Done building '%s'", y))
|
||||||
|
|
||||||
# if for some reason an underlying error didnt' get caught in the tryCatch calls, we check again here for the existence of the binary file on disk and mark the build as failed if it is not found
|
# if for some reason an underlying error didnt' get caught in the tryCatch calls, we check again here for the existence of the binary file on disk and mark the build as failed if it is not found
|
||||||
tarball_name <- sprintf("%s_%s.tar.gz", x, y)
|
tarball_name <- sprintf("%s_%s.tar.gz", x, y)
|
||||||
if (fs::file_exists(sprintf("%s/%s", local_bin_path, tarball_name))) {
|
if (fs::file_exists(sprintf("%s/%s", local_bin_path, tarball_name))) {
|
||||||
|
|
@ -127,11 +134,17 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
|
||||||
store_build_metadata(x, y, platform, error_occurred = TRUE, arch = arch, force = TRUE, error = e$stderr)
|
store_build_metadata(x, y, platform, error_occurred = TRUE, arch = arch, force = TRUE, error = e$stderr)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
p(message = sprintf("Finished building %s %s", x, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
future.apply::future_mapply(worker_fun, package_name, tag,
|
|
||||||
future.seed = TRUE, MoreArgs = list(p)
|
if (debug) {
|
||||||
)
|
mapply(worker_fun, package_name, tag, MoreArgs = list(p, debug))
|
||||||
|
} else {
|
||||||
|
future.apply::future_mapply(worker_fun, package_name, tag,
|
||||||
|
future.seed = TRUE, MoreArgs = list(p, debug)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
total_build_time <- round(Sys.time() - t1, 2)
|
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))}}.")
|
cli::cli_alert("Execution time ({.pkg {package_name[1]}}) ({length(tag)} tags): {.strong {total_build_time} {units(difftime(Sys.time(), t1))}}.")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue