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 a node to the graph and connect incoming wires, which are specified via keyword arguments.
Capture an input from an outer scope.
Get a port from the input node by name.
Set the outputs of the graph by specifying incoming wires as keyword arguments.
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.
- 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).