Skip to content

Container

hexa.container

Summary

Container to build a wired hexa pipeline from annotations.

build recursively instantiates the port tree implied by a root class's annotations, injecting provided runtime instances and config values by name.


Notes

  • Runtime instances and config values are applied by name across the whole tree.

Functions

build

1
2
3
4
5
6
build(
    cls: type[T],
    *,
    instances: dict[str, Any] | None = None,
    config: dict[str, Any] | None = None
) -> T

Recursively instantiate the port tree from annotations.

Parameters:

Name Type Description Default
cls type[T]

The root class to build (e.g. AxisExtractionPipeline).

required
instances dict[str, Any] | None

{slot_name: object} injected verbatim into every node whose annotations contain that name (runtime values — repos, handlers, clients — that must not be re-constructed). Applied to the whole tree by name.

None
config dict[str, Any] | None

{field_name: value} propagated by name to every node's annotated config fields (non-port attributes), replacing the default None.

None

Returns:

Name Type Description
T T

A fully wired instance of cls and all its nested ports.