How to use the powerapi.dispatch_rule.HWPCDepthLevel function in powerapi

To help you get started, we’ve selected a few powerapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github powerapi-ng / powerapi / tests / unit / dispatcher_rule / test_hwpc_dispatcher_rule.py View on Github external
def test_init_fields_name_test():
    """
    test if the field's names of the dispatch_rule identifier tuple are
    correctly initialized
    """
    assert HWPCDispatchRule(HWPCDepthLevel.TARGET).fields == ['target']
    assert HWPCDispatchRule(HWPCDepthLevel.ROOT).fields == ['sensor']
    assert HWPCDispatchRule(HWPCDepthLevel.SOCKET).fields == ['sensor',
                                                              'socket']
    assert HWPCDispatchRule(HWPCDepthLevel.CORE).fields == ['sensor', 'socket',
                                                            'core']
github powerapi-ng / powerapi / tests / integration / dispatcher / test_integration_dispatcher.py View on Github external
def route_table_with_primary_rule():
    """
    return a RouteTable with :
      - a HWPCGrouptBy rule as primary rule
    """
    route_table = RouteTable()
    route_table.dispatch_rule(HWPCReport, HWPCDispatchRule(HWPCDepthLevel.ROOT,
                                                           primary=True))
    return route_table
github powerapi-ng / powerapi / tests / acceptation / test_hight_load.py View on Github external
- after powerapi handle all the reports, test if all the reports was handeled
        by the formula and pushed to the mongo database and if no report were lost

    """
    # Pusher
    output_mongodb = MongoDB(DB_URI, 'MongoDB1', 'test_result')
    pusher = PusherActor("pusher_mongodb", PowerModel(), output_mongodb, level_logger=LOG_LEVEL)

    # Formula
    formula_factory = (lambda name, verbose:
                       DummyFormulaActor(name, {'my_pusher': pusher}, level_logger=verbose, sleep_time=0.1))
                       # DummyFormulaActor(name, {'my_pusher': pusher}, level_logger=verbose))

    # Dispatcher
    route_table = RouteTable()
    route_table.dispatch_rule(HWPCReport, HWPCDispatchRule(getattr(HWPCDepthLevel, 'SOCKET'), primary=True))

    dispatcher = DispatcherActor('dispatcher', formula_factory, route_table, level_logger=LOG_LEVEL)

    # Puller
    input_mongodb = MongoDB(DB_URI, 'MongoDB1', 'test_hwrep')
    report_filter = Filter()
    report_filter.filter(lambda msg: True, dispatcher)
    puller = PullerActor("puller_mongodb", input_mongodb, report_filter, HWPCModel(), level_logger=LOG_LEVEL)

    supervisor.launch_actor(pusher)
    supervisor.launch_actor(dispatcher)
    supervisor.launch_actor(puller)

    supervisor.join()

    assert get_number_of_output_reports() == 30 * 2
github powerapi-ng / powerapi / tests / acceptation / test_hight_load.py View on Github external
- Launch the full architecture

    Test if:
      - each 50 ms, reports are writen in the output database
    """
    # Pusher
    output_mongodb = MongoDB(DB_URI, 'MongoDB1', 'test_result')
    pusher = PusherActor("pusher_mongodb", PowerModel(), output_mongodb, level_logger=LOG_LEVEL)

    # Formula
    formula_factory = (lambda name, verbose:
                       DummyFormulaActor(name, {'my_pusher': pusher}, level_logger=verbose))

    # Dispatcher
    route_table = RouteTable()
    route_table.dispatch_rule(HWPCReport, HWPCDispatchRule(getattr(HWPCDepthLevel, 'SOCKET'), primary=True))

    dispatcher = DispatcherActor('dispatcher', formula_factory, route_table, level_logger=LOG_LEVEL)

    # Puller
    input_mongodb = MongoDB(DB_URI, 'MongoDB1', 'test_hwrep')
    report_filter = Filter()
    report_filter.filter(lambda msg: True, dispatcher)
    puller = PullerActor("puller_mongodb", input_mongodb, report_filter, HWPCModel(), level_logger=LOG_LEVEL)

    supervisor.launch_actor(pusher)
    supervisor.launch_actor(dispatcher)
    supervisor.launch_actor(puller)


    t = time.time()
    number_of_output_reports = 0
github powerapi-ng / powerapi / tests / acceptation / test_crash_dispatcher.py View on Github external
signal.signal(signal.SIGINT, term_handler)

        stream_mode = True
        supervisor = BackendSupervisor(stream_mode)

        # Pusher
        output_mongodb = MongoDB(DB_URI, 'MongoDB1', 'test_result')
        pusher = PusherActor("pusher_mongodb", PowerModel(), output_mongodb, level_logger=LOG_LEVEL)

        # Formula
        formula_factory = (lambda name, verbose:
                           DummyFormulaActor(name, {'id_pusher': pusher}, level_logger=verbose))

        # Dispatcher
        route_table = RouteTable()
        route_table.dispatch_rule(HWPCReport, HWPCDispatchRule(getattr(HWPCDepthLevel, 'ROOT'), primary=True))

        dispatcher = DispatcherActor('dispatcher', formula_factory, route_table,
                                     level_logger=LOG_LEVEL)

        # Puller
        input_mongodb = MongoDB(DB_URI, 'MongoDB1', 'test_hwrep')
        report_filter = Filter()
        report_filter.filter(lambda msg: True, dispatcher)
        puller = PullerActor("puller_mongodb", input_mongodb,
                             report_filter, HWPCModel(), stream_mode=stream_mode, level_logger=LOG_LEVEL)

        supervisor.launch_actor(pusher)
        supervisor.launch_actor(dispatcher)
        supervisor.launch_actor(puller)
        time.sleep(1)
github powerapi-ng / powerapi / tests / unit / dispatcher_rule / test_hwpc_dispatcher_rule.py View on Github external
def test_get_formula_id_cpu_rule_report_2(report_2):
    """
    get formula id from report2 with a rule that dispatch by cpu :

    the method must return this list :
    [('toto','1', '1'), ('toto','2', '2')]
    """
    ids = HWPCDispatchRule(HWPCDepthLevel.CORE).get_formula_id(report_2)
    validate_formula_id(ids, [('toto', '1', '1'), ('toto', '1', '2')])
github powerapi-ng / powerapi / tests / acceptation / test_simple_architecture.py View on Github external
def test_run(database, supervisor):
    # Pusher
    output_mongodb = MongoDB(DB_URI, 'MongoDB1', 'test_result')
    pusher = PusherActor("pusher_mongodb", PowerModel(), output_mongodb, level_logger=LOG_LEVEL)

    # Formula
    formula_factory = (lambda name, verbose:
                       DummyFormulaActor(name, {'my_pusher': pusher}, level_logger=verbose))

    # Dispatcher
    route_table = RouteTable()
    route_table.dispatch_rule(HWPCReport, HWPCDispatchRule(getattr(HWPCDepthLevel, 'SOCKET'), primary=True))

    dispatcher = DispatcherActor('dispatcher', formula_factory, route_table, level_logger=LOG_LEVEL)

    # Puller
    input_mongodb = MongoDB(DB_URI, 'MongoDB1', 'test_hwrep')
    report_filter = Filter()
    report_filter.filter(lambda msg: True, dispatcher)
    puller = PullerActor("puller_mongodb", input_mongodb, report_filter, HWPCModel(), level_logger=LOG_LEVEL)

    supervisor.launch_actor(pusher)
    supervisor.launch_actor(dispatcher)
    supervisor.launch_actor(puller)

    supervisor.join()

    check_db()
github powerapi-ng / powerapi / tests / acceptation / test_simple_architecture_csv.py View on Github external
'name': 'puller',
                                  }}},
              'output': {'csv': {'pusher': {'model': 'PowerReport', 'name': 'pusher', 'directory': ROOT_PATH}}}}

    # Pusher
    pusher_generator = PusherGenerator()
    pushers = pusher_generator.generate(config)

    # Formula
    formula_factory = (lambda name,
                       verbose: DummyFormulaActor(name, pushers, level_logger=config['verbose']))

    # Dispatcher
    route_table = RouteTable()
    route_table.dispatch_rule(HWPCReport,
                              HWPCDispatchRule(getattr(HWPCDepthLevel, 'SOCKET'), primary=True))

    dispatcher = DispatcherActor('dispatcher', formula_factory, route_table,
                                 level_logger=LOG_LEVEL)

    # Puller
    report_filter = Filter()
    report_filter.filter(lambda msg: True, dispatcher)
    puller_generator = PullerGenerator(report_filter)
    pullers = puller_generator.generate(config)

    for _, pusher in pushers.items():
        supervisor.launch_actor(pusher)

    supervisor.launch_actor(dispatcher)

    for _, puller in pullers.items():
github powerapi-ng / powerapi / powerapi-cli.py View on Github external
# Pusher
    output_mongodb = MongoDB(args.output_uri,
                             args.output_db, args.output_collection,
                             HWPCModel())
    pusher = PusherActor("pusher_mongodb", PowerReport, output_mongodb,
                         level_logger=args.verbose)

    # Formula
    formula_factory = (lambda name, verbose:
                       RAPLFormulaActor(name, pusher, level_logger=verbose))

    # Dispatcher
    route_table = RouteTable()
    route_table.dispatch_rule(HWPCReport, HWPCDispatchRule(
        getattr(HWPCDepthLevel, args.hwpc_dispatch_rule), primary=True))

    dispatcher = DispatcherActor('dispatcher', formula_factory, route_table,
                                 level_logger=args.verbose)

    # Puller
    input_mongodb = MongoDB(args.input_uri,
                            args.input_db, args.input_collection,
                            HWPCModel(), stream_mode=args.stream_mode)
    report_filter = Filter()
    report_filter.filter(lambda msg: True, dispatcher)
    puller = PullerActor("puller_mongodb", input_mongodb,
                         report_filter, level_logger=args.verbose)

    ##########################################################################
    # Actor start step