diff --git a/R/BiocParallelParam-class.R b/R/BiocParallelParam-class.R index 1af985f1..7dcdfd53 100644 --- a/R/BiocParallelParam-class.R +++ b/R/BiocParallelParam-class.R @@ -261,7 +261,7 @@ setMethod("bpprogressbar", "BiocParallelParam", setReplaceMethod("bpprogressbar", c("BiocParallelParam", "logical"), function(x, value) { - x$progressbar <- value + x$progressbar <- value x }) diff --git a/R/MulticoreParam-class.R b/R/MulticoreParam-class.R index 3433dd28..e60a0bee 100644 --- a/R/MulticoreParam-class.R +++ b/R/MulticoreParam-class.R @@ -30,6 +30,9 @@ MulticoreParam <- function(workers=multicoreWorkers(), tasks=0L, workers = 1L } + if (progressbar && missing(tasks)) + tasks <- .Machine$integer.max + clusterargs <- c(list(spec=workers, type="FORK"), list(...)) manager.hostname <- diff --git a/R/SnowParam-class.R b/R/SnowParam-class.R index 25096960..4e94797e 100644 --- a/R/SnowParam-class.R +++ b/R/SnowParam-class.R @@ -115,6 +115,9 @@ SnowParam <- function(workers=snowWorkers(type), if (type %in% c("MPI", "FORK") && is(workers, "character")) stop("'workers' must be integer(1) when 'type' is MPI or FORK") + if (progressbar && missing(tasks)) + tasks <- .Machine$integer.max + clusterargs <- c(list(spec=workers, type=type), list(...)) manager.hostname <- diff --git a/inst/unitTests/test_MulticoreParam.R b/inst/unitTests/test_MulticoreParam.R new file mode 100644 index 00000000..4b2da0de --- /dev/null +++ b/inst/unitTests/test_MulticoreParam.R @@ -0,0 +1,12 @@ +test_MulticoreParam_progressbar <- function() +{ + if (.Platform$OS.type == "windows") + return() + + checkIdentical(bptasks(MulticoreParam()), 0L) + checkIdentical(bptasks(MulticoreParam(tasks = 0L, progressbar = TRUE)), 0L) + checkIdentical( + bptasks(MulticoreParam(progressbar = TRUE)), + .Machine$integer.max + ) +} diff --git a/inst/unitTests/test_SnowParam.R b/inst/unitTests/test_SnowParam.R index ca06645b..e6c8ebd5 100644 --- a/inst/unitTests/test_SnowParam.R +++ b/inst/unitTests/test_SnowParam.R @@ -105,3 +105,10 @@ test_SnowParam_workers <- function() checkException(SnowParam("host", "MPI"), silent=TRUE) checkException(SnowParam("host", "FORK"), silent=TRUE) } + +test_SnowParam_progressbar <- function() +{ + checkIdentical(bptasks(SnowParam()), 0L) + checkIdentical(bptasks(SnowParam(tasks = 0L, progressbar = TRUE)), 0L) + checkIdentical(bptasks(SnowParam(progressbar = TRUE)), .Machine$integer.max) +} diff --git a/man/MulticoreParam-class.Rd b/man/MulticoreParam-class.Rd index d56d02f4..1253833c 100644 --- a/man/MulticoreParam-class.Rd +++ b/man/MulticoreParam-class.Rd @@ -185,12 +185,16 @@ multicoreWorkers() In this documentation a job is defined as a single call to a function, such as \code{bplapply}, \code{bpmapply} etc. A task is the division of the - \code{X} argument into chunks. When \code{tasks == 0} (default), \code{X} - is divided as evenly as possible over the number of workers. + \code{X} argument into chunks. - A \code{tasks} value of > 0 specifies the exact number of tasks. Values - can range from 1 (all of \code{X} to a single worker) to the length of - \code{X} (each element of \code{X} to a different worker). + When \code{tasks == 0} (default, except when \code{progressbar = + TRUE}), \code{X} is divided as evenly as possible over the number of + workers. + + A \code{tasks} value of > 0 specifies the exact number of + tasks. Values can range from 1 (all of \code{X} to a single worker) + to the length of \code{X} (each element of \code{X} to a different + worker). When the length of \code{X} is less than the number of workers each element of \code{X} is sent to a worker and \code{tasks} is ignored. @@ -202,7 +206,10 @@ multicoreWorkers() \code{logical(1)} Enable stop on error. } \item{progressbar}{ - \code{logical(1)} Enable progress bar (based on plyr:::progress_text). + \code{logical(1)} Enable progress bar (based on + plyr:::progress_text). Enabling the progress bar changes the + \emph{default} value of \code{tasks} to \code{.Machine$integer.max}, so + that progress is reported for each element of \code{X}. } \item{RNGseed}{ \code{integer(1)} Seed for random number generation. When not \code{NULL},