8.2.15.1. Solution

class Solution(*args, **kwargs)[source]

Solution class for dispatch result.

Methods

__class_getitem__

See PEP 585

__contains__

True if the dictionary has the specified key, else False.

__deepcopy__

__delattr__

Implement delattr(self, name).

__delitem__

Delete self[key].

__dir__

Default dir() implementation.

__eq__

Return self==value.

__format__

Default object formatter.

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__getitem__

x.__getitem__(y) <==> x[y]

__getstate__

Helper for pickle.

__gt__

Return self>value.

__hash__

Return hash(self).

__init__

__init_subclass__

This method is called when a class is subclassed.

__ior__

Return self|=value.

__iter__

Implement iter(self).

__le__

Return self<=value.

__len__

Return len(self).

__lt__

Return self<value.

__ne__

Return self!=value.

__new__

__or__

Return self|value.

__reduce__

Return state information for pickling

__reduce_ex__

Helper for pickle.

__repr__

Return repr(self).

__reversed__

od.__reversed__() <==> reversed(od)

__ror__

Return value|self.

__setattr__

Implement setattr(self, name, value).

__setitem__

Set self[key] to value.

__sizeof__

Size of object in memory, in bytes.

__str__

Return str(self).

__subclasshook__

Abstract classes can override this to customize issubclass().

_add_initial_value

Add initial values updating workflow, seen, and fringe.

_add_out_dsp_inputs

_apply_filters

_check_function_domain

_check_sub_dsp_domain

_clean_set

_close

_copy_structure

_dsp_closed_add

_ended

_evaluate_function

_evaluate_node

_get_node_estimations

Returns the data nodes estimations and wait_inputs flag.

_init_sub_dsp

Initialize the dispatcher as sub-dispatcher and update the fringe.

_init_workflow

_remove_unused_nodes

Removes unused function and sub-dispatcher nodes.

_remove_wait_in

_run

_see_node

See a node, updating seen and fringe.

_see_remote_link_node

See data remote links of the node (set output to remote links).

_set_data_node_output

Set the data node output from node estimations.

_set_dsp_features

_set_function_node_output

Set the function node output from node inputs.

_set_inputs

_set_node_output

Set the node outputs from node inputs.

_set_sub_dsp_node_input

Initializes the sub-dispatcher and set its inputs.

_set_wildcards

Update wildcards set with the input data nodes that are also outputs.

_started

_update_fut_results

_update_meeting

_update_methods

_verbose

_visit_nodes

Visits a node, updating workflow, seen, and fringe..

_warning

Handles the error messages.

check_targets

Terminates ArciDispatch algorithm when all targets have been visited.

check_wait_in

Stops the search of the investigated node of the ArciDispatch algorithm, until all inputs are satisfied.

clear

od.clear() -> None.

copy

od.copy() -> a shallow copy of od

form

Creates a dispatcher Form Flask app.

fromkeys

Create a new ordered dictionary with keys from iterable and values set to value.

get

Return the value for key if key is in the dictionary, else default.

get_node

Returns a sub node of a dispatcher.

get_sub_dsp_from_workflow

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

items

D.items() -> a set-like object providing a view on D's items

keys

D.keys() -> a set-like object providing a view on D's keys

move_to_end

Move an existing element to the end (or beginning if last is false).

plot

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

pop

od.pop(key[,default]) -> v, remove specified key and return the corresponding value.

popitem

Remove and return a (key, value) pair from the dictionary.

result

Set all asynchronous results.

setdefault

Insert key with a value of default if key is not in the dictionary.

update

D.update([E, ]**F) -> None.

values

D.values() -> an object providing a view on D's values

web

Creates a dispatcher Flask app.

__init__(dsp=None, inputs=None, outputs=None, wildcard=False, inputs_dist=None, no_call=False, rm_unused_nds=False, wait_in=None, no_domain=False, _empty=False, index=(-1,), full_name=(), verbose=False, excluded_defaults=())[source]

