pyrophone.nodes
Reusable node implementations built on the public component model.
Attributes
| Name | Description |
|---|---|
JSONValue | No description. |
Classes
| Name | Description |
|---|---|
Identity | Forward each value unchanged, preserving its type and object identity. |
IdentityBytes | Pass byte payloads through unchanged. |
JSONTransform | Decode JSON, transform its value, and encode the result as UTF-8 bytes. |
Print | Print each value to stdout and forward it unchanged. |
PrintBytes | Print byte payloads (including the b prefix) without decoding them. |
PrintText | Print text or UTF-8 bytes and forward the original value unchanged. |
Sink | Consume values from one input port in stream order. |
Source | Send the values from an async generator through one output port. |
Transform | Transform each input value into one output value, in stream order. |
JSONValueattribute#
JSONValueIdentityclass#
class Identity(Transform[T, T])Bases: Transform[T, T]
Forward each value unchanged, preserving its type and object identity.
Register a concrete subclass, such as Identity[int], with node_type.
transformmethodasync#
async def transform(value: T) -> TIdentityBytesclass#
class IdentityBytes(Identity[bytes])Pass byte payloads through unchanged.
JSONTransformclass#
class JSONTransform(Transform[bytes, bytes])Bases: Transform[bytes, bytes]
Decode JSON, transform its value, and encode the result as UTF-8 bytes.
Override transform_json(); ports remain byte-oriented for direct connection to transports such as MQTT. Encoding uses compact JSON with Unicode text preserved and rejects non-finite numbers. Codec and hook errors propagate through the normal node failure contract.
Printclass#
class Print(Transform[T, T])Bases: Transform[T, T]
Print each value to stdout and forward it unchanged.
Uses Python’s normal print formatting and flushes each line immediately. Register a concrete subclass such as Print[int] with node_type.
transformmethodasync#
async def transform(value: T) -> TPrintBytesclass#
class PrintBytes(Print[bytes])Print byte payloads (including the b prefix) without decoding them.
PrintTextclass#
class PrintText(Transform[str | bytes, str | bytes])Bases: Transform[str | bytes, str | bytes]
Print text or UTF-8 bytes and forward the original value unchanged.
Invalid UTF-8 prints as a bytes repr. Each print flushes stdout immediately. The graph infers the output type from the connected upstream port.
Sinkclass#
class Sink(Node)Bases: Node
Consume values from one input port in stream order.
Override consume() and register a concrete subclass with node_type. Each call finishes before the next input is received.
in_portattributeclass attributeinstance attribute#
in_port = Input[T](description='Values to consume.')Inherited from pyrophone._inspection.Printable
printmethod#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.
Sourceclass#
class Source(Node)Bases: Node
Send the values from an async generator through one output port.
Override produce() and register a concrete subclass with node_type. The next value is requested after the current send is accepted.
out_portattributeclass attributeinstance attribute#
out_port = Output[T](description='Produced values.')Inherited from pyrophone._inspection.Printable
printmethod#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.
Transformclass#
class Transform(Node)Bases: Node
Transform each input value into one output value, in stream order.
Override transform() and register a concrete subclass with node_type.
in_portattributeclass attributeinstance attribute#
in_port = Input[InputT](description='Values to transform.')out_portattributeclass attributeinstance attribute#
out_port = Output[OutputT](description='Transformed values.')runmethodasync#
async def run() -> Nonetransformmethodasync#
async def transform(value: InputT) -> OutputTInherited from pyrophone._inspection.Printable
printmethod#
pyrophone._inspection.PrintableView sourcedef print(file: TextIO | None = None) -> NoneWrite a pretty multiline description, followed by a newline.