Bioconductor / BiocParallel

Bioconductor facilities for parallel evaluation
https://bioconductor.org/packages/BiocParallel
65 stars 29 forks source link

BiocParallel doesn't propagate warnings #216

Open alanocallaghan opened 2 years ago

alanocallaghan commented 2 years ago

This is not ideal imo, means that warnings silently disappear. Would be fine (ish) if at least a message showed up saying we encountered some warnings

library(BiocParallel)
fun <- function(v) {
     warning("A warning")
     sqrt(v)
 }
 bplapply(1:10, fun)
#> [[1]]
#> [1] 1
#> 
#> [[2]]
#> [1] 1.414214
#> 
#> [[3]]
#> [1] 1.732051
#> 
#> [[4]]
#> [1] 2
#> 
#> [[5]]
#> [1] 2.236068
#> 
#> [[6]]
#> [1] 2.44949
#> 
#> [[7]]
#> [1] 2.645751
#> 
#> [[8]]
#> [1] 2.828427
#> 
#> [[9]]
#> [1] 3
#> 
#> [[10]]
#> [1] 3.162278
Jiefei-Wang commented 2 years ago

Thanks for pointing it out, this is because of log=FALSE in the BPPARAM and the warnings are discarded. A temporary workaround is to enable the log manually by

fun <- function(v) {
    warning("A warning")
    sqrt(v)
}
bplapply(1:10, fun, BPOPTIONS = bpoptions(log = TRUE))

but I agree that this is not a good design...

mtmorgan commented 2 years ago

I also agree, and am surprised that warnings are not propagated!

alanocallaghan commented 2 years ago

Hmm, log=TRUE seems like much more information than I want, and I think the warnings might get lost anyways as a result, if users don't know what they're looking for/at