Giter VIP home page Giter VIP logo

Comments (1)

mtmorgan avatar mtmorgan commented on August 16, 2024

Here's a more reproducible example

Without BiocParallel

g = function() stop("stopping in 'g'")
f = function(i) if (i == 2) g()
lapply(1:4, f)
traceback()
## 4: stop("stopping in 'g'") at #1
## 3: g() at #1
## 2: FUN(X[[i]], ...)
## 1: lapply(1:4, f)

With BiocParallel, traceback() initially points to the failed iteration on the manager.

bplapply(1:4, f, BPPARAM = SnowParam())
traceback()
## 4: stop(.error_bplist(res)) at bpinit.R#54
## 3: .bpinit(manager = manager, X = X, FUN = FUN, ARGS = ARGS, BPPARAM = BPPARAM, 
##        BPOPTIONS = BPOPTIONS, BPREDO = BPREDO) at bplapply-methods.R#57
## 2: bplapply(1:4, f, BPPARAM = SnowParam()) at AllGenerics.R#2
## 1: bplapply(1:4, f, BPPARAM = SnowParam())

Using bptry() gets us the results from the worker, but it's long, complicated, in the reverse order (deepest call is last, instead of first) and uninformative because it doesn't go deeper than a tryCatch() executed at the top level of each function call (to capture remote errors and to allow for bpstopOnError).

result <- bptry(bplapply(1:4, f, BPPARAM = SnowParam()))
length(attr(result[[2]], "traceback"))
## [1] 45

attr(result[[2]], "traceback") |> tail(6) |> cat(sep = "\n")
## 4: tryCatch({
##        FUN(...)
##    }, error = handle_error)
## 3: tryCatchList(expr, classes, parentenv, handlers)
## 2: tryCatchOne(expr, names, parentenv, handlers[[1L]])
## 1: value[[3L]](cond)

Running the same command under MulticoreParam gets a long traceback (60 calls deep) but no more information. Running under SerialParam is no more informative.

I think the code here

output <- withCallingHandlers({
could be reworked so that the call stack at the time the error occurs can be caught (withCallingHandlers() rather than tryCatch(), only the call stack on the worker is reported (by trimming the stack to things below the call), and in the same order as the base traceback() (by reversing the output of sys.calls() at
call <- sapply(sys.calls(), deparse, nlines=3)

from biocparallel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.