Payload-agnostic, generically typed framework for composing flow graphs from sources, transformers, reducers, sinks, and combinators.
Project description
Flow
Payload-agnostic, generically typed framework for composing flow graphs from sources, transformers, reducers, sinks, and combinators.
Overview
vcti.flow models a computation as a right-to-left graph of nodes: a Source
produces a value, a Transformer maps one value to another, a Reducer
combines many values into one, and a Sink consumes a value and passes it
through. Calling execute() on the final node pulls the whole graph.
The framework is generic over the payload type — Node[OutT], with
Transformer[InT, OutT] and Reducer[InT, OutT] carrying type transitions — so
the same graph machinery works for any payload (NumPy arrays, dataclasses,
domain objects). It never inspects payloads: the type parameters are
compile-time documentation, and there are no runtime dependencies. Fan-out and
other graph constructions live in a small combinator layer
(for_each, …) rather than as node types.
Installation
pip install vcti-flow
In requirements.txt
vcti-flow>=2.0.0
In pyproject.toml dependencies
dependencies = [
"vcti-flow>=2.0.0",
]
Quick Start
from vcti.flow.core import Source, Transformer, Reducer, Sink, for_each
# A source produces a value (0 -> 1)
class Constant(Source[int]):
def __init__(self, value: int) -> None:
super().__init__()
self._value = value
def load(self) -> int:
return self._value
# A transformer maps one value to another (1 -> 1; type may change)
class Double(Transformer[int, int]):
def transform(self, record: int) -> int:
return record * 2
# A reducer combines many values into one (N -> 1)
class Sum(Reducer[int, int]):
def reduce(self, records: list[int]) -> int:
return sum(records)
# Compose right-to-left and execute
result = Double().connect(Constant(21)).execute() # 42
# Combine two sources
total = Sum().connect(Constant(1)).connect(Constant(2)).execute() # 3
# Fan out into one flow per item (a combinator, not a node)
for key, node in for_each(Constant(3), range, Constant):
print(key, node.execute()) # 0 0 / 1 1 / 2 2
Node taxonomy
| Kind | Arity | Implement |
|---|---|---|
Source[OutT] |
0 → 1 | load() |
Transformer[InT, OutT] |
1 → 1 | transform(record) |
Reducer[InT, OutT] |
N → 1 | reduce(records) |
Sink[T] |
1 → 1 (passthrough) | save(record) (optional) |
for_each(...) |
1 → N | combinator (graph construction) |
Observer[OutT] observes connect / before-execute / after-execute events
(subclass ObserverBase to override only the events you need);
execute_cached() memoises shared nodes in diamond graphs; validate() checks
for cycles and wrong input counts before running. Framework errors derive from
FlowError (FlowWiringError, FlowStateError, FlowValidationError).
See the docs for more: patterns (practical recipes), design (concepts and rationale), extending (adding combinators and wrappers), and runnable examples/.
Dependencies
None. Standard library only.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vcti_flow-2.0.0.tar.gz.
File metadata
- Download URL: vcti_flow-2.0.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2a8106dc7cadcf8b68c78ea800686b59544f9c2bc9282f87b637b673b46f18d
|
|
| MD5 |
7e226d05bfa3b9d514adfaf159266fb5
|
|
| BLAKE2b-256 |
344a5a2754fd409cd81707b97241300115457b42868a1e352fc18f03e5e2bd29
|
Provenance
The following attestation bundles were made for vcti_flow-2.0.0.tar.gz:
Publisher:
release.yml on vcollab/vcti-python-flow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vcti_flow-2.0.0.tar.gz -
Subject digest:
f2a8106dc7cadcf8b68c78ea800686b59544f9c2bc9282f87b637b673b46f18d - Sigstore transparency entry: 1989185872
- Sigstore integration time:
-
Permalink:
vcollab/vcti-python-flow@605d8156b875bff7e69fa4034849af8f09b012e1 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/vcollab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@605d8156b875bff7e69fa4034849af8f09b012e1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file vcti_flow-2.0.0-py3-none-any.whl.
File metadata
- Download URL: vcti_flow-2.0.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
881b9e46cb496eb4a5611aa02d469151ee327c9f56302dc3e45c06cda3afc027
|
|
| MD5 |
11ef1c9dd0e612425de47b2699dcb182
|
|
| BLAKE2b-256 |
fd946e834a19b8998baaeb77cf9e0146a80d86b6ab003aafb4add03f10d09f93
|
Provenance
The following attestation bundles were made for vcti_flow-2.0.0-py3-none-any.whl:
Publisher:
release.yml on vcollab/vcti-python-flow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vcti_flow-2.0.0-py3-none-any.whl -
Subject digest:
881b9e46cb496eb4a5611aa02d469151ee327c9f56302dc3e45c06cda3afc027 - Sigstore transparency entry: 1989185910
- Sigstore integration time:
-
Permalink:
vcollab/vcti-python-flow@605d8156b875bff7e69fa4034849af8f09b012e1 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/vcollab
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@605d8156b875bff7e69fa4034849af8f09b012e1 -
Trigger Event:
push
-
Statement type: