Principle:Facebookresearch Habitat lab Structured Config Definition
| Knowledge Sources | |
|---|---|
| Domains | Configuration_Management, Software_Architecture |
| Last Updated | 2026-02-15 02:00 GMT |
Overview
A typed configuration pattern using Python dataclasses to define type-safe, IDE-friendly configuration schemas for custom Habitat components.
Description
Structured Config Definition uses Python @dataclass classes that inherit from Habitat's base config classes (LabSensorConfig, MeasurementConfig, ActionConfig) to define typed configuration schemas. These dataclasses serve as the Hydra structured config for the custom component, providing default values, type validation, and IDE autocompletion.
The type field must match the registration name in the registry, linking the config to the component implementation.
Usage
Define after creating a custom component class and before wiring it into Hydra configuration. The dataclass defines what parameters are available in YAML config.
Theoretical Basis
Structured configs bridge Python types and YAML:
- Dataclass: Defines typed fields with defaults
- MISSING sentinel: Marks required fields (no default)
- Inheritance: Base config classes provide shared fields (
type) - Composition: Hydra merges structured defaults with YAML overrides
# Abstract config pattern
@dataclass
class MyConfig(BaseConfig):
type: str = "MyComponent" # Must match registry name
param1: int = 10 # Optional with default
param2: str = MISSING # Required (no default)