From 973dab7dcdc11947940226d49306b8c503f2649e Mon Sep 17 00:00:00 2001 From: mitchelloharawild Date: Thu, 29 Aug 2024 12:13:53 +1000 Subject: [PATCH] Add progress reporting for all parallel operations --- R/utils.R | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/R/utils.R b/R/utils.R index b7bc4ee7..83d3ad48 100644 --- a/R/utils.R +++ b/R/utils.R @@ -256,11 +256,15 @@ flatten_with_names <- function (x, sep = "_") { } mapply_maybe_parallel <- function (.f, ..., MoreArgs = list(), SIMPLIFY = FALSE) { + p <- progressr::progressor(length(..1)) + .fp <- function(...) { + p() + .f(...) + } if(is_attached("package:future")){ require_package("future.apply") - future.apply::future_mapply( - FUN = .f, + FUN = .fp, ..., MoreArgs = MoreArgs, SIMPLIFY = SIMPLIFY, @@ -270,7 +274,7 @@ mapply_maybe_parallel <- function (.f, ..., MoreArgs = list(), SIMPLIFY = FALSE) } else{ mapply( - FUN = .f, + FUN = .fp, ..., MoreArgs = MoreArgs, SIMPLIFY = SIMPLIFY