def test_range_operation_single_thread(self): """ Check that 'Range' operation works in single-threaded mode and raises an Exception in multi-threaded mode. """ backend = Local() backend.check_supported("Range")
def test_range_operation_multi_thread(self): """ Check that 'Range' operation raises an Exception in multi-threaded mode. """ ROOT.ROOT.EnableImplicitMT() backend = Local() with self.assertRaises(Exception): backend.check_supported("Range") ROOT.ROOT.DisableImplicitMT()
def use(backend_name, conf={}): """ Allows the user to choose the execution backend. Args: backend_name (str): This is the name of the chosen backend. conf (str, optional): This should be a dictionary with necessary configuration parameters. Its default value is an empty dictionary {}. """ future_backends = ["dask"] global current_backend if backend_name in future_backends: msg = "This backend environment will be considered in the future !" raise NotImplementedError(msg) elif backend_name == "local": current_backend = Local(conf) elif backend_name == "spark": from PyRDF.backend.Spark import Spark current_backend = Spark(conf) elif backend_name == "AWS": from PyRDF.backend.AWS import AWS current_backend = AWS(conf) else: msg = "Incorrect backend environment \"{}\"".format(backend_name) raise Exception(msg)
def test_unsupported_operations(self): """Check that unsupported operations raise an Exception.""" backend = Local() with self.assertRaises(Exception): backend.check_supported("Take") with self.assertRaises(Exception): backend.check_supported("Foreach")
def test_initialization_method(self): """ Check initialization method in Local backend. Define a method in the ROOT interpreter called getValue which returns the value defined by the user on the python side. """ def init(value): cpp_code = '''auto getUserValue = [](){return %s ;};''' % value ROOT.gInterpreter.Declare(cpp_code) PyRDF.initialize(init, 123) PyRDF.current_backend = Local() df = PyRDF.RDataFrame(1) s = df.Define("userValue", "getUserValue()").Sum("userValue") self.assertEqual(s.GetValue(), 123)
from PyRDF.RDataFrame import RDataFrame # noqa from PyRDF.RDataFrame import RDataFrameException # noqa from PyRDF.CallableGenerator import CallableGenerator # noqa from PyRDF.backend.Local import Local from PyRDF.backend.Backend import Backend from PyRDF.backend.Utils import Utils import os import logging import sys current_backend = Local() includes_headers = set() # All headers included in the analysis includes_shared_libraries = set() # All shared libraries included includes_files = set() # All other generic files included logger = logging.getLogger(__name__) def create_logger(level="WARNING", log_path="./PyRDF.log"): """PyRDF basic logger""" logger = logging.getLogger(__name__) level = getattr(logging, level) logger.setLevel(level) format_string = ("%(levelname)s: %(name)s[%(asctime)s]: %(message)s") formatter = logging.Formatter(format_string) stream_handler = logging.StreamHandler(sys.stdout)
def test_none(self): """Check that incorrect operations raise an Exception.""" backend = Local() with self.assertRaises(Exception): backend.check_supported("random")
def test_transformation(self): """Check that transformation nodes are classified accurately.""" backend = Local() backend.check_supported("Define")
def test_action(self): """Check that action nodes are classified accurately.""" backend = Local() backend.check_supported("Count")