Skip to content

pyrophone

Type part of a name or a dotted path

Typed declarations for asynchronous message-processing nodes.

Attributes

NameDescription
runNo description.

Classes

NameDescription
ChannelClosedErrorA value could not be accepted because the channel has closed.
CompiledEdgeNo description.
CompiledGraphNo description.
CompiledNodeConfigured occurrence retaining its original declaration ID.
ConfigurationErrorConfiguration does not satisfy a node's schema.
EdgeNo description.
EndOfStreamThe input channel has closed and no more values can arrive.
GraphEditable graph with stable tuple inspection views.
GraphErrorA graph connection or compiled graph is invalid.
InputNo description.
InputPortNo description.
NodeBase for node implementations. Runtime construction is framework-owned.
NodeDeclarationAn occurrence, with independent configuration and a stable unique ID.
NodeExecutionErrorA node initializer or run method failed; __cause__ holds the original.
NodeHandleRuntime-owned editing access to one node, without exposing its instance.
NodeTypeSchemaNo description.
OutputNo description.
OutputPortNo description.
PortHandleInspection and tracing access to one live port; it cannot send or receive.
PortReferenceA named port on one occurrence, never a live runtime endpoint.
PortSchemaNo description.
PropertyDeclare a typed property; omitting default makes it required.
PropertySchemaNo description.
PyrophoneErrorBase class for errors reported by Pyrophone.
RuntimeRuntime-owned controller exposing handles in graph insertion order.
SchemaErrorA node declaration has an invalid or unresolved schema.
TraceA port trace registration. close() removes it synchronously and idempotently.

Functions

NameDescription
compile_graphValidate every connection and configuration without allocating live nodes.
mainRun a graph directly, or mark a graph factory as a script entry point.
node_typeRegister a class's immutable schema without constructing an instance.
node_type_schemaReturn this class's schema; subclasses require their own registration.
run_asyncRun a fresh instance of each node after validating the entire graph.
run_syncRun a graph or zero-argument graph factory in a new event loop.

Modules

  • cabeByte-stream CABE transforms backed by the optional cabe extra.
  • jqJSON byte-stream filtering with the optional PyPI jq binding.
  • mqttMQTT payload sources and sinks, backed by the optional mqtt extra.
  • nodesReusable node implementations built on the public component model.
  • scriptConvenience vocabulary for from pyrophone.script import *.

runattributemodule attribute#

run = run_async

ChannelClosedErrorclass#

Re-exported from pyrophone._exceptionsView source
class ChannelClosedError(PyrophoneError)

Bases: PyrophoneError

A value could not be accepted because the channel has closed.

CompiledEdgeclassdataclass#

Re-exported from pyrophone._compileView source
class CompiledEdge(source_id: str, source_port: str, destination_id: str, destination_port: str)

Bases: Printable

destination_idattributeinstance attribute#

destination_id: str

destination_portattributeinstance attribute#

destination_port: str

source_idattributeinstance attribute#

source_id: str

source_portattributeinstance attribute#

source_port: str
Inherited from pyrophone._inspection.Printable

printmethod#

Inherited from pyrophone._inspection.PrintableView source
def print(file: TextIO | None = None) -> None

Write a pretty multiline description, followed by a newline.

CompiledGraphclassdataclass#

Re-exported from pyrophone._compileView source
class CompiledGraph(nodes: tuple[CompiledNode, ...], edges: tuple[CompiledEdge, ...])

Bases: Printable

edgesattributeinstance attribute#

edges: tuple[CompiledEdge, ...]

nodesattributeinstance attribute#

nodes: tuple[CompiledNode, ...]
Inherited from pyrophone._inspection.Printable

printmethod#

Inherited from pyrophone._inspection.PrintableView source
def print(file: TextIO | None = None) -> None

Write a pretty multiline description, followed by a newline.

CompiledNodeclassdataclass#

Re-exported from pyrophone._compileView source
class CompiledNode(id: str, node_type: type[Node], configuration: Mapping[str, object], schema: NodeTypeSchema)

Bases: Printable

Configured occurrence retaining its original declaration ID.

Configuration is shallowly read-only, with nested values detached from the authoring declaration so subsequent graph edits cannot change execution.

configurationattributeinstance attribute#

configuration: Mapping[str, object]

idattributeinstance attribute#

id: str

node_typeattributeinstance attribute#

node_type: type[Node]

schemaattributeinstance attribute#

schema: NodeTypeSchema
Inherited from pyrophone._inspection.Printable

printmethod#

Inherited from pyrophone._inspection.PrintableView source
def print(file: TextIO | None = None) -> None

Write a pretty multiline description, followed by a newline.

ConfigurationErrorclass#

Re-exported from pyrophone._exceptionsView source
class ConfigurationError(PyrophoneError, ValueError)

Bases: PyrophoneError, ValueError

