cottax.consumers.execution.run module

What can run (CallableGraph), and running it (run).

check_function_callable[N: Label, V: Place](name: N, node: NodeDefinition[V])[source]

Callable function for functional nodes

Return type:

Iterator[Violation]

check_implements_its_driver[N: Label, V: Place](name: N, node: NodeDefinition[V])[source]

Check: - is the implementation a DriverImplementation - is the node implementing the driver contract? - Is the implementation capable of taking and reporting the contract’s (chosen) input data and reports?

Return type:

Iterator[Violation]

class CallableGraph[N: Label, V: Place](graph: NestingGraph[N, V])[source]

Bases: RealisedGraph[N, V], Generic[N, V]

A realised graph whose every implementation is callable / driver implemented

checks_node: PerLevel[tuple[Callable[[N, NodeDefinition[V]], Iterator[Violation]], ...]] = (<function check_function_callable>, <function check_implements_its_driver>)

the one thing a level below adds.

Type:

(name, node) -> violations

check_callable(valued: GraphWithValues)[source]
Return type:

Iterator[Violation]

run[N: Label, V: Place](valued: GraphWithValues[CallableGraph[N, V], V])[source]

Every place with a value: the inputs, and everything the graph computes.

Return type:

OrderedMap[V, Any]

class Env[V](values: Iterable[tuple[V, Any]] | Mapping[V, Any] = ())[source]

Bases: Generic[V]

The values so far during a walk, by place.

values: dict[V, Any]
read(places: Iterable[V])[source]
Return type:

tuple[Any, ...]

write(places: tuple[V, ...], values: Iterable[Any])[source]
Return type:

None

type AtSolve = Callable[[DrivenNode, SteppedExecutableGraph, Env], None]

What a walk does at a Solve, handed the problem, its interior and the values so far: it writes the unknowns and the reports, and walks the interior if it wants its values.

walk(graph: SteppedExecutableGraph, env: Env, at_solve: AtSolve)[source]

graph’s steps in order, a Run called and a Solve handed to at_solve: run is this loop with “solve it” at a solve. What a step raises names its node (blamed).

Return type:

None

blamed(e: BaseException)[source]

The node whose step raised e, the innermost; None if no step did.

Return type:

Any

class InteriorConditionMap[N: Label, V: Place](interior: CallableGraph[N, V], unknowns: tuple[V, ...], context_places: tuple[V, ...], conditions: tuple[V, ...])[source]

Bases: ConditionMap, Generic[N, V]

A condition map by one walk of a solve’s interior. It holds a graph and places, so it hashes and compares by value.

interior: CallableGraph[N, V]
unknowns: tuple[V, ...]

Where the unknowns’ values go.

context_places: tuple[V, ...]

where context goes, in order. Fixed while the solve iterates.

Type:

What the interior reads from outside, the unknowns aside

conditions: tuple[V, ...]

the condition’s reads, its conditions then its parameters.

Type:

Where the answer is read

classmethod posing(node: DrivenNode[V], interior: CallableGraph[N, V])[source]

The map run hands node’s driver, interior its Solve’s. Fixed: what the interior reads from outside, and what the condition reads that the interior does not produce (a parameter); the map answers at every condition read.

Return type:

InteriorConditionMap[N, V]