Description Usage Arguments Details Author(s) Examples
View source: R/ErrorHandling.R
Identifies unsuccessful results returned from bplapply
,
bpmapply
, bpvec
, bpaggregate
or bpvectorize
.
1 | bpok(x)
|
x |
Results returned from a call to |
bpok
Returns a logical()
vector: FALSE for any jobs that resulted in
an error. x
is the result list output by bplapply
,
bpmapply
, bpvec
, bpaggregate
or bpvectorize
.
Michel Lang, Martin Morgan and Valerie Obenchain
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ## -----------------------------------------------------------------------
## Catch errors:
## -----------------------------------------------------------------------
## By default 'stop.on.error' is TRUE in BiocParallelParam objects. If
## 'stop.on.error' is TRUE an ill-fated bplapply() simply stops,
## displaying the error message.
param <- SnowParam(workers = 2, stop.on.error = TRUE)
tryCatch({
bplapply(list(1, "two", 3), sqrt, BPPARAM = param)
}, error=identity)
## If 'stop.on.error' is FALSE then the computation continues. Errors
## are signalled but the full evaluation can be retrieved
param <- SnowParam(workers = 2, stop.on.error = FALSE)
X <- list(1, "two", 3)
result <- bptry(bplapply(X, sqrt, BPPARAM = param))
result
## Check for errors:
fail <- !bpok(result)
fail
## Access the traceback with attr():
tail(attr(result[[2]], "traceback"), 5)
## -----------------------------------------------------------------------
## Resume calculations:
## -----------------------------------------------------------------------
## The 'resume' mechanism is triggered by supplying a list of partial
## results as 'BPREDO'. Data elements that failed are rerun and merged
## with previous results.
## A call of sqrt() on the character "2" returns an error. Fix the input
## data by changing the character "2" to a numeric 2:
X_mod <- list(1, 2, 3)
bplapply(X_mod, sqrt, BPPARAM = param , BPREDO = result)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.