7.1.1. Dispatcher

class Dispatcher(dmap=None, name='', default_values=None, raises=False, description='', stopper=None)[source]

It provides a data structure to process a complex system of functions.

The scope of this data structure is to compute the shortest workflow between input and output data nodes.

Variables:stopper – A semaphore (threading.Event) to abort the dispatching.

Tip

Remember to set stopper to False before dispatching ;-)

A workflow is a sequence of function calls.

***************************************************************************

Example:

As an example, here is a system of equations:

\(b - a = c\)

\(log(c) = d_{from-log}\)

\(d = (d_{from-log} + d_{initial-guess}) / 2\)

that will be solved assuming that \(a = 0\), \(b = 1\), and \(d_{initial-guess} = 4\).

Steps

Create an empty dispatcher:

>>> dsp = Dispatcher(name='Dispatcher')

Add data nodes to the dispatcher map:

>>> dsp.add_data(data_id='a')
'a'
>>> dsp.add_data(data_id='c')
'c'

Add a data node with a default value to the dispatcher map:

>>> dsp.add_data(data_id='b', default_value=1)
'b'

Add a function node:

>>> def diff_function(a, b):
...     return b - a
...
>>> dsp.add_function('diff_function', function=diff_function,
...                  inputs=['a', 'b'], outputs=['c'])
'diff_function'

Add a function node with domain:

>>> from math import log
...
>>> def log_domain(x):
...     return x > 0
...
>>> dsp.add_function('log', function=log, inputs=['c'], outputs=['d'],
...                  input_domain=log_domain)
'log'

Add a data node with function estimation and callback function.

  • function estimation: estimate one unique output from multiple estimations.
  • callback function: is invoked after computing the output.
>>> def average_fun(kwargs):
...     '''
...     Returns the average of node estimations.
...
...     :param kwargs:
...         Node estimations.
...     :type kwargs: dict
...
...     :return:
...         The average of node estimations.
...     :rtype: float
...     '''
...
...     x = kwargs.values()
...     return sum(x) / len(x)
...
>>> def callback_fun(x):
...     print('(log(1) + 4) / 2 = %.1f' % x)
...
>>> dsp.add_data(data_id='d', default_value=4, wait_inputs=True,
...              function=average_fun, callback=callback_fun)
'd'

digraph dmap { graph [ratio=1] node [style=filled] label = <dmap> splines = ortho style = filled 202 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">a</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=a] 203 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">b</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">1</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=b] 204 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">c</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=c] 205 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">d</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">4</TD></TR><TR><TD align="RIGHT" border="1">wait_inputs</TD><TD align="LEFT" border="1">True</TD></TR><TR><TD align="RIGHT" border="1">function</TD><TD align="LEFT" border="1" href="./dispatcher-b3957c4b0edea40abf462fab96791fa3eceb2b7d/average_fun.html">average_fun</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=d] 206 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-b3957c4b0edea40abf462fab96791fa3eceb2b7d/diff_function.html">diff_function</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip=diff_function] 207 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-b3957c4b0edea40abf462fab96791fa3eceb2b7d/log.html">log</TD></TR><TR><TD align="RIGHT" border="1">input_domain</TD><TD align="LEFT" border="1" href="./dispatcher-b3957c4b0edea40abf462fab96791fa3eceb2b7d/log_domain.html">log_domain</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="log(x[, base])"] 203 -> 206 207 -> 205 202 -> 206 206 -> 204 204 -> 207 }

Dispatch the function calls to achieve the desired output data node d:

>>> outputs = dsp.dispatch(inputs={'a': 0}, outputs=['d'])
(log(1) + 4) / 2 = 2.0
>>> outputs
Solution([('a', 0), ('b', 1), ('c', 1), ('d', 2.0)])

