Ejemplo n.º 1
0
def targettype(x):
    try:
        _target = int(x)

        def infinite_iterator():
            return (_target for _ in iter(int, 1))
        return infinite_iterator
    except ValueError:
        return util.load_obj_from_path(x, prefix='relay.plugins')
Ejemplo n.º 2
0
def warmer(
    parser,
    type=lambda x: util.load_obj_from_path(x, prefix='relay.plugins'),
    help=(
        ' This should point to a function that starts n additional tasks.'
        ' In a PID controller, this is the manipulated variable (MV).'
        '  Valid examples:\n'
        '  "bash_echo_warmer",\n'
        '  "relay.plugins.bash_echo_warmer",\n'
        '  "mycode.my_warmer_func"\n')):
    add_argument('-w', '--warmer', type=type, help=help)(parser)
Ejemplo n.º 3
0
def cooler(
    parser,
    type=lambda x: util.load_obj_from_path(x, prefix='relay.plugins'),
    help=(
        ' This should point to a function or class that terminates n'
        " instances of your tasks."
        '  In a PID controller, this is the manipulated variable (MV).'
        " You may not want to implement"
        " both a warmer and a cooler.  Does your thermostat toggle"
        " the heating element and air conditioner at the same time?"
        " For valid examples, see the --warmer syntax")):
    add_argument('-c', '--cooler', type=type, help=help)(parser)
Ejemplo n.º 4
0
def stop_condition(parser):
    add_argument(
        '--stop_condition',
        type=lambda x: util.load_obj_from_path(x, prefix='relay.plugins'),
        help=(
            'Optional.  This should point to a function that examines the'
            ' error history and determines whether Relay should exit. The'
            ' return code returned by this function gets passed to'
            ' sys.exit(...)'
            '  Valid examples:\n'
            '  "stop_if_mostly_diverging",\n'
            '  "mycode.my_stop_condition"\n')
    )(parser)
Ejemplo n.º 5
0
def metric(
    parser,
    type=lambda x: util.load_obj_from_path(x, prefix='relay.plugins'),
    help=(
        ' This should point to generator (function or class) that,'
        ' when called, returns a metric value.  In a PID controller, this'
        ' corresponds to the process variable (PV).  Warming the system'
        ' should eventually increase metric values and cooling should'
        ' decrease them. '
        '  Valid examples:\n'
        '  "bash_echo_metric"'
        '  (this loads relay.plugins.bash_echo_metric),\n'
        '  "relay.plugins.bash_echo_metric",\n'
        '  "mycode.custom_metric"\n')):
    add_argument('-m', '--metric', type=type, help=help)(parser)