GraphBuilder#

class tierkreis.builder.GraphBuilder(inputs: list[str] | None = None, outputs: list[str] | None = None, name: str = '', debug: bool = True)[source]#

Bases: AbstractContextManager

Builder context that maintains a graph state and allows adding nodes within the context.

Methods

add_node_to_graph

Add a node to the graph and connect incoming wires, which are specified via keyword arguments.

capture

Capture an input from an outer scope.

input

Get a port from the input node by name.

set_graph_outputs

Set the outputs of the graph by specifying incoming wires as keyword arguments.

type_check

Type check a graph against a provided signature and return a new graph with type annotations.

Attributes

graph

inputs

outputs

inner_scopes

debug_info

add_node_to_graph(_tk_node: TierkreisNode, /, **incoming_wires: NodePort | NodeRef | PortFunc) NodeRef[source]#

Add a node to the graph and connect incoming wires, which are specified via keyword arguments.

capture(incoming: NodePort | NodeRef | PortFunc, allow_existing: bool = False) NodePort | NodeRef | PortFunc[source]#

Capture an input from an outer scope.

input(name: str) NodePort[source]#

Get a port from the input node by name.

set_graph_outputs(**incoming_wires: NodePort | NodeRef | PortFunc) None[source]#

Set the outputs of the graph by specifying incoming wires as keyword arguments.

type_check(sig: Signature) TierkreisGraph[source]#

Type check a graph against a provided signature and return a new graph with type annotations. Throws an exception if typecheck optional dependencies not installed).