digraph workflow { graph [ratio=1] node [style=filled] label = <workflow> splines = ortho style = filled 213 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-9f9e33d12faa54288c701f663f6bc61fe43c970f/a-output.html">a</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">0.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=a] 214 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-9f9e33d12faa54288c701f663f6bc61fe43c970f/b-output.html">b</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">1</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">0.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=b] 215 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-9f9e33d12faa54288c701f663f6bc61fe43c970f/c-output.html">c</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">2.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=c] 216 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-9f9e33d12faa54288c701f663f6bc61fe43c970f/d-output.html">d</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">4</TD></TR><TR><TD align="RIGHT" border="1">wait_inputs</TD><TD align="LEFT" border="1">True</TD></TR><TR><TD align="RIGHT" border="1">function</TD><TD align="LEFT" border="1" href="./dispatcher-9f9e33d12faa54288c701f663f6bc61fe43c970f/average_fun.html">average_fun</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">4.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=d] 217 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-9f9e33d12faa54288c701f663f6bc61fe43c970f/diff_function.html">diff_function</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">1.0</TD></TR><TR><TD align="RIGHT" border="1">started</TD><TD align="LEFT" border="1">2018-10-08T22:02:36.061790</TD></TR><TR><TD align="RIGHT" border="1">duration</TD><TD align="LEFT" border="1">0:00:00.000007</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip=diff_function] 218 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-9f9e33d12faa54288c701f663f6bc61fe43c970f/log.html">log</TD></TR><TR><TD align="RIGHT" border="1">solution_domain</TD><TD align="LEFT" border="1" href="./dispatcher-9f9e33d12faa54288c701f663f6bc61fe43c970f/log-solution_domain.html">log-solution_domain</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">3.0</TD></TR><TR><TD align="RIGHT" border="1">started</TD><TD align="LEFT" border="1">2018-10-08T22:02:36.061859</TD></TR><TR><TD align="RIGHT" border="1">duration</TD><TD align="LEFT" border="1">0:00:00.000007</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="log(x[, base])"] 219 [label=start fillcolor=red shape=egg] 214 -> 217 218 -> 216 213 -> 217 219 -> 214 219 -> 213 219 -> 216 215 -> 218 217 -> 215 }

Methods

__init__ Initializes the dispatcher.
add_data Add a single data node to the dispatcher.
add_dispatcher Add a single sub-dispatcher node to dispatcher.
add_from_lists Add multiple function and data nodes to dispatcher.
add_function Add a single function node to dispatcher.
copy Returns a copy of the Dispatcher.
copy_structure
dispatch Evaluates the minimum workflow and data outputs of the dispatcher model from given inputs.
get_node Returns a sub node of a dispatcher.
get_sub_dsp Returns the sub-dispatcher induced by given node and edge bunches.
get_sub_dsp_from_workflow Returns the sub-dispatcher induced by the workflow from sources.
plot Plots the Dispatcher with a graph in the DOT language with Graphviz.
search_node_description
set_data_remote_link Set a remote link of a data node in the dispatcher.
set_default_value Set the default value of a data node in the dispatcher.
shrink_dsp Returns a reduced dispatcher.
web Creates a dispatcher Flask app.
__init__(dmap=None, name='', default_values=None, raises=False, description='', stopper=None)[source]

Initializes the dispatcher.

Parameters:
  • dmap (networkx.DiGraph, optional) – A directed graph that stores data & functions parameters.
  • name (str, optional) – The dispatcher’s name.
  • default_values (dict[str, dict], optional) – Data node default values. These will be used as input if it is not specified as inputs in the ArciDispatch algorithm.
  • raises (bool, optional) – If True the dispatcher interrupt the dispatch when an error occur, otherwise it logs a warning.
  • description (str, optional) – The dispatcher’s description.
  • stopper (threading.Event, optional) – A semaphore to abort the dispatching.

Attributes

data_nodes Returns all data nodes of the dispatcher.
function_nodes Returns all function nodes of the dispatcher.
sub_dsp_nodes Returns all sub-dispatcher nodes of the dispatcher.
dmap = None

The directed graph that stores data & functions parameters.

name = None

The dispatcher’s name.

nodes = None

The function and data nodes of the dispatcher.

default_values = None

Data node default values. These will be used as input if it is not specified as inputs in the ArciDispatch algorithm.

weight = None

Weight tag.

raises = None

If True the dispatcher interrupt the dispatch when an error occur.

stopper = <threading.Event object>

Stopper to abort the dispatcher execution.

solution = None

Last dispatch solution.

counter = None

Counter to set the node index.

add_data(data_id=None, default_value=empty, initial_dist=0.0, wait_inputs=False, wildcard=None, function=None, callback=None, remote_links=None, description=None, filters=None, **kwargs)[source]

Add a single data node to the dispatcher.

