Hi,
I am not quite sure if this is intentional, but I realized that calls to message
and cat
within functions executed by bplapply
are shown only after the bplapply
call. I tried to use also flush.console()
after each message
call but that didn't work either.
library(BiocParallel) myFun <- function(x) { message("Element ", x, " start") Sys.sleep(2) message("Element ", x, " end") } register(SerialParam()) tmp <- bplapply(1:6, myFun) Element 1 start Element 1 end Element 2 start Element 2 end Element 3 start Element 3 end Element 4 start Element 4 end Element 5 start Element 5 end Element 6 start Element 6 end ## Works nicely ## Using MulticoreParam: register(MulticoreParam(2)) tmp <- bplapply(1:6, myFun) Element 4 start Element 4 end Element 5 start Element 5 end Element 6 start Element 6 end Element 1 start Element 1 end Element 2 start Element 2 end Element 3 start Element 3 end ## Console output is shown after the bplapply call finished
Is there a way to enable the immediate output of message or cat calls?
Additionally, at least on my system, the progress bar is also not progressing, but shows 0% and after all is finished 50% and 100%.
thanks, jo
My sessionInfo:
> sessionInfo() R version 3.4.0 (2017-04-21) Platform: x86_64-apple-darwin16.6.0/x86_64 (64-bit) Running under: macOS Sierra 10.12.6 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] BiocParallel_1.11.2 loaded via a namespace (and not attached): [1] compiler_3.4.0 parallel_3.4.0
Thanks Martin for this explanation!
Hi Martin,
I was wondering if there is a way to avoid that upfront division of the job i.e. have
bplapply()
work asynchronously (likebpiterate()
) where the n workers receive only 1 element of the list at a time. Can this be controlled via theBPPARAM
argument or should I usebpiterate()
for that? Thanks!H.
If the tasks are in X with length(X), then
*Param(tasks=length(X))
does this -- workers receive one element at a time.bpiterate()
is intended for use when X cannot be computed / is expensive to compute ahead of time.Excellent! Thanks. H.