Skip to content

Commit

Permalink
[DF] Allow calling RunGraphs and VariationsFor on distrdf results
Browse files Browse the repository at this point in the history
  • Loading branch information
eguiraud committed Jul 14, 2023
1 parent d648a51 commit 31ec1a3
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions bindings/pyroot/pythonizations/python/ROOT/_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,36 @@ def _create_rdf_experimental_distributed_module(parent):
return DistRDF.create_distributed_module(parent)


def _distrdf_compatible_rungraphs(distrdf_rungraphs, rdf_rungraphs):
"""
Create a callable that correctly dispatches either to the C++ version
or the dedicated DistRDF version of RunGraphs.
"""

def rungraphs(handles) -> int:
if len(handles) > 0 and hasattr(handles[0], "proxied_node"):
return distrdf_rungraphs(handles)
else:
return rdf_rungraphs(handles)

return rungraphs


def _distrdf_compatible_variationsfor(distrdf_variationsfor, rdf_variationsfor):
"""
Create a callable that correctly dispatches either to the C++ version
or the dedicated DistRDF version of RunGraphs.
"""

def variationsfor(resptr):
if hasattr(resptr, "proxied_node"):
return distrdf_variationsfor(resptr)
else:
return rdf_variationsfor(resptr)

return variationsfor


def _subimport(name):
# type: (str) -> types.ModuleType
"""
Expand Down Expand Up @@ -333,6 +363,8 @@ def RDF(self):
try:
# Inject Experimental.Distributed package into namespace RDF if available
ns.Experimental.Distributed = _create_rdf_experimental_distributed_module(ns.Experimental)
ns.RunGraphs = _distrdf_compatible_rungraphs(ns.Experimental.Distributed.RunGraphs, ns.RunGraphs)
ns.Experimental.VariationsFor = _distrdf_compatible_variationsfor(ns.Experimental.Distributed.VariationsFor, ns.Experimental.VariationsFor)
except ImportError:
pass
except:
Expand Down

0 comments on commit 31ec1a3

Please sign in to comment.