Parameters:
  • data_id (str, optional) – Data node id. If None will be assigned automatically (‘unknown<%d>’) not in dmap.
  • default_value (T, optional) – Data node default value. This will be used as input if it is not specified as inputs in the ArciDispatch algorithm.
  • initial_dist (float, int, optional) – Initial distance in the ArciDispatch algorithm when the data node default value is used.
  • wait_inputs (bool, optional) – If True ArciDispatch algorithm stops on the node until it gets all input estimations.
  • 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.
  • function (callable, optional) – Data node estimation function. This can be any function that takes only one dictionary (key=function node id, value=estimation of data node) as input and return one value that is the estimation of the data node.
  • callback (callable, optional) – Callback function to be called after node estimation. This can be any function that takes only one argument that is the data node estimation output. It does not return anything.
  • remote_links (list[[str, Dispatcher]], optional) – List of parent or child dispatcher nodes e.g., [[dsp_id, dsp], …].
  • description (str, optional) – Data node’s description.
  • filters (list[function], optional) – A list of functions that are invoked after the invocation of the main function.
  • kwargs (keyword arguments, optional) – Set additional node attributes using key=value.
Returns:

Data node id.

Return type:

str

***********************************************************************

Example:

Add a data to be estimated or a possible input data node:

>>> dsp.add_data(data_id='a')
'a'

Add a data with a default value (i.e., input data node):

>>> dsp.add_data(data_id='b', default_value=1)
'b'

Create a data node with function estimation and a default value.

  • function estimation: estimate one unique output from multiple estimations.
  • default value: is a default estimation.
>>> def min_fun(kwargs):
...     '''
...     Returns the minimum value of node estimations.
...
...     :param kwargs:
...         Node estimations.
...     :type kwargs: dict
...
...     :return:
...         The minimum value of node estimations.
...     :rtype: float
...     '''
...
...     return min(kwargs.values())
...
>>> dsp.add_data(data_id='c', default_value=2, wait_inputs=True,
...              function=min_fun)
'c'

Create a data with an unknown id and return the generated id:

>>> dsp.add_data()
'unknown'
add_function(function_id=None, function=None, inputs=None, outputs=None, input_domain=None, weight=None, inp_weight=None, out_weight=None, description=None, filters=None, **kwargs)[source]

Add a single function node to dispatcher.

Parameters:
  • function_id (str, optional) – Function node id. If None will be assigned as <fun.__name__>.
  • function (callable, optional) – Data node estimation function.
  • inputs (list, optional) – Ordered arguments (i.e., data node ids) needed by the function.
  • outputs (list, optional) – Ordered results (i.e., data node ids) returned by the function.
  • input_domain (callable, optional) – A function that checks if input values satisfy the function domain. This can be any function that takes the same inputs of the function and returns True if input values satisfy the domain, otherwise False. In this case the dispatch algorithm doesn’t pass on the node.
  • weight (float, int, optional) – Node weight. It is a weight coefficient that is used by the dispatch algorithm to estimate the minimum workflow.
  • inp_weight (dict[str, float | int], optional) – Edge weights from data nodes to the function node. It is a dictionary (key=data node id) with the weight coefficients used by the dispatch algorithm to estimate the minimum workflow.
  • out_weight (dict[str, float | int], optional) – Edge weights from the function node to data nodes. It is a dictionary (key=data node id) with the weight coefficients used by the dispatch algorithm to estimate the minimum workflow.
  • description (str, optional) – Function node’s description.
  • filters (list[function], optional) – A list of functions that are invoked after the invocation of the main function.
  • kwargs (keyword arguments, optional) – Set additional node attributes using key=value.
Returns:

Function node id.

Return type:

str

***********************************************************************

Example:

Add a function node:

>>> def my_function(a, b):
...     c = a + b
...     d = a - b
...     return c, d
...
>>> dsp.add_function(function=my_function, inputs=['a', 'b'],
...                  outputs=['c', 'd'])
'my_function'

Add a function node with domain:

>>> from math import log
>>> def my_log(a, b):
...     return log(b - a)
...
>>> def my_domain(a, b):
...     return a < b
...
>>> dsp.add_function(function=my_log, inputs=['a', 'b'],
...                  outputs=['e'], input_domain=my_domain)
'my_log'
add_dispatcher(dsp, inputs, outputs, dsp_id=None, input_domain=None, weight=None, inp_weight=None, description=None, include_defaults=False, **kwargs)[source]

Add a single sub-dispatcher node to dispatcher.

