A function composition framework that supports:
- State - functions which retain state for their next turn of action.
- Prioritized paths - lazily attempt overloaded composition paths according to priorities.
- Deep dependency injection - compose a function to a variadic function at the end of an arbitrarily long pipeline.
- Non cancerous
asynciosupport.
pip install computation-graph
To deploy: python setup.py sdist bdist_wheel; twine upload dist/*; rm -rf dist/;
Node identity and duplication
A node is a function plus the wiring that feeds it. Composing the same function twice with the same inputs yields one shared node: edges are a frozenset, and equal edges collapse. Use duplicate_function / duplicate_graph (computation_graph/composers/duplication.py) only when the same function must take different inputs at the same parameter within one graph, which otherwise fails the build with "There are multiple edges with the same destination, key and priority". Input-less nodes never need it, and every needless copy is a permanent extra node. The module docstring spells out the rule and the cases that do not need it.
Type checking
The runner will type check all outputs for nodes with return type annotations. In case of a wrong typing, it will log the node at fault.
Debugging
Computation trace
Available computation trace visualizers:
graphviz.computation_tracemermaid.computation_traceascii.computation_trace
To use, replace to_callable with run.to_callable_with_side_effect with your selected style as the first argument.
Graphviz debugger
This debugger will save a file on each graph execution to current working directory.
You can use this file in a graph viewer like gephi. Nodes colored red are part of the 'winning' computation path. Each of these nodes has the attributes 'result' and 'state'. 'result' is the output of the node, and 'state' is the new state of the node.
In gephi you can filter for the nodes participating in calculation of final result by filtering on result != null.
Metadata
Release files for computation-graph 79
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| computation_graph-79.tar.gz | 36.3 kB | Details |
Release files / computation_graph-79.tar.gz
| Download URL | computation_graph-79.tar.gz |
|---|---|
| Size | 36.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e57b766db6040772ee26ec1714f920ecff59a643fce67d862ea15a33e422d68
|
|
BLAKE2b-256 checksum How to use checksums |
9fece5c60dfd1d4b918c6a3effa658d8ce471bad5ec5bfa58338568bcc5b63d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.0
|