proFlow is a Python library for running an ordered sequence of processes against an application state. Each process is a function whose inputs are selected from state (and optionally configuration, parameters, or external data) and whose result is mapped back to state.
Processes should be pure functions: they compute and return values rather than modifying the input state directly. This makes process behavior easier to test and reason about.
- Run an ordered list of reusable process definitions.
- Map process inputs and outputs using state attributes and dotted paths.
- Supply configuration, parameters, external state, and additional inputs.
- Optionally update supported state objects without mutating the original.
- Inspect process dependencies and visualize data flows with the analysis tools.
proFlow requires Python 3.14 or newer and is available on PyPI:
python -m pip install proflowDefine a state, a function, and a Process that maps the state value into the
function and maps its result back to the state. IMMUTABLE_MODE=True makes the
runner return an updated dataclass without modifying the original.
from dataclasses import dataclass
from proflow.objects.interface import I
from proflow.objects.process import Process
from proflow.process_runner import ProcessRunner
@dataclass(frozen=True)
class State:
count: int = 0
def increment(count: int) -> int:
return count + 1
increment_process = Process(
func=increment,
state_inputs=lambda state: [I(state.count, as_="count")],
state_outputs=lambda result: [(result, "count")],
)
runner = ProcessRunner(IMMUTABLE_MODE=True)
initial_state = State()
result = runner.run_processes([increment_process], initial_state=initial_state)
assert result.count == 1
assert initial_state.count == 0ProcessRunner runs processes in order, passing the state returned by one
process to the next. A Process describes the function to call and how its
inputs and outputs connect to the surrounding data:
- Inputs are provided with callables such as
state_inputs. Each returnsI(value, as_="argument_name")entries; theas_value becomes the corresponding keyword argument to the function. - Outputs are provided by
state_outputs. The callable receives the function result and returns(value, "target.path")pairs to write int state. - Other input sources include
config_inputs,parameters_inputs,external_state_inputs, andadditional_inputs. - Process options include
gateto skip a process,commentandgroupfor descriptions, andargsfor additional positional arguments.
By default, output mapping updates state in place. Set
ProcessRunner(IMMUTABLE_MODE=True) to use the non-mutating update path for
supported dataclasses, dictionaries, and lists.
The main entry points are:
Processdefines a function and its input and output mappings.Idescribes an input value and optional function argument name.ProcessRunnerconfigures and runs processes.proflow/analysiscontains process and data-flow inspection tools.proflow/tests/demodata.pycontains a small example process sequence; the experiments directory has analysis and visualization examples.
Clone the repository, install the project and development dependencies, then run the tests and style checks:
uv sync --all-groups
source .venv/bin/activate
python -m pytest
ruff check .
ruff format . --checkproFlow is distributed under the terms of the MIT License.
The publish workflow builds the distributions and publishes them to PyPI using trusted publishing.
Use build_and_deploy.sh patch|minor|major to bump the version and trigger the publish workflow.
Configure a PyPI trusted publisher for this GitHub repository with workflow filename publish.yml and environment pypi before pushing the tag. No PyPI API token is needed.