Parameters:
  • dsp (Dispatcher | dict[str, list]) – Child dispatcher that is added as sub-dispatcher node to the parent dispatcher.
  • inputs (dict[str, str | list[str]] | tuple[str] | (str, .., dict[str, str | list[str]])) – Inputs mapping. Data node ids from parent dispatcher to child sub-dispatcher.
  • outputs (dict[str, str | list[str]] | tuple[str] | (str, .., dict[str, str | list[str]])) – Outputs mapping. Data node ids from child sub-dispatcher to parent dispatcher.
  • dsp_id (str, optional) – Sub-dispatcher node id. If None will be assigned as <dsp.name>.
  • input_domain ((dict) -> bool, optional) –

    A function that checks if input values satisfy the function domain. This can be any function that takes the a dictionary with the inputs of the sub-dispatcher node and returns True if input values satisfy the domain, otherwise False.

    Note

    This function is invoked every time that a data node reach the sub-dispatcher node.

  • weight (float, int, optional) – Node weight. It is a weight coefficient that is used by the dispatch algorithm to estimate the minimum workflow.
  • inp_weight (dict[str, int | float], optional) – Edge weights from data nodes to the sub-dispatcher node. It is a dictionary (key=data node id) with the weight coefficients used by the dispatch algorithm to estimate the minimum workflow.
  • description (str, optional) – Sub-dispatcher node’s description.
  • include_defaults (bool, optional) – If True the default values of the sub-dispatcher are added to the current dispatcher.
  • kwargs (keyword arguments, optional) – Set additional node attributes using key=value.
Returns:

Sub-dispatcher node id.

Return type:

str

***********************************************************************

Example:

Create a sub-dispatcher:

>>> sub_dsp = Dispatcher()
>>> sub_dsp.add_function('max', max, ['a', 'b'], ['c'])
'max'

Add the sub-dispatcher to the parent dispatcher:

>>> dsp.add_dispatcher(dsp_id='Sub-Dispatcher', dsp=sub_dsp,
...                    inputs={'A': 'a', 'B': 'b'},
...                    outputs={'c': 'C'})
'Sub-Dispatcher'

Add a sub-dispatcher node with domain:

>>> def my_domain(kwargs):
...     return kwargs['C'] > 3
...
>>> dsp.add_dispatcher(dsp_id='Sub-Dispatcher with domain',
...                    dsp=sub_dsp, inputs={'C': 'a', 'D': 'b'},
...                    outputs={('c', 'b'): ('E', 'E1')},
...                    input_domain=my_domain)
'Sub-Dispatcher with domain'
add_from_lists(data_list=None, fun_list=None, dsp_list=None)[source]

Add multiple function and data nodes to dispatcher.

Parameters:
  • data_list (list[dict], optional) – It is a list of data node kwargs to be loaded.
  • fun_list (list[dict], optional) – It is a list of function node kwargs to be loaded.
  • dsp_list (list[dict], optional) – It is a list of sub-dispatcher node kwargs to be loaded.
Returns:

  • Data node ids.
  • Function node ids.
  • Sub-dispatcher node ids.

Return type:

(list[str], list[str], list[str])

***********************************************************************

Example:

Define a data list:

>>> data_list = [
...     {'data_id': 'a'},
...     {'data_id': 'b'},
...     {'data_id': 'c'},
... ]

Define a functions list:

>>> def func(a, b):
...     return a + b
...
>>> fun_list = [
...     {'function': func, 'inputs': ['a', 'b'], 'outputs': ['c']}
... ]

Define a sub-dispatchers list:

>>> sub_dsp = Dispatcher(name='Sub-dispatcher')
>>> sub_dsp.add_function(function=func, inputs=['e', 'f'],
...                      outputs=['g'])
'func'
>>>
>>> dsp_list = [
...     {'dsp_id': 'Sub', 'dsp': sub_dsp,
...      'inputs': {'a': 'e', 'b': 'f'}, 'outputs': {'g': 'c'}},
... ]

Add function and data nodes to dispatcher:

>>> dsp.add_from_lists(data_list, fun_list, dsp_list)
(['a', 'b', 'c'], ['func'], ['Sub'])
set_default_value(data_id, value=empty, initial_dist=0.0)[source]

Set the default value of a data node in the dispatcher.

Parameters:
  • data_id (str) – Data node id.
  • value (T, optional) –

    Data node default value.

    Note

    If EMPTY the previous default value is removed.

  • initial_dist (float, int, optional) – Initial distance in the ArciDispatch algorithm when the data node default value is used.

***********************************************************************

Example:

A dispatcher with a data node named a:

>>> dsp = Dispatcher(name='Dispatcher')
...
>>> dsp.add_data(data_id='a')
'a'

Add a default value to a node:

>>> dsp.set_default_value('a', value='value of the data')
>>> list(sorted(dsp.default_values['a'].items()))
[('initial_dist', 0.0), ('value', 'value of the data')]

Remove the default value of a node:

>>> dsp.set_default_value('a', value=EMPTY)
>>> dsp.default_values
{}

Set a remote link of a data node in the dispatcher.