Attributes

__annotations__

__dict__

__doc__

__module__

__weakref__

list of weak references to the object

pipe

Returns the full pipe of a dispatch run.

__hash__()[source]

Return hash(self).

__repr__()[source]

Return repr(self).

__init__(dsp=None, inputs=None, outputs=None, wildcard=False, inputs_dist=None, no_call=False, rm_unused_nds=False, wait_in=None, no_domain=False, _empty=False, index=(-1,), full_name=(), verbose=False, excluded_defaults=())[source]
_set_dsp_features(dsp)[source]
_set_inputs(inputs, initial_dist, excluded_defaults=())[source]
_set_wildcards(wildcard, inputs=None, outputs=None)[source]

Update wildcards set with the input data nodes that are also outputs.

Parameters:
  • wildcard (bool, int) – 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. If it is equal to 2, the the data node that cannot be calculated are excluded by the wildcard condition.

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

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

_update_methods()[source]
check_wait_in(wait_in, n_id)[source]

Stops the search of the investigated node of the ArciDispatch algorithm, until all inputs are satisfied.

Parameters:
  • wait_in (bool) – If True the node is waiting input estimations.

  • n_id (str) – Data or function node id.

Returns:

True if all node inputs are satisfied, otherwise False.

Return type:

bool

_clean_set()[source]
_init_workflow(inputs=None, inputs_dist=None, initial_dist=0.0, clean=True)[source]
_close(cached_ids)[source]
static _update_fut_results(futs, fut, data, key)[source]
result(timeout=None)[source]

Set all asynchronous results.

Parameters:

timeout (float) – The number of seconds to wait for the result if the futures aren’t done. If None, then there is no limit on the wait time.

Returns:

Update Solution.

Return type:

Solution

