Skip to content

pyrophone.nodes

Reusable node implementations built on the public component model.

Attributes

NameDescription
JSONValueNo description.

Classes

NameDescription
IdentityForward each value unchanged, preserving its type and object identity.
IdentityBytesPass byte payloads through unchanged.
JSONTransformDecode JSON, transform its value, and encode the result as UTF-8 bytes.
PrintPrint each value to stdout and forward it unchanged.
PrintBytesPrint byte payloads (including the b prefix) without decoding them.
PrintTextPrint text or UTF-8 bytes and forward the original value unchanged.
SinkConsume values from one input port in stream order.
SourceSend the values from an async generator through one output port.
TransformTransform each input value into one output value, in stream order.

JSONValueattribute#

JSONValue

Identityclass#

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) -> T

IdentityBytesclass#

class IdentityBytes(Identity[bytes])

Bases: 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.

transformmethodasync#

async def transform(payload: bytes) -> bytes

transform_jsonmethodasync#

async def transform_json(value: JSONValue) -> JSONValue

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) -> T

PrintBytesclass#

class PrintBytes(Print[bytes])

Bases: 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.

transformmethodasync#

async def transform(value: str | bytes) -> str | bytes

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.')

consumemethodasync#

async def consume(value: T) -> None

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.

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.')

producemethod#

def produce() -> AsyncGenerator[T, None]

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.

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() -> None

transformmethodasync#

async def transform(value: InputT) -> OutputT
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.