Parameters:
  • data_id (str) – Data node id.
  • remote_link ([str, Dispatcher], optional) – Parent or child dispatcher and its node id (id, dsp).
  • is_parent (bool) – If True the link is inflow (parent), otherwise is outflow (child).
get_sub_dsp(nodes_bunch, edges_bunch=None)[source]

Returns the sub-dispatcher induced by given node and edge bunches.

The induced sub-dispatcher contains the available nodes in nodes_bunch and edges between those nodes, excluding those that are in edges_bunch.

The available nodes are non isolated nodes and function nodes that have all inputs and at least one output.

Parameters:
  • nodes_bunch (list[str], iterable) – A container of node ids which will be iterated through once.
  • edges_bunch (list[(str, str)], iterable, optional) – A container of edge ids that will be removed.
Returns:

A dispatcher.

Return type:

Dispatcher

Note

The sub-dispatcher edge or node attributes just point to the original dispatcher. So changes to the node or edge structure will not be reflected in the original dispatcher map while changes to the attributes will.

***********************************************************************

Example:

A dispatcher with a two functions fun1 and fun2:

digraph dmap { graph [ratio=1] node [style=filled] label = <dmap> splines = ortho style = filled 82 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">a</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=a] 83 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">b</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=b] 84 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">c</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=c] 85 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">d</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=d] 86 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">e</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=e] 87 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-cf28632e9a1c3ff2118ae3a6dc7f1f912abc76c5/fun1-function.html">fun1</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip=fun1] 88 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-cf28632e9a1c3ff2118ae3a6dc7f1f912abc76c5/fun2-function.html">fun2</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip=fun2] 88 -> 84 87 -> 85 82 -> 87 88 -> 86 87 -> 84 85 -> 88 82 -> 88 83 -> 87 }

Get the sub-dispatcher induced by given nodes bunch:

>>> sub_dsp = dsp.get_sub_dsp(['a', 'c', 'd', 'e', 'fun2'])

digraph dmap { graph [ratio=1] node [style=filled] label = <dmap> splines = ortho style = filled 97 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">a</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=a] 98 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">c</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=c] 99 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">d</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=d] 100 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">e</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=e] 101 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-7ddcc5d67e9a008b8aefaa9fe16ccafecfc0f2a0/fun2-function.html">fun2</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip=fun2] 101 -> 98 97 -> 101 101 -> 100 99 -> 101 }

get_sub_dsp_from_workflow(sources, graph=None, reverse=False, add_missing=False, check_inputs=True, blockers=None, wildcard=False, _update_links=True)[source]

Returns the sub-dispatcher induced by the workflow from sources.

The induced sub-dispatcher of the dsp contains the reachable nodes and edges evaluated with breadth-first-search on the workflow graph from source nodes.

Parameters:
  • sources (list[str], iterable) – Source nodes for the breadth-first-search. A container of nodes which will be iterated through once.
  • graph (networkx.DiGraph, optional) – A directed graph where evaluate the breadth-first-search.
  • reverse (bool, optional) – If True the workflow graph is assumed as reversed.
  • add_missing (bool, optional) – If True, missing function’ inputs are added to the sub-dispatcher.
  • check_inputs (bool, optional) – If True the missing function’ inputs are not checked.
  • blockers (set[str], iterable, optional) – Nodes to not be added to the queue.
  • 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.
  • _update_links (bool, optional) – If True, it updates remote links of the extracted dispatcher.
Returns:

A sub-dispatcher.

Return type:

Dispatcher

See also

get_sub_dsp()

Note

The sub-dispatcher edge or node attributes just point to the original dispatcher. So changes to the node or edge structure will not be reflected in the original dispatcher map while changes to the attributes will.

***********************************************************************

Example:

A dispatcher with a function fun and a node a with a default value:

digraph dmap { graph [ratio=1] node [style=filled] label = <dmap> splines = ortho style = filled 106 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">a</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">1</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=a] 107 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">b</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=b] 108 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">c</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=c] 109 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">d</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=d] 110 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">e</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=e] 111 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-abef0f1465688da0fd5881f28575dfda1a070fba/fun1-function.html">fun1</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip=fun1] 112 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-abef0f1465688da0fd5881f28575dfda1a070fba/fun2-function.html">fun2</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip=fun2] 112 -> 108 111 -> 109 106 -> 111 111 -> 108 107 -> 111 110 -> 112 }

Dispatch with no calls in order to have a workflow:

>>> o = dsp.dispatch(inputs=['a', 'b'], no_call=True)

Get sub-dispatcher from workflow inputs a and b:

>>> sub_dsp = dsp.get_sub_dsp_from_workflow(['a', 'b'])

