Exemple #1
0
    def get(self):
        # load all the plugin information from the backend
        modules = get_gquant_config_modules()
        client_info = {}
        client_info['validation'] = {}
        client_info['display'] = {}
        for key in modules.keys():
            if os.path.isdir(modules[key]):
                mod = load_modules(modules[key])
                #                if hasattr(mod.mod, 'client'):
                client_mod = mod.mod
                if hasattr(client_mod, 'validation'):
                    val_dict = getattr(client_mod, 'validation')
                    client_info['validation'].update(val_dict)
                else:
                    print(client_mod, 'no validation')
                if hasattr(client_mod, 'display'):
                    val_dict = getattr(client_mod, 'display')
                    client_info['display'].update(val_dict)
                else:
                    print(client_mod, 'no display')


#                else:
#                    print(key, mod.mod, 'no client')
        self.finish(json.dumps(client_info))
Exemple #2
0
python -m unittest discover <test_directory>
python -m unittest discover -s <directory> -p 'test_*.py'

# Using pytest
# "conda install pytest" or "pip install pytest"
pytest -v tests
pytest -v tests/unit/test_nodes.py

'''
import warnings
import unittest
import cudf
import os
from gquant.dataframe_flow.task import load_modules
load_modules(os.getenv('MODULEPATH') + '/rapids_modules/')
from rapids_modules.transform.returnFeatureNode import ReturnFeatureNode
from rapids_modules.transform.indicatorNode import IndicatorNode
from rapids_modules.transform.assetIndicatorNode import AssetIndicatorNode
from gquant.dataframe_flow.task import Task
from .utils import make_orderer, error_function_index
import numpy as np
import pandas as pd

ordered, compare = make_orderer()
unittest.defaultTestLoader.sortTestMethodsUsing = compare

# gt for  return
ground_truth = b'\x92\x01\xef3\xec \x02@\xa3\xd5\xc0\xd96\xdd\xc0\xbf\xe2\xe1\xa7f\xab\xc0\xaa?\x8e\x9cySv\x9b\xca?vA\xc5\xd9\x8e\xd6\xd8\xbf\xbf){\x92=p\xc3\xbf\xd7\x06\xda\xca\x98\n\xd0?\xcf\xbf\xe8C\xb8\xb5\xc6?\x03\xa9\xf2H1\xcf\xca?V{\xc3\x9c\xda\xd5\xc0?\x1f\xed\xc6p\x14\xea\xe4\xbf\x84*\x911\x07\xf6\xe1\xbfQ\xdbQON&\x12@b\\H\xceZ\x19\xd3\xb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e1?\x14\x94D\xc3hh\xe2\xbf\x8e|\x0cY\xdb,\xe5\xbf?\xe7\xcf\xb3\x0c\xf5\x1b@\xb9|\x12\xef\xc1\xd9\xef\xbf\xdd\xf1U2\xdff0@\x88\xff\x1e\xe9\xdb\x97\xe9?\xab\xdc\x95\xc1\xb3|\x18@\xba_\xc38\x06\xb6\xe5\xbfK\x05\xd9\x0c\xee\xee\xd2\xbf\xaf\x0c\x85|\x80i\xc9?\xcc\xd0\x90\xab\x81\xfe\xe3\xbf\xadEW\xcb\xd4\x82\t@\x10\xd2\xeett8\xea?\x91\xc9R?\x89\x00\xbd\xbf\xf7R\xb0\xe9\xd7\x9d\xe3\xbf%\x1eK\xcc;\xe3\xb7\xbf\x1ce\x80\x92D\xe1\xf2?XO\xaf\x94\xdd\xcf\xe7?iB \x9e\xe8\x12\xd1\xbf\xd5B\xf0t\xadO\xc8?>\x89x\xa3\xc1\xeb\xda\xbf\r\x1c\xf50\xec\x9d\xb5\xbf\x95FF\xe8z\xcd\xe9?}^\xbd\x94\xba\x08\xdf\xbf\xdd\xf3I\x96\xfd\xf9\xde?\xdcl-c*W\xeb\xbf\x86\xd4\xfe\x0b\xe6\x8a\x19@n\x9f\xf5\x1c\x8a\xdf\xe0\xbf`\xa2JiRI\xfa?\x88\xfb\x95\xcb\xce\x1e\xe3\xbf\x01q\xf5V~\x8f\xf8?;\xd6\x8dX$p\xe6\xbf\xec*\xb9\x9f|`\xef\xbfI\xbd\xbd\xa5\x90\xb6>@\xc4\x92\\\x81\xcd\xda\xf1?\x9c\xcdf\xe3\xf7\xac\xd5\xbfH\xc6\x8d\xbbU\xe6\xfc?=i\xb19\xe4\xc1\xe3\xbf\xa5b\xc3oo\xa8\x05@\x97\x17\x10\x8e\x84\'\xd8\xbf\x8f=z\xe6\x1al\xd4?'  # noqa #E501

# gt for indicators
Exemple #3
0
def add_nodes():
    """
    It will load all the nodes for the UI client so user can add new node
    to the graph. The nodes are from two sources: default gQuant nodes and
    customized node modules.

    The output is a dictionary whose keys are module names and values are a
    list of the nodes inside that module.

    Arguments
    -------

    Returns
    -------
    dict
        dictionary of all the nodes that can be added in the client
    """
    all_modules = get_gquant_config_modules()
    print(all_modules)
    all_nodes = {}
    # not implemented yet for gQuant
    for item in inspect.getmembers(plugin_nodes):
        if inspect.ismodule(item[1]):
            print(item)
            all_nodes[item[0]] = []
            for node in inspect.getmembers(item[1]):
                if inspect.isclass(node[1]):
                    task = {
                        'id': 'random',
                        'type': node[0],
                        'conf': {},
                        'inputs': []
                    }
                    t = Task(task)
                    n = node[1](t)
                    if issubclass(node[1], Node):
                        nodeObj = get_node_obj(n)
                        all_nodes[item[0]].append(nodeObj)
    for module in all_modules:
        loaded = load_modules(all_modules[module], module)
        mod = loaded.mod
        modulename = module

        all_nodes[modulename] = []
        for node in inspect.getmembers(mod):
            if node[1] == Node:
                continue
            if inspect.isclass(node[1]):
                if issubclass(node[1], Node):
                    task = {
                        'id': 'node_' + str(uuid.uuid4())[:8],
                        'type': node[0],
                        'conf': {},
                        'inputs': [],
                        'module': module
                    }
                    t = Task(task)
                    n = node[1](t)
                    nodeObj = get_node_obj(n)
                    all_nodes[modulename].append(nodeObj)
    return all_nodes
Exemple #4
0
def add_nodes():
    """
    It will load all the nodes for the UI client so user can add new node
    to the graph. The nodes are from two sources: default gQuant nodes and
    customized node modules.

    The output is a dictionary whose keys are module names and values are a
    list of the nodes inside that module.

    Arguments
    -------

    Returns
    -------
    dict
        dictionary of all the nodes that can be added in the client
    """
    loaded_node_classes = []
    all_modules = get_gquant_config_modules()
    print(all_modules)
    all_nodes = {}
    # not implemented yet for gQuant
    for item in inspect.getmembers(plugin_nodes):
        if inspect.ismodule(item[1]):
            print(item)
            labmod_pkg = 'gquant.{}'.format(item[0])
            all_nodes[labmod_pkg] = []
            for node in inspect.getmembers(item[1]):
                nodecls = node[1]
                if not inspect.isclass(nodecls):
                    continue
                if not issubclass(nodecls, Node):
                    continue
                if nodecls in loaded_node_classes:
                    continue

                task = {
                    'id': 'node_' + str(uuid.uuid4()),
                    'type': node[0],
                    'conf': {},
                    'inputs': []
                }
                t = Task(task)
                n = nodecls(t)
                nodeObj = get_node_obj(n, False)
                all_nodes[labmod_pkg].append(nodeObj)
                loaded_node_classes.append(nodecls)

    for module in all_modules:
        module_file_or_path = Path(all_modules[module])
        loaded = load_modules(all_modules[module], module)
        mod = loaded.mod
        modulename = module

        # all_nodes[modulename] = []
        for node in inspect.getmembers(mod):
            nodecls = node[1]
            if not inspect.isclass(nodecls):
                continue
            if nodecls == Node:
                continue

            if not issubclass(nodecls, Node):
                continue

            if nodecls in loaded_node_classes:
                continue

            task = {
                'id': 'node_' + str(uuid.uuid4()),
                'type': node[0],
                'conf': {},
                'inputs': [],
                'module': module
            }
            t = Task(task)
            n = nodecls(t)
            nodeObj = get_node_obj(n, False)
            if module_file_or_path.is_dir():
                # submod = nodecls.__module__.split('.')[1:]
                # flatten out the namespace hierarchy
                submod = nodecls.__module__.split('.')[1:2]
                modulename_ = '.'.join([modulename, '.'.join(submod)]) \
                    if submod else modulename
                all_nodes.setdefault(modulename_, []).append(nodeObj)
            else:
                all_nodes.setdefault(modulename, []).append(nodeObj)

            loaded_node_classes.append(nodecls)
    for module in dynamic_modules.keys():
        modulename = module
        node_lists = []
        all_nodes[modulename] = node_lists
        for class_name in dynamic_modules[module].keys():
            classObj = dynamic_modules[module][class_name]
            if issubclass(classObj, Node):
                task = {
                    'id': 'node_' + str(uuid.uuid4()),
                    'type': classObj.__name__,
                    'conf': {},
                    'inputs': [],
                    'module': module
                }
                t = Task(task)
                n = classObj(t)
                nodeObj = get_node_obj(n, False)
                node_lists.append(nodeObj)

    # load all the plugins from entry points
    for entry_point in importlib_metadata.entry_points().get(
            'gquant.plugin', ()):
        mod = entry_point.load()
        modulename = entry_point.name

        for node in inspect.getmembers(mod):
            nodecls = node[1]
            if not inspect.isclass(nodecls):
                continue
            if nodecls == Node:
                continue

            if not issubclass(nodecls, Node):
                continue

            if nodecls in loaded_node_classes:
                continue

            task = {
                'id': 'node_' + str(uuid.uuid4()),
                'type': node[0],
                'conf': {},
                'inputs': [],
                'module': modulename
            }
            t = Task(task)
            n = nodecls(t)
            nodeObj = get_node_obj(n, False)
            all_nodes.setdefault(modulename, []).append(nodeObj)
            loaded_node_classes.append(nodecls)

    return all_nodes