Skip to main content

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 typeNode[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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vcti_flow-2.0.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vcti_flow-2.0.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

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

Hashes for vcti_flow-2.0.0.tar.gz
Algorithm Hash digest
SHA256 f2a8106dc7cadcf8b68c78ea800686b59544f9c2bc9282f87b637b673b46f18d
MD5 7e226d05bfa3b9d514adfaf159266fb5
BLAKE2b-256 344a5a2754fd409cd81707b97241300115457b42868a1e352fc18f03e5e2bd29

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_flow-2.0.0.tar.gz:

Publisher: release.yml on vcollab/vcti-python-flow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for vcti_flow-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 881b9e46cb496eb4a5611aa02d469151ee327c9f56302dc3e45c06cda3afc027
MD5 11ef1c9dd0e612425de47b2699dcb182
BLAKE2b-256 fd946e834a19b8998baaeb77cf9e0146a80d86b6ab003aafb4add03f10d09f93

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page