digraph dmap { graph [ratio=1] node [style=filled] label = <dmap> splines = ortho style = filled 119 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">a</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">1</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=a] 120 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">b</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=b] 121 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">c</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=c] 122 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">d</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=d] 123 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-e779287d555f65d95f0149bf5a36d54eff848162/fun1-function.html">fun1</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip=fun1] 123 -> 122 120 -> 123 119 -> 123 123 -> 121 }

Get sub-dispatcher from a workflow output c:

>>> sub_dsp = dsp.get_sub_dsp_from_workflow(['c'], reverse=True)

digraph dmap { graph [ratio=1] node [style=filled] label = <dmap> splines = ortho style = filled 128 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">a</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">1</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=a] 129 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">b</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=b] 130 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">c</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=c] 131 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-529b2ebd718265a855b76046a49bacbc27e9a99e/fun1-function.html">fun1</TD></TR><TR><TD align="RIGHT" border="1">M_outputs</TD><TD align="LEFT" border="1">(&#x27;d&#x27;,)</TD></TR></TABLE>> fillcolor=orange shape=box tooltip=fun1] 129 -> 131 128 -> 131 131 -> 130 }

data_nodes

Returns all data nodes of the dispatcher.

Returns:All data nodes of the dispatcher.
Return type:dict[str, dict]
function_nodes

Returns all function nodes of the dispatcher.

Returns:All data function of the dispatcher.
Return type:dict[str, dict]
sub_dsp_nodes

Returns all sub-dispatcher nodes of the dispatcher.

Returns:All sub-dispatcher nodes of the dispatcher.
Return type:dict[str, dict]
copy()[source]

Returns a copy of the Dispatcher.

Returns:A copy of the Dispatcher.
Return type:Dispatcher

Example:

>>> dsp = Dispatcher()
>>> dsp is dsp.copy()
False
dispatch(inputs=None, outputs=None, cutoff=None, inputs_dist=None, wildcard=False, no_call=False, shrink=False, rm_unused_nds=False, select_output_kw=None, _wait_in=None, stopper=None)[source]

Evaluates the minimum workflow and data outputs of the dispatcher model from given inputs.

Parameters:
  • inputs (dict[str, T], list[str], iterable, optional) – Input data values.
  • outputs (list[str], iterable, optional) – Ending data nodes.
  • cutoff (float, int, optional) – Depth to stop the search.
  • inputs_dist (dict[str, int | float], optional) – Initial distances of input data nodes.
  • 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.
  • no_call (bool, optional) – If True data node estimation function is not used and the input values are not used.
  • shrink (bool, optional) –

    If True the dispatcher is shrink before the dispatch.

    See also

    shrink_dsp()

  • rm_unused_nds (bool, optional) – If True unused function and sub-dispatcher nodes are removed from workflow.
  • select_output_kw (dict, optional) – Kwargs of selector function to select specific outputs.
  • _wait_in (dict, optional) – Override wait inputs.
  • stopper (threading.Event, optional) – A semaphore to abort the dispatching.
Returns:

Dictionary of estimated data node outputs.

Return type:

schedula.utils.sol.Solution

***********************************************************************

Example:

A dispatcher with a function \(log(b - a)\) and two data a and b with default values:

digraph dmap { graph [ratio=1] node [style=filled] label = <dmap> splines = ortho style = filled 0 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">a</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=a] 1 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">b</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">5</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=b] 2 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">c</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=c] 3 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">d</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">1</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=d] 4 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">e</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=e] 5 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-6f3d4c386651ea551538ec292ef6e138750921c3/my_log.html">log(b - a)</TD></TR><TR><TD align="RIGHT" border="1">input_domain</TD><TD align="LEFT" border="1" href="./dispatcher-6f3d4c386651ea551538ec292ef6e138750921c3/my_domain.html">my_domain</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="log(b - a)"] 6 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-6f3d4c386651ea551538ec292ef6e138750921c3/min.html">min</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="min(iterable, *[, default=obj, key=func]) -> value"] 1 -> 6 0 -> 6 3 -> 5 6 -> 2 2 -> 5 5 -> 4 }

Dispatch without inputs. The default values are used as inputs:

>>> outputs = dsp.dispatch()
>>> outputs
Solution([('a', 0), ('b', 5), ('d', 1), ('c', 0), ('e', 0.0)])

digraph workflow { graph [ratio=1] node [style=filled] label = <workflow> splines = ortho style = filled 13 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-c2b2e58cce9c9beffc9faa9a74c41f7ea0093e30/a-output.html">a</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">0</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">0.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=a] 14 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-c2b2e58cce9c9beffc9faa9a74c41f7ea0093e30/b-output.html">b</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">5</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">0.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=b] 15 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-c2b2e58cce9c9beffc9faa9a74c41f7ea0093e30/c-output.html">c</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">2.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=c] 16 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-c2b2e58cce9c9beffc9faa9a74c41f7ea0093e30/d-output.html">d</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">1</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">0.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=d] 17 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-c2b2e58cce9c9beffc9faa9a74c41f7ea0093e30/e-output.html">e</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">4.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=e] 18 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-c2b2e58cce9c9beffc9faa9a74c41f7ea0093e30/my_log.html">log(b - a)</TD></TR><TR><TD align="RIGHT" border="1">solution_domain</TD><TD align="LEFT" border="1" href="./dispatcher-c2b2e58cce9c9beffc9faa9a74c41f7ea0093e30/log(b_-_a)-solution_domain.html">log(b - a)-solution_domain</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">3.0</TD></TR><TR><TD align="RIGHT" border="1">started</TD><TD align="LEFT" border="1">2018-10-08T22:02:34.426270</TD></TR><TR><TD align="RIGHT" border="1">duration</TD><TD align="LEFT" border="1">0:00:00.000006</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="log(b - a)"] 19 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-c2b2e58cce9c9beffc9faa9a74c41f7ea0093e30/min.html">min</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">1.0</TD></TR><TR><TD align="RIGHT" border="1">started</TD><TD align="LEFT" border="1">2018-10-08T22:02:34.426206</TD></TR><TR><TD align="RIGHT" border="1">duration</TD><TD align="LEFT" border="1">0:00:00.000007</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="min(iterable, *[, default=obj, key=func]) -> value"] 20 [label=start fillcolor=red shape=egg] 14 -> 19 15 -> 18 20 -> 14 16 -> 18 20 -> 13 20 -> 16 18 -> 17 13 -> 19 19 -> 15 }

Dispatch until data node c is estimated:

>>> outputs = dsp.dispatch(outputs=['c'])
>>> outputs
Solution([('a', 0), ('b', 5), ('c', 0)])

digraph workflow { graph [ratio=1] node [style=filled] label = <workflow> splines = ortho style = filled 30 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-459a8c9c07bc15724ed07fe0d76824dad9796cea/a-output.html">a</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">0</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">0.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=a] 31 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-459a8c9c07bc15724ed07fe0d76824dad9796cea/b-output.html">b</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">5</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">0.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=b] 32 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-459a8c9c07bc15724ed07fe0d76824dad9796cea/c-output.html">c</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">2.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=c] 33 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-459a8c9c07bc15724ed07fe0d76824dad9796cea/min.html">min</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">1.0</TD></TR><TR><TD align="RIGHT" border="1">started</TD><TD align="LEFT" border="1">2018-10-08T22:02:34.466621</TD></TR><TR><TD align="RIGHT" border="1">duration</TD><TD align="LEFT" border="1">0:00:00.000006</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="min(iterable, *[, default=obj, key=func]) -> value"] 34 [label=start fillcolor=red shape=egg] 33 -> 32 31 -> 33 30 -> 33 34 -> 30 34 -> 31 }

Dispatch with one inputs. The default value of a is not used as inputs:

>>> outputs = dsp.dispatch(inputs={'a': 3})
>>> outputs
Solution([('a', 3), ('b', 5), ('d', 1), ('c', 3)])

digraph workflow { graph [ratio=1] node [style=filled] label = <workflow> splines = ortho style = filled 40 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-4468933c3db847ff99f6096d6c64652af444fdc5/a-output.html">a</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">0</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">0.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=a] 41 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-4468933c3db847ff99f6096d6c64652af444fdc5/b-output.html">b</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">5</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">0.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=b] 42 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-4468933c3db847ff99f6096d6c64652af444fdc5/c-output.html">c</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">2.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=c] 43 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-4468933c3db847ff99f6096d6c64652af444fdc5/d-output.html">d</TD></TR><TR><TD align="RIGHT" border="1">default</TD><TD align="LEFT" border="1">1</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">0.0</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=d] 44 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-4468933c3db847ff99f6096d6c64652af444fdc5/my_log.html">log(b - a)</TD></TR><TR><TD align="RIGHT" border="1">input_domain</TD><TD align="LEFT" border="1" href="./dispatcher-4468933c3db847ff99f6096d6c64652af444fdc5/my_domain.html">my_domain</TD></TR><TR><TD align="RIGHT" border="1">M_outputs</TD><TD align="LEFT" border="1">(&#x27;e&#x27;,)</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">3.0</TD></TR></TABLE>> fillcolor=orange shape=box tooltip="log(b - a)"] 45 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-4468933c3db847ff99f6096d6c64652af444fdc5/min.html">min</TD></TR><TR><TD align="RIGHT" border="1">distance</TD><TD align="LEFT" border="1">1.0</TD></TR><TR><TD align="RIGHT" border="1">started</TD><TD align="LEFT" border="1">2018-10-08T22:02:34.489880</TD></TR><TR><TD align="RIGHT" border="1">duration</TD><TD align="LEFT" border="1">0:00:00.000005</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="min(iterable, *[, default=obj, key=func]) -> value"] 46 [label=start fillcolor=red shape=egg] 41 -> 45 40 -> 45 46 -> 41 43 -> 44 46 -> 40 46 -> 43 42 -> 44 45 -> 42 }

shrink_dsp(inputs=None, outputs=None, cutoff=None, inputs_dist=None, wildcard=True)[source]

Returns a reduced dispatcher.

Parameters:
  • inputs (list[str], iterable, optional) – Input data nodes.
  • outputs (list[str], iterable, optional) – Ending data nodes.
  • cutoff (float, int, optional) – Depth to stop the search.
  • inputs_dist (dict[str, int | float], optional) – Initial distances of input data nodes.
  • 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.
Returns:

A sub-dispatcher.

Return type:

Dispatcher

See also

dispatch()

***********************************************************************

Example:

A dispatcher like this:

digraph dmap { graph [ratio=1] node [style=filled] label = <dmap> splines = ortho style = filled 149 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">a</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=a] 150 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">b</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=b] 151 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">c</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=c] 152 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">d</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=d] 153 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">e</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=e] 154 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">f</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=f] 155 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-d6b3fb0daf47d40e912db57cc7135de25f4d204b/fun1-function.html">fun1</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip=fun1] 156 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-d6b3fb0daf47d40e912db57cc7135de25f4d204b/fun2-function.html">fun2</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip=fun2] 157 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-d6b3fb0daf47d40e912db57cc7135de25f4d204b/min.html">fun3</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="min(iterable, *[, default=obj, key=func]) -> value"] 158 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-d6b3fb0daf47d40e912db57cc7135de25f4d204b/max.html">fun4</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="max(iterable, *[, default=obj, key=func]) -> value"] 159 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-d6b3fb0daf47d40e912db57cc7135de25f4d204b/max-0.html">fun5</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip="max(iterable, *[, default=obj, key=func]) -> value"] 160 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">g</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=g] 150 -> 155 159 -> 154 154 -> 157 158 -> 160 152 -> 156 149 -> 158 150 -> 156 152 -> 159 153 -> 159 149 -> 155 159 -> 151 150 -> 158 156 -> 153 152 -> 157 157 -> 160 155 -> 151 }

Get the sub-dispatcher induced by dispatching with no calls from inputs a, b, and c to outputs c, e, and f:

>>> shrink_dsp = dsp.shrink_dsp(inputs=['a', 'b', 'd'],
...                             outputs=['c', 'f'])

digraph dmap { graph [ratio=1] node [style=filled] label = <dmap> splines = ortho style = filled 177 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">a</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=a] 178 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">b</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=b] 179 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">c</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=c] 180 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">d</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=d] 181 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">e</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=e] 182 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2">f</TD></TR></TABLE>> fillcolor=cyan shape=box style="rounded,filled" tooltip=f] 183 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-5f0fb3bb7bc095944a751068eaa9c5408362c207/fun1-function.html">fun1</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip=fun1] 184 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-5f0fb3bb7bc095944a751068eaa9c5408362c207/fun2-function.html">fun2</TD></TR></TABLE>> fillcolor=springgreen shape=box tooltip=fun2] 185 [label=<<TABLE border="0" cellspacing="0"><TR><TD border="0" colspan="2" href="./dispatcher-5f0fb3bb7bc095944a751068eaa9c5408362c207/max.html">fun5</TD></TR><TR><TD align="RIGHT" border="1">M_outputs</TD><TD align="LEFT" border="1">(&#x27;c&#x27;,)</TD></TR></TABLE>> fillcolor=orange shape=box tooltip="max(iterable, *[, default=obj, key=func]) -> value"] 178 -> 183 185 -> 182 184 -> 181 183 -> 179 180 -> 184 177 -> 183 178 -> 184 180 -> 185 181 -> 185 }