Bioconductor / BiocParallel

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

improve traceback in remote errors #246

Closed mtmorgan closed 1 year ago

mtmorgan commented 1 year ago
mtmorgan commented 1 year ago

@MikeDMorgan could you see if this addresses (mostly) your concern?

BiocManager::install("Bioconductor/BiocParallel", ref = "issue-245")

My simple example gives me

g = function() stop("stopping in 'g'")
f = function(i) { if (i == 2) g(); i }
result <- bptry(bplapply(1:4, f, BPPARAM = SerialParam()))

and then

> attr(result[[2]], "traceback") |> cat(sep = "\n")
6: handle_error(e)
5: h(simpleError(msg, call))
4: .handleSimpleError(function (e)
   {
       annotated_condition <- handle_error(e)
       stop(annotated_condition)
   }, "stopping in 'g'", base::quote(g()))
3: stop("stopping in 'g'") at #1
2: g() at #1
1: FUN(...)

where the interesting stuff is frames 1, 2, and 3 (so trimming 45+ calls...) and extends 'into' the tryCatch; currently 4, 5, and 6 are not relevant, but I'm not sure how to robustly mask them... The call stack is also presented in the same way as traceback(), whereas before it was reversed.

MikeDMorgan commented 1 year ago

Hi @mtmorgan - I can now get the full callstack down to Rcpp - thank you for implemeting this so quickly. I'll consider #245 resolved.