pyrophone
Type part of a name or a dotted path
Typed declarations for asynchronous message-processing nodes.
Attributes
| Name | Description |
|---|---|
run | No description. |
Classes
| Name | Description |
|---|---|
ChannelClosedError | A value could not be accepted because the channel has closed. |
CompiledEdge | No description. |
CompiledGraph | No description. |
CompiledNode | Configured occurrence retaining its original declaration ID. |
ConfigurationError | Configuration does not satisfy a node's schema. |
Edge | No description. |
EndOfStream | The input channel has closed and no more values can arrive. |
Graph | Editable graph with stable tuple inspection views. |
GraphError | A graph connection or compiled graph is invalid. |
Input | No description. |
InputPort | No description. |
Node | Base for node implementations. Runtime construction is framework-owned. |
NodeDeclaration | An occurrence, with independent configuration and a stable unique ID. |
NodeExecutionError | A node initializer or run method failed; __cause__ holds the original. |
NodeHandle | Runtime-owned editing access to one node, without exposing its instance. |
NodeTypeSchema | No description. |
Output | No description. |
OutputPort | No description. |
PortHandle | Inspection and tracing access to one live port; it cannot send or receive. |
PortReference | A named port on one occurrence, never a live runtime endpoint. |
PortSchema | No description. |
Property | Declare a typed property; omitting default makes it required. |
PropertySchema | No description. |
PyrophoneError | Base class for errors reported by Pyrophone. |
Runtime | Runtime-owned controller exposing handles in graph insertion order. |
SchemaError | A node declaration has an invalid or unresolved schema. |
Trace | A port trace registration. close() removes it synchronously and idempotently. |
Functions
| Name | Description |
|---|---|
compile_graph | Validate every connection and configuration without allocating live nodes. |
main | Run a graph directly, or mark a graph factory as a script entry point. |
node_type | Register a class's immutable schema without constructing an instance. |
node_type_schema | Return this class's schema; subclasses require their own registration. |
run_async | Run a fresh instance of each node after validating the entire graph. |
run_sync | Run 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 *.
ChannelClosedErrorclass#
pyrophone._exceptionsView sourceclass ChannelClosedError(PyrophoneError)Bases: PyrophoneError
A value could not be accepted because the channel has closed.
CompiledEdgeclassdataclass#
pyrophone._compileView sourceclass CompiledEdge(source_id: str, source_port: str, destination_id: str, destination_port: str)Bases: Printable
destination_idattributeinstance attribute#
destination_id: strdestination_portattributeinstance attribute#
destination_port: strsource_idattributeinstance attribute#
source_id: strsource_portattributeinstance attribute#
source_port: strInherited from pyrophone._inspection.Printable
printmethod#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.
CompiledGraphclassdataclass#
pyrophone._compileView sourceclass 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#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.
CompiledNodeclassdataclass#
pyrophone._compileView sourceclass 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: strnode_typeattributeinstance attribute#
node_type: type[Node]schemaattributeinstance attribute#
schema: NodeTypeSchemaInherited from pyrophone._inspection.Printable
printmethod#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.
ConfigurationErrorclass#
pyrophone._exceptionsView sourceclass ConfigurationError(PyrophoneError, ValueError)Bases: PyrophoneError, ValueError
Configuration does not satisfy a node’s schema.
Edgeclassdataclass#
pyrophone._graphView sourceclass Edge(source: PortReference, destination: PortReference)Bases: Printable
destinationattributeinstance attribute#
destination: PortReferencesourceattributeinstance attribute#
source: PortReferenceInherited from pyrophone._inspection.Printable
printmethod#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.
EndOfStreamclass#
pyrophone._exceptionsView sourceclass EndOfStream(PyrophoneError)Bases: PyrophoneError
The input channel has closed and no more values can arrive.
Graphclass#
pyrophone._graphView sourceclass 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.
connectmethod#
def connect(source: PortReference, destination: PortReference) -> GraphInherited from pyrophone._inspection.Printable
printmethod#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.
GraphErrorclass#
pyrophone._exceptionsView sourceclass GraphError(PyrophoneError, ValueError)Bases: PyrophoneError, ValueError
A graph connection or compiled graph is invalid.
Inputclass#
pyrophone._portsView sourceclass Input(description: str | None = None, default: bool = False)InputPortclass#
pyrophone._portsView sourceclass InputPort(Protocol)Bases: Protocol
Nodeclass#
pyrophone._nodeView sourceclass Node(Printable)Bases: Printable
Base for node implementations. Runtime construction is framework-owned.
Inherited from pyrophone._inspection.Printable
printmethod#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.
NodeDeclarationclassdataclass#
pyrophone._graphView sourceclass 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) -> PortReferenceInherited from pyrophone._inspection.Printable
printmethod#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.
NodeExecutionErrorclass#
pyrophone._exceptionsView sourceclass NodeExecutionError(node_id: str, node_type: type[Node])Bases: PyrophoneError
A node initializer or run method failed; cause holds the original.
NodeHandleclass#
pyrophone._controlView sourceclass 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: boolconfigurationproperty#
configuration: Mapping[str, object]Return a detached, read-only snapshot of current property values.
idproperty#
id: strnode_typeproperty#
node_type: type[Node]schemaproperty#
schema: NodeTypeSchemaget_propertymethod#
def get_property(name: str) -> objectRead a property by name, including names reserved by the handle.
portmethod#
def port(name: str) -> PortHandleInspect or trace a named runtime port, including reserved names.
set_propertymethod#
def set_property(name: str, value: object) -> NoneValidate, copy, and apply one value without yielding or invoking hooks.
Inherited from pyrophone._inspection.Printable
printmethod#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.
NodeTypeSchemaclassdataclass#
pyrophone._schemaView sourceclass NodeTypeSchema(name: str, description: str | None, properties: Mapping[str, PropertySchema], inputs: Mapping[str, PortSchema], outputs: Mapping[str, PortSchema])descriptionattributeinstance attribute#
description: str | Noneinputsattributeinstance attribute#
inputs: Mapping[str, PortSchema]nameattributeinstance attribute#
name: stroutputsattributeinstance attribute#
outputs: Mapping[str, PortSchema]propertiesattributeinstance attribute#
properties: Mapping[str, PropertySchema]Outputclass#
pyrophone._portsView sourceclass Output(description: str | None = None, default: bool = False)OutputPortclass#
pyrophone._portsView sourceclass OutputPort(Protocol)Bases: Protocol
PortHandleclass#
pyrophone._controlView sourceclass 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: strnodeproperty#
node: NodeHandleschemaproperty#
schema: PortSchematracemethod#
def trace(callback: Callable[[object], None]) -> TraceObserve accepted transfers synchronously. The callback must not block.
Inherited from pyrophone._inspection.Printable
printmethod#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.
PortReferenceclassdataclass#
pyrophone._graphView sourceclass PortReference(node: NodeDeclaration, name: str, direction: Direction)Bases: Printable
A named port on one occurrence, never a live runtime endpoint.
directionattributeinstance attribute#
direction: Directionnameattributeinstance attribute#
name: strnodeattributeinstance attribute#
node: NodeDeclarationschemaproperty#
schema: PortSchemaInherited from pyrophone._inspection.Printable
printmethod#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.
PortSchemaclassdataclass#
pyrophone._schemaView sourceclass PortSchema(name: str, type: object, description: str | None = None, default: bool = False)Propertyclass#
pyrophone._propertiesView sourceclass 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 = defaultdescriptionattributeinstance attribute#
description = descriptionmaximumattributeinstance attribute#
maximum = maximumminimumattributeinstance attribute#
minimum = minimumstepattributeinstance attribute#
step = steptitleattributeinstance attribute#
title = titlePropertySchemaclassdataclass#
pyrophone._schemaView sourceclass 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 = _MISSINGdescriptionattributeclass attributeinstance attribute#
description: str | None = Nonemaximumattributeclass attributeinstance attribute#
maximum: int | float | None = Noneminimumattributeclass attributeinstance attribute#
minimum: int | float | None = Nonenameattributeinstance attribute#
name: strstepattributeclass attributeinstance attribute#
step: int | float | None = Nonetitleattributeclass attributeinstance attribute#
title: str | None = Nonetypeattributeinstance attribute#
type: objectPyrophoneErrorclass#
pyrophone._exceptionsView sourceclass PyrophoneError(Exception)Bases: Exception
Base class for errors reported by Pyrophone.
Runtimeclass#
pyrophone._controlView sourceclass Runtime(compiled_graph: CompiledGraph, nodes: tuple[NodeHandle, ...])Bases: Printable
Runtime-owned controller exposing handles in graph insertion order.
compiled_graphproperty#
compiled_graph: CompiledGraphThe startup snapshot; live edits do not mutate it.
nodesproperty#
nodes: tuple[NodeHandle, ...]Inherited from pyrophone._inspection.Printable
printmethod#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.
SchemaErrorclass#
pyrophone._exceptionsView sourceclass SchemaError(PyrophoneError, ValueError)Bases: PyrophoneError, ValueError
A node declaration has an invalid or unresolved schema.
Traceclass#
pyrophone._traceView sourceclass Trace(callback: Callable[[object], None], remove: Callable[[], object])A port trace registration. close() removes it synchronously and idempotently.
compile_graphfunction#
pyrophone._compileView sourcedef compile_graph(graph: Graph) -> CompiledGraphValidate 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#
pyrophone._entryView sourcedef main(target: Graph | _Factory | None = None, /) -> _Factory | _Decorator | NoneRun 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#
pyrophone._nodeView sourcedef node_type() -> type[N]Register a class’s immutable schema without constructing an instance.
node_type_schemafunction#
pyrophone._nodeView sourcedef node_type_schema() -> NodeTypeSchemaReturn this class’s schema; subclasses require their own registration.
run_asyncfunctionasync#
pyrophone._runtimeView sourceasync 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) -> NoneRun 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#
pyrophone._runnerView sourcedef 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) -> NoneRun 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.