Skip to content

Commit

Permalink
Add progress reporting for all parallel operations
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Aug 29, 2024
1 parent 6865b67 commit 973dab7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -270,7 +274,7 @@ mapply_maybe_parallel <- function (.f, ..., MoreArgs = list(), SIMPLIFY = FALSE)
}
else{
mapply(
FUN = .f,
FUN = .fp,
...,
MoreArgs = MoreArgs,
SIMPLIFY = SIMPLIFY
Expand Down

0 comments on commit 973dab7

Please sign in to comment.