Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Facebookresearch Habitat lab Registry Registration

From Leeroopedia
Knowledge Sources
Domains Software_Architecture, Design_Patterns
Last Updated 2026-02-15 02:00 GMT

Overview

A global registry pattern using Python decorators to register custom components (sensors, measures, actions) for string-based lookup from configuration.

Description

Registry Registration is the mechanism by which custom Habitat components become discoverable from YAML configuration. The @registry.register_* decorators add classes to a global mapping keyed by their registration name (defaulting to the class name). When Habitat initializes a task, it looks up component names from config in the registry and instantiates the corresponding classes.

This pattern enables extending Habitat without modifying framework code -- custom components are registered at import time and resolved at runtime through config.

Usage

Register custom sensors, measures, and actions after defining them. The registration name must match the type field in the corresponding structured config dataclass.

Theoretical Basis

The registry pattern implements a service locator:

  1. Registration: Decorator maps a name to a class in a global dict
  2. Resolution: Framework looks up name from config, gets class, and instantiates
  3. Extensibility: New components are added without modifying framework code
# Abstract registry pattern
registry = {}

def register(name):
    def decorator(cls):
        registry[name] = cls
        return cls
    return decorator

@register("my_sensor")
class MySensor: ...

# Later, resolved from config:
sensor_cls = registry[config.type]
sensor = sensor_cls(config=config, sim=sim)

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment