ComponentRegistry
Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.
- class ComponentRegistry[source]
Bases:
ClassRegistry[Type[T]]Registry for ONE component family, keyed by implementation name.
Subclasses declare their domain:
class SupervoxelizerRegistry(ComponentRegistry[Supervoxelizer]): domain = "supervoxelizer" kind = "supervoxelizer"
The full surface is then:
@SupervoxelizerRegistry.register("slic") class SlicSupervoxelizer: ... SupervoxelizerRegistry.create("slic", n_supervoxels=100) SupervoxelizerRegistry.available() # -> tuple of names SupervoxelizerRegistry.constructor_signature("slic")
- domain: ClassVar[str] = 'component'
Plugin domain name;
snake_caseof the protocol class, singular. The entry point group isf"habit.{domain}".
- classmethod register(name: str, *, params_model: Type[BaseModel] | None = None) Callable[[Type[T]], Type[T]][source]
Register one component together with its parameter contract.
Keeping the implementation and its Pydantic schema in one decorator prevents a component from being temporarily or permanently registered without the validation contract used by YAML, plugin introspection, GUI forms, and Agent-generated specifications. The separate
register_params_model()method remains supported for third-party plugins and v1.x compatibility.- Parameters:
name – Stable component name within this registry domain.
params_model – Pydantic model for user-configurable constructor parameters.
Nonepreserves the legacy two-step registration path.
- Returns:
A decorator that registers the component class unchanged.
- classmethod create(name: str, **params: Any) T[source]
Instantiate a registered component after validating
params.When a Pydantic parameters model is registered for
name(viaregister_params_model()), the parameters are validated and coerced through it before construction, so a mistyped parameter fails at the call site with a precise message instead of deep inside an algorithm.- Parameters:
name – Registered implementation name.
**params – Parameters forwarded to the component constructor.
- Returns:
The constructed component.
- Raises:
ComponentNotFoundError – If the name is not registered.
ConfigurationError – If the parameters fail schema validation.
- classmethod constructor_signature(name: str) Signature[source]
Return the inspectable constructor contract for a registered component.
The signature is the v2 source of parameter names, defaults and type annotations. It intentionally excludes no public constructor argument.
- classmethod available() Tuple[str, ...][source]
Return the registered implementation names, sorted.
- classmethod params_model(name: str) Type[BaseModel] | None[source]
Return the Pydantic model describing one implementation’s parameters.
JSON Schema for a GUI or an agent is then
.model_json_schema(); keeping a single source of truth avoids a second, drifting schema.- Parameters:
name – Registered implementation name.
- Returns:
The params model class, or
Nonewhen none was registered.
- classmethod entry_point_group() str[source]
Return the entry point group third-party packages register into.
- classmethod load_entry_points() Tuple[str, ...][source]
Load third-party components declared under
habit.<domain>.An entry point may resolve to a module (whose registration decorators execute during import) or to a zero-argument callable performing registration. Loading is idempotent per entry point and failures are skipped by design: a broken third-party plugin must never prevent built-in components from working.
- Returns:
Names of the entry points loaded by this call.