static _dsp_closed_add(dsp_closed, s)[source]
_run(stopper=None, executor=False)[source]
get_sub_dsp_from_workflow(sources, reverse=False, add_missing=False, check_inputs=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.

  • 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.

Returns:

A sub-dispatcher.

Return type:

schedula.dispatcher.Dispatcher

property pipe

Returns the full pipe of a dispatch run.

_copy_structure(**kwargs)[source]
__deepcopy__(memo)[source]
_add_out_dsp_inputs()[source]
check_targets(node_id)[source]

Terminates ArciDispatch algorithm when all targets have been visited.

Parameters:

node_id (str) – Data or function node id.

Returns:

True if all targets have been visited, otherwise False.

Return type:

bool

_get_node_estimations(node_attr, node_id)[source]

Returns the data nodes estimations and wait_inputs flag.

Parameters:
  • node_attr (dict) – Dictionary of node attributes.

  • node_id (str) – Data node’s id.

Returns:

  • node estimations with minimum distance from the starting node, and

  • wait_inputs flag

Return type:

(dict[str, T], bool)

_remove_wait_in()[source]
_set_node_output(node_id, no_call, next_nds=None, **kw)[source]

Set the node outputs from node inputs.

Parameters:
  • node_id (str) – Data or function node id.

  • no_call (bool) – If True data node estimation function is not used.

Returns:

If the output have been evaluated correctly.

Return type:

bool

_evaluate_function(args, node_id, node_attr, attr, stopper=None, executor=False)[source]
_check_function_domain(args, node_attr, node_id)[source]
_evaluate_node(args, node_attr, node_id, skip_func=False, **kw)[source]
_set_data_node_output(node_id, node_attr, no_call, next_nds=None, **kw)[source]

Set the data node output from node estimations.

Parameters:
  • node_id (str) – Data node id.

  • node_attr (dict[str, T]) – Dictionary of node attributes.

  • no_call (bool) – If True data node estimations are not used.

Returns:

If the output have been evaluated correctly.

Return type:

bool

_apply_filters(res, node_id, node_attr, attr, stopper=None, executor=False)[source]
_started(attr, node_id)[source]
_ended(attr, node_id)[source]
_verbose(node_id, attr, end=False)[source]
_set_function_node_output(node_id, node_attr, no_call, next_nds=None, **kw)[source]

Set the function node output from node inputs.

Parameters:
  • node_id (str) – Function node id.

  • node_attr (dict[str, T]) – Dictionary of node attributes.

  • no_call (bool) – If True data node estimation function is not used.

Returns:

If the output have been evaluated correctly.

Return type:

bool

_add_initial_value(data_id, value, initial_dist=0.0, fringe=None, no_call=None)[source]

Add initial values updating workflow, seen, and fringe.

Parameters:
  • fringe (list[(float | int, bool, (str, Dispatcher)]) – Heapq of closest available nodes.

  • no_call (bool) – If True data node estimation function is not used.

  • data_id (str) – Data node id.

  • value (dict[str, T]) – Data node value e.g., {‘value’: val}.

  • initial_dist (float, int, optional) – Data node initial distance in the ArciDispatch algorithm.

Returns:

True if the data has been visited, otherwise false.

Return type:

bool

_update_meeting(node_id, dist)[source]
_visit_nodes(node_id, dist, fringe, no_call=False, **kw)[source]

Visits a node, updating workflow, seen, and fringe..

Parameters:
  • node_id (str) – Node id to visit.

  • dist (float, int) – Distance from the starting node.

  • fringe (list[(float | int, bool, (str, Dispatcher)]) – Heapq of closest available nodes.

  • no_call (bool, optional) – If True data node estimation function is not used.

Returns:

False if all dispatcher targets have been reached, otherwise True.

Return type:

bool

_see_node(node_id, fringe, dist, w_wait_in=0)[source]

See a node, updating seen and fringe.

Parameters:
  • node_id (str) – Node id to see.

  • fringe (list[(float | int, bool, (str, Dispatcher)]) – Heapq of closest available nodes.

  • dist (float, int) – Distance from the starting node.

  • w_wait_in (int, float) – Additional weight for sorting correctly the nodes in the fringe.

Returns:

True if the node is visible, otherwise False.

Return type:

bool

_remove_unused_nodes()[source]

Removes unused function and sub-dispatcher nodes.

_init_sub_dsp(dsp, fringe, outputs, no_call, initial_dist, index, full_name, excluded_defaults)[source]

Initialize the dispatcher as sub-dispatcher and update the fringe.

Parameters:
  • fringe (list[(float | int, bool, (str, Dispatcher)]) – Heapq of closest available nodes.

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

  • no_call (bool) – If True data node estimation function is not used.

See data remote links of the node (set output to remote links).

Parameters:
  • node_id (str) – Node id.

  • fringe (list[(float | int, bool, (str, Dispatcher)]) – Heapq of closest available nodes.

  • dist (float, int) – Distance from the starting node.

  • check_dsp ((Dispatcher) -> bool) – A function to check if the remote dispatcher is ok.

_check_sub_dsp_domain(dsp_id, node, pred, kw)[source]
_set_sub_dsp_node_input(node_id, dsp_id, fringe, no_call, initial_dist)[source]

Initializes the sub-dispatcher and set its inputs.

Parameters:
  • node_id (str) – Input node to set.

  • dsp_id (str) – Sub-dispatcher node id.

  • fringe (list[(float | int, bool, (str, Dispatcher)]) – Heapq of closest available nodes.

  • no_call (bool) – If True data node estimation function is not used.

  • initial_dist (int, float) – Distance to reach the sub-dispatcher node.

Returns:

If the input have been set.

Return type:

bool

_warning(msg, node_id, ex, *args, **kwargs)[source]

Handles the error messages.

Note

If self.raises is True the dispatcher interrupt the dispatch when an error occur, otherwise if raises != ‘’ it logs a warning.

__annotations__ = {}
__doc__ = 'Solution class for dispatch result.'
__module__ = 'schedula.utils.sol'