7.2.8.21. SubDispatchPipe

class SubDispatchPipe(dsp=None, *args, **kwargs)[source]

It converts a Dispatcher into a function.

This function takes a sequence of arguments as input of the dispatch.

Returns:

A function that executes the pipe of the given dsp.

Return type:

callable

Example:

A dispatcher with two functions max and min and an unresolved cycle (i.e., a –> max –> c –> min –> a):

Extract a static function node, i.e. the inputs a and b and the output a are fixed:

>>> fun = SubDispatchPipe(dsp, 'myF', ['a', 'b'], ['a'])
>>> fun.__name__
'myF'
>>> fun(2, 1)
1

The created function raises a ValueError if un-valid inputs are provided:

>>> fun(1, 0)
0

Methods

__init__

Initializes the Sub-dispatch Function.

blue

Constructs a Blueprint out of the current object.

copy

form

Creates a dispatcher Form Flask app.

get_node

Returns a sub node of a dispatcher.

plot

Plots the Dispatcher with a graph in the DOT language with Graphviz.

web

Creates a dispatcher Flask app.

__init__(dsp, function_id=None, inputs=None, outputs=None, inputs_dist=None, no_domain=True, wildcard=True, shrink=True, output_type=None, output_type_kw=None, first_arg_as_kw=False)[source]

Initializes the Sub-dispatch Function.

Parameters:
  • dsp (schedula.Dispatcher | schedula.utils.blue.BlueDispatcher) – A dispatcher that identifies the model adopted.

  • function_id (str) – Function name.

  • inputs (list[str], iterable) – Input data nodes.

  • outputs (list[str], iterable, optional) – Ending data nodes.

  • inputs_dist (dict[str, int | float], optional) – Initial distances of input data nodes.

  • no_domain (bool, optional) – Skip the domain check.

  • shrink (bool, optional) – If True the dispatcher is shrink before the dispatch.

  • wildcard (bool, optional) – If True, when the data node is used as input and target in the ArciDispatch algorithm, the input value will be used as input for the connected functions, but not as output.

  • output_type (str, optional) –

    Type of function output:

    • ’all’: a dictionary with all dispatch outputs.

    • ’list’: a list with all outputs listed in outputs.

    • ’dict’: a dictionary with any outputs listed in outputs.

  • output_type_kw (bool) – Extra kwargs to pass to the selector function.

  • first_arg_as_kw – Converts first argument of the __call__ method as kwargs.

Attributes

var_keyword

var_keyword = None