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>=1.0.0

In pyproject.toml dependencies

dependencies = [
    "vcti-flow>=1.0.0",
]

Quick Start

from vcti.flow 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-1.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-1.0.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file vcti_flow-1.0.0.tar.gz.

File metadata

  • Download URL: vcti_flow-1.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5c8ecb7d472f16bca35d4331510b34568d8025b295a519b4992caeac83777799
MD5 0110489164810f614ffc2a5d8033d5c6
BLAKE2b-256 d8a4c09304452bd6daa41907781cd572def01840f6547e2313ddf0ececee6234

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_flow-1.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-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: vcti_flow-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d697939ba35a518ab72f0763edfd703357d9d958ae26e8133dd5a3df7b562b2
MD5 d801040eba4000d053b6647b8fab3953
BLAKE2b-256 7758dd1bd14deeb91b8990f6d68ec117939f2282b4d27fbe29eae5d8a1fbbf4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_flow-1.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