Skip to content

Model

hexa.model

Shared neutral model for hexa port trees.

All utilities (parse_yaml, generate_abc, parse_abc, generate_yaml, check_matches) serialize through this single model. It is NOT tied to any sample — any port tree fits.

Classes

MethodSpec dataclass

1
2
3
4
5
MethodSpec(
    name: str,
    args: list[str] = list(),
    kwargs: dict[str, str] = dict(),
)

Specification of a single abstract method.

PortNode dataclass

1
2
3
4
5
6
7
8
PortNode(
    name: str,
    port_cls: str,
    kind: str = "leaf",
    attributes: dict[str, ConfigValue] = dict(),
    children: list[PortNode] = list(),
    methods: dict[str, MethodSpec] = dict(),
)

A node in the hexa port tree.

Parameters

name : str Slot name, e.g. "parser", "amount_balance". kind : str One of "leaf", "port", or "parent". - "leaf": no children (e.g. NumberPort) - "port": has children (e.g. TransactionParserPort) - "parent": the root of the tree (e.g. ExtractionPipeline) port_cls : str ABC class name that gives this port its shape, e.g. "TransactionParserPort". Every port has a concrete typed shape. attributes : dict[str, ConfigValue] Annotated attributes: name -> type_expr for scalars, or a nested dict of sub-attributes (a struct) for grouped/structured values. children : list[PortNode] Nested port slots. methods : dict[str, MethodSpec] Abstract methods keyed by method name.

Functions
diff
diff(other: PortNode, path: str = '') -> list[str]

Return a list of human-readable difference strings.

An empty list means the trees are equal.

find
find(name: str) -> PortNode | None

Find a direct child by slot name.

walk
walk() -> list[PortNode]

Return all nodes in depth-first order (self first).