builder

builder#

The builder module allows Tierkreis graphs to be constructed concisely using decorated functions and context managers.

Functions

Const

Add a constant value to the graph.

MakeTuple

Make a struct from some values, treating them like a python tuple, with member position indices used to generate the field labels.

RenameInputs

Utility function to rename the inputs of a thunk (runtime graph value).

RenameOutputs

Utility to rename the outputs of a thunk (runtime graph value).

Tag

Add a tag node to the graph, tagging the value with the provided tag string and producing a VariantValue from the output port.

UnionConst

Add a constant as a variant value tagged by its type, to be used with Union type annotations.

UnpackTuple

Unpack a struct containing python tuple fields, up to the first_n fields.

closure

Decorator to build a closure TierkreisGraph inside a builder context.

current_builder

The current GraphBuilder context.

current_graph

The current GraphBuilder's graph.

graph

Convert a function into a TierkreisGraph.

lazy_graph

Decorate a function to build a TierkreisGraph when it is called.

loop

Decorator to build a loop body TierkreisGraph inside a builder context.

Classes

Break

Exit the loop with the provided output.

CaptureBuilder

Graph builder for closures which capture inputs from outer scopes.

Case

Define a graph to handle a specific variant in a Match block.

Continue

Exit the current iteration of a loop and continue to the next with the provided output.

Copyable

Inserts a copy of an underlying ValueSource whenever an outgoing edge is added unless there are no existing uses of the underlying ValueSource (=> the wire is routed from the underlying ValueSource)

Else

Utility to build an if/else block, adds a Match node when called.

Function

A Tierkreis function - i.e. provided by a worker, or a builtin.

GraphBuilder

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

If

Utility to build an if/else block, adds a Match node when called.

IfElse

Define an if/else block.

LazyGraph

Context to lazily build a graph from a decorated function.

Match

Pattern match on a variant value by providing a Case for each variant.

Namespace

Namespace of functions and sub-namespaces.

Output

Set the outputs of a graph to the provided values.

PortFunc

Magic for lazily creating nodes (and returning ports thereof).

Scope

Build a sub graph to be executed at a specific Location.

StablePortFunc

Extends the contract of PortFunc, as documented for the resolve method

Thunk

Utility to call a thunk (a graph) as a function.

Unpack

Utility class representing an unpacked field of a struct.

Exceptions

DuplicateBlock

Duplicate blocks, avoid multiple If/Else or duplicate Case blocks.

IntermediateNodes

Adding of nodes not valid in _CaseScope outside child blocks.

InvalidContext

Expression not valid outside GraphBuilder with context