Configuration does not satisfy a node’s schema.

Edgeclassdataclass#

Re-exported from pyrophone._graphView source
class Edge(source: PortReference, destination: PortReference)

Bases: Printable

destinationattributeinstance attribute#

destination: PortReference

sourceattributeinstance attribute#

source: PortReference
Inherited from pyrophone._inspection.Printable

printmethod#

Inherited from pyrophone._inspection.PrintableView source
def print(file: TextIO | None = None) -> None

Write a pretty multiline description, followed by a newline.

EndOfStreamclass#

Re-exported from pyrophone._exceptionsView source
class EndOfStream(PyrophoneError)

Bases: PyrophoneError

The input channel has closed and no more values can arrive.

Graphclass#

Re-exported from pyrophone._graphView source
class Graph(*nodes: NodeDeclaration)

Bases: Printable

Editable graph with stable tuple inspection views.

connect atomically adds endpoints and an edge, returning this graph. graph | declaration returns a new graph, connecting from the last node in insertion order. Implicit selection uses only declared direction/default metadata; existing bindings and compatible types never change that choice.

edgesproperty#

edges: tuple[Edge, ...]

nodesproperty#

nodes: tuple[NodeDeclaration, ...]

connectmethod#

def connect(source: PortReference, destination: PortReference) -> Graph
Inherited from pyrophone._inspection.Printable

printmethod#

Inherited from pyrophone._inspection.PrintableView source
def print(file: TextIO | None = None) -> None

Write a pretty multiline description, followed by a newline.

GraphErrorclass#

Re-exported from pyrophone._exceptionsView source
class GraphError(PyrophoneError, ValueError)

Bases: PyrophoneError, ValueError

A graph connection or compiled graph is invalid.

Inputclass#

Re-exported from pyrophone._portsView source
class Input(description: str | None = None, default: bool = False)

defaultattributeinstance attribute#

default = default

descriptionattributeinstance attribute#

description = description

InputPortclass#

Re-exported from pyrophone._portsView source
class InputPort(Protocol)

Bases: Protocol

closemethodasync#

async def close() -> None

Stop accepting values, waking any blocked senders.

recvmethodasync#

async def recv() -> T

Receive the next value; cancellation follows the runtime task.

Nodeclass#

Re-exported from pyrophone._nodeView source
class Node(Printable)

Bases: Printable

Base for node implementations. Runtime construction is framework-owned.

runmethodasync#

async def run() -> None
Inherited from pyrophone._inspection.Printable

printmethod#

Inherited from pyrophone._inspection.PrintableView source
def print(file: TextIO | None = None) -> None

Write a pretty multiline description, followed by a newline.

NodeDeclarationclassdataclass#

Re-exported from pyrophone._graphView source
class NodeDeclaration(node_type: type[Node], configuration: Mapping[str, object] = dict())

Bases: Printable

An occurrence, with independent configuration and a stable unique ID.

Configuration is shallowly read-only; nested values are copied on creation. No live node or user initializer is involved in creating a declaration. Named attributes expose ports; use port(name) for ports whose names collide with declaration fields or methods (such as id or port).

configurationattributeclass attributeinstance attribute#

configuration: Mapping[str, object] = field(default_factory=dict)

idattributeclass attributeinstance attribute#

id: str = field(default_factory=lambda : uuid4().hex, init=False)

node_typeattributeinstance attribute#

node_type: type[Node]

schemaattributeclass attributeinstance attribute#

schema: NodeTypeSchema = field(init=False)

portmethod#

def port(name: str) -> PortReference
Inherited from pyrophone._inspection.Printable

printmethod#

Inherited from pyrophone._inspection.PrintableView source
def print(file: TextIO | None = None) -> None

Write a pretty multiline description, followed by a newline.

NodeExecutionErrorclass#

Re-exported from pyrophone._exceptionsView source
class NodeExecutionError(node_id: str, node_type: type[Node])

Bases: PyrophoneError

A node initializer or run method failed; cause holds the original.

node_idattributeinstance attribute#

node_id = node_id

node_typeattributeinstance attribute#

node_type = node_type

node_type_nameattributeinstance attribute#

node_type_name = node_type.__name__

NodeHandleclass#

Re-exported from pyrophone._controlView source
class NodeHandle(definition: CompiledNode, instance: Node)

Bases: Printable

Runtime-owned editing access to one node, without exposing its instance.

Attribute assignment validates and immediately replaces a property value. Edits must run on the node’s event loop while the node is active. Reads and configuration snapshots are detached copies; edit containers by assignment. For names colliding with handle metadata/methods, use get_property/set_property.

activeproperty#

active: bool

configurationproperty#

configuration: Mapping[str, object]

Return a detached, read-only snapshot of current property values.

idproperty#

id: str

node_typeproperty#

node_type: type[Node]

schemaproperty#

schema: NodeTypeSchema

get_propertymethod#

def get_property(name: str) -> object

Read a property by name, including names reserved by the handle.

portmethod#

def port(name: str) -> PortHandle

Inspect or trace a named runtime port, including reserved names.

set_propertymethod#

def set_property(name: str, value: object) -> None

Validate, copy, and apply one value without yielding or invoking hooks.

Inherited from pyrophone._inspection.Printable

printmethod#

Inherited from pyrophone._inspection.PrintableView source
def print(file: TextIO | None = None) -> None

Write a pretty multiline description, followed by a newline.

NodeTypeSchemaclassdataclass#

Re-exported from pyrophone._schemaView source
class NodeTypeSchema(name: str, description: str | None, properties: Mapping[str, PropertySchema], inputs: Mapping[str, PortSchema], outputs: Mapping[str, PortSchema])

descriptionattributeinstance attribute#

description: str | None

inputsattributeinstance attribute#

inputs: Mapping[str, PortSchema]

nameattributeinstance attribute#

name: str

outputsattributeinstance attribute#

outputs: Mapping[str, PortSchema]

propertiesattributeinstance attribute#

properties: Mapping[str, PropertySchema]

Outputclass#

Re-exported from pyrophone._portsView source
class Output(description: str | None = None, default: bool = False)

defaultattributeinstance attribute#

default = default

descriptionattributeinstance attribute#

description = description

OutputPortclass#

Re-exported from pyrophone._portsView source
class OutputPort(Protocol)

Bases: Protocol

closemethodasync#

async def close() -> None

Announce end of stream and reject unaccepted sends.

sendmethodasync#

async def send(value: T) -> None

Wait until a receiver accepts the value, without processing acknowledgement.

PortHandleclass#

Re-exported from pyrophone._controlView source
class PortHandle(node: NodeHandle, name: str, direction: Literal['input', 'output'], traces: _TraceCallbacks[object])

Bases: Printable

Inspection and tracing access to one live port; it cannot send or receive.

directionproperty#

direction: Literal['input', 'output']

nameproperty#

name: str

nodeproperty#

node: NodeHandle

schemaproperty#

schema: PortSchema

tracemethod#

def trace(callback: Callable[[object], None]) -> Trace

Observe accepted transfers synchronously. The callback must not block.

Inherited from pyrophone._inspection.Printable

printmethod#

Inherited from pyrophone._inspection.PrintableView source
def print(file: TextIO | None = None) -> None

Write a pretty multiline description, followed by a newline.

PortReferenceclassdataclass#

Re-exported from pyrophone._graphView source
class PortReference(node: NodeDeclaration, name: str, direction: Direction)

Bases: Printable

A named port on one occurrence, never a live runtime endpoint.

directionattributeinstance attribute#

direction: Direction

nameattributeinstance attribute#

name: str

nodeattributeinstance attribute#

node: NodeDeclaration

schemaproperty#

schema: PortSchema
Inherited from pyrophone._inspection.Printable

printmethod#

Inherited from pyrophone._inspection.PrintableView source
def print(file: TextIO | None = None) -> None

Write a pretty multiline description, followed by a newline.

PortSchemaclassdataclass#

Re-exported from pyrophone._schemaView source
class PortSchema(name: str, type: object, description: str | None = None, default: bool = False)

defaultattributeclass attributeinstance attribute#

default: bool = False

descriptionattributeclass attributeinstance attribute#

description: str | None = None

nameattributeinstance attribute#

name: str

typeattributeinstance attribute#

type: object

Propertyclass#

Re-exported from pyrophone._propertiesView source
class Property(default: T | _Missing = _MISSING, title: str | None = None, description: str | None = None, minimum: int | float | None = None, maximum: int | float | None = None, step: int | float | None = None)

Declare a typed property; omitting default makes it required.

Values are bound separately for each runtime instance. Configuration is shallowly read-only: callers may still mutate a mutable value’s contents.

defaultattributeinstance attribute#

default = default

descriptionattributeinstance attribute#

description = description

maximumattributeinstance attribute#

maximum = maximum

minimumattributeinstance attribute#

minimum = minimum

stepattributeinstance attribute#

step = step

titleattributeinstance attribute#

title = title

PropertySchemaclassdataclass#

Re-exported from pyrophone._schemaView source
class PropertySchema(name: str, type: object, default: object = _MISSING, title: str | None = None, description: str | None = None, minimum: int | float | None = None, maximum: int | float | None = None, step: int | float | None = None)

defaultattributeclass attributeinstance attribute#

default: object = _MISSING

descriptionattributeclass attributeinstance attribute#

description: str | None = None

maximumattributeclass attributeinstance attribute#

maximum: int | float | None = None

minimumattributeclass attributeinstance attribute#

minimum: int | float | None = None

nameattributeinstance attribute#

name: str

stepattributeclass attributeinstance attribute#

step: int | float | None = None

titleattributeclass attributeinstance attribute#

title: str | None = None

typeattributeinstance attribute#

type: object

requiredproperty#

required: bool

PyrophoneErrorclass#

Re-exported from pyrophone._exceptionsView source
class PyrophoneError(Exception)

Bases: Exception

Base class for errors reported by Pyrophone.

Runtimeclass#

Re-exported from pyrophone._controlView source
class Runtime(compiled_graph: CompiledGraph, nodes: tuple[NodeHandle, ...])

Bases: Printable

Runtime-owned controller exposing handles in graph insertion order.

compiled_graphproperty#

compiled_graph: CompiledGraph

The startup snapshot; live edits do not mutate it.

nodesproperty#

nodes: tuple[NodeHandle, ...]
Inherited from pyrophone._inspection.Printable

printmethod#

Inherited from pyrophone._inspection.PrintableView source
def print(file: TextIO | None = None) -> None

Write a pretty multiline description, followed by a newline.

SchemaErrorclass#

Re-exported from pyrophone._exceptionsView source
class SchemaError(PyrophoneError, ValueError)

Bases: PyrophoneError, ValueError

A node declaration has an invalid or unresolved schema.

Traceclass#

Re-exported from pyrophone._traceView source
class Trace(callback: Callable[[object], None], remove: Callable[[], object])

A port trace registration. close() removes it synchronously and idempotently.

activeproperty#

active: bool

closemethod#

def close() -> None

Stop future notifications; call from the runtime’s event loop.

compile_graphfunction#

Re-exported from pyrophone._compileView source
def compile_graph(graph: Graph) -> CompiledGraph

Validate every connection and configuration without allocating live nodes.

Every declared input and output must have exactly one channel. Empty graphs and portless nodes are valid. The returned tuples and copied configuration are independent of later authoring graph changes.

mainfunction#

Re-exported from pyrophone._entryView source
def main(target: Graph | _Factory | None = None, /) -> _Factory | _Decorator | None

Run a graph directly, or mark a graph factory as a script entry point.

main(graph) immediately invokes the command-line driver, even on import. The driver parses arguments before executing the graph or its factory. @main and @main() execute a zero-argument sync or async factory only when its module is main. The factory and graph share an event loop. Decoration always returns the original function; imported factories remain callable and retain their static types.

Put decorated entry points after their dependencies: execution begins when Python evaluates the decorator. Empty parentheses reserve space for future options; no configuration arguments are currently accepted.

node_typefunction#

Re-exported from pyrophone._nodeView source
def node_type() -> type[N]

Register a class’s immutable schema without constructing an instance.

node_type_schemafunction#

Re-exported from pyrophone._nodeView source
def node_type_schema() -> NodeTypeSchema

Return this class’s schema; subclasses require their own registration.

run_asyncfunctionasync#

Re-exported from pyrophone._runtimeView source
async def run_async(graph: Graph, *, on_graph: Callable[[CompiledGraph], None] | None = None, execute: bool = True, on_runtime: Callable[[Runtime], None] | None = None, session: _Session | None = None) -> None

Run a fresh instance of each node after validating the entire graph.

on_graph observes the validated snapshot before any live nodes are allocated. execute=False validates and observes the graph without running it. Neither option parses command-line arguments. An optional session runs alongside the graph; completion of either cancels and awaits the other. on_runtime receives editing handles after all initializers finish, before node tasks or the session start. execute=False skips this callback too.

Normal return closes a node’s outputs and inputs. A failed node cancels its siblings; cancellation awaits their cooperative cleanup. Run failures appear in TaskGroup exception groups containing one or more NodeExecutionErrors, each retaining the original exception as its cause. Initialization failures raise NodeExecutionError directly, before any node run tasks are started.

Nodes should own asynchronous resources inside run(), using async context managers or try/finally. The runtime closes its endpoints, but cannot unwind arbitrary resources acquired by user initializers. There are no forced cancellation timeouts, restart policies, or background runtime tasks.

run_syncfunction#

Re-exported from pyrophone._runnerView source
def run_sync(graph: Graph | _Factory, *, on_graph: Callable[[CompiledGraph], None] | None = None, execute: bool = True, on_runtime: Callable[[Runtime], None] | None = None, session: _Session | None = None) -> None

Run a graph or zero-argument graph factory in a new event loop.

Graph factories may be synchronous or asynchronous. Construction and graph execution share the same loop. No command-line arguments are parsed. on_graph observes the validated snapshot before live node creation; execute=False stops after validation and observation. on_runtime receives editing handles after initialization, before node tasks start.

Ctrl-C cancels execution and completes cooperative cleanup without a traceback. Other failures propagate. Inside an existing event loop, use await run_async(graph) instead.