root icon indicating copy to clipboard operation
root copied to clipboard

[DF] Catch and propagate C++ exceptions in the distributed tasks

Open vepadulano opened this issue 2 years ago • 5 comments

Consider the following code

from dask.distributed import LocalCluster, Client
import ROOT
RDataFrame = ROOT.RDF.Experimental.Distributed.Dask.RDataFrame

def create_connection():
    cluster = LocalCluster(n_workers=2, threads_per_worker=1, processes=False)
    client = Client(cluster)
    return client

if __name__ == "__main__":
    connection = create_connection()
    df = RDataFrame(100, daskclient=connection)
    df = df.Define("x", "1").Define("y", "ROOT::RVecF{1., 2., 3.}")
    g = df.Graph("x", "y")
    gv = g.GetValue()

Before this PR, the output would be:

$: python test.py
RDataFrame::Run: event loop was interrupted
Warning in <TBufferFile::WriteObjectAny>: since runtime_error has no public constructor
	which can be called without argument, objects of this class
	can not be read with the current library. You will need to
	add a default constructor before attempting to read it.
Warning in <TStreamerInfo::Build>: runtime_error: base class exception has no streamer or dictionary it will not be saved
Warning in <TStreamerInfo::Build>: runtime_error: __cow_string has no streamer or dictionary, data member "_M_msg" will not be saved
Error in <TClass::New>: cannot create object of class runtime_error
Error in <TBufferFile::ReadObject>: could not create object of class runtime_error
 *** Break *** bus error

After this PR:

$: python test.py
[...]
  File "/home/vpadulan/programs/rootproject/rootbuild/fix-tentrylist-int-overflow-distrdf-debug/lib/DistRDF/Backends/Dask/Backend.py", line 155, in dask_mapper
    return mapper(current_range)
  File "/home/vpadulan/programs/rootproject/rootbuild/fix-tentrylist-int-overflow-distrdf-debug/lib/DistRDF/Backends/Base.py", line 116, in distrdf_mapper
    raise RuntimeError(f"C++ exception thrown:\n\t{type(e).__name__}: {e.what()}")
RuntimeError: C++ exception thrown:
	runtime_error: Graph was applied to a mix of scalar values and collections. This is not supported.

vepadulano avatar Jul 25 '22 19:07 vepadulano

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac1015/cxx17, mac11/cxx14, windows10/cxx14 How to customize builds

phsft-bot avatar Jul 25 '22 19:07 phsft-bot

Build failed on windows10/cxx14. See console output.

phsft-bot avatar Jul 25 '22 19:07 phsft-bot

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac1015/cxx17, mac11/cxx14, windows10/cxx14 How to customize builds

phsft-bot avatar Jul 26 '22 16:07 phsft-bot

Build failed on ROOT-performance-centos8-multicore/cxx17. Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build See console output.

Failing tests:

phsft-bot avatar Jul 26 '22 17:07 phsft-bot