BiocParallel icon indicating copy to clipboard operation
BiocParallel copied to clipboard

BiocParallel doesn't propagate warnings

Open alanocallaghan opened this issue 3 years ago • 3 comments

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

alanocallaghan avatar Jul 20 '22 11:07 alanocallaghan

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...

Jiefei-Wang avatar Jul 20 '22 14:07 Jiefei-Wang

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

mtmorgan avatar Jul 20 '22 18:07 mtmorgan

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

alanocallaghan avatar Jul 20 '22 19:07 alanocallaghan