7.1.1.11. get_sub_dsp_from_workflow

Dispatcher.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 }