Exemplo n.º 1
0
    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")
Exemplo n.º 2
0
    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()
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
    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")
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
 def test_none(self):
     """Check that incorrect operations raise an Exception."""
     backend = Local()
     with self.assertRaises(Exception):
         backend.check_supported("random")
Exemplo n.º 8
0
 def test_transformation(self):
     """Check that transformation nodes are classified accurately."""
     backend = Local()
     backend.check_supported("Define")
Exemplo n.º 9
0
 def test_action(self):
     """Check that action nodes are classified accurately."""
     backend = Local()
     backend.check_supported("Count")