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.

Implementation:Facebookresearch Habitat lab Get config extension

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

Overview

Concrete function and context manager for loading Habitat config and programmatically injecting custom component configurations, provided by habitat-lab core.

Description

The get_config function (from habitat-lab, not habitat-baselines) loads the base task config, and the read_write context manager temporarily unfreezes it for modification. Custom config dataclass instances are inserted into config.habitat.task.lab_sensors, config.habitat.task.measurements, or config.habitat.task.actions.

Usage

Used in custom scripts that need to programmatically register components. For YAML-only workflows, custom configs can be defined directly in YAML without this step.

Code Reference

Source Location

  • Repository: habitat-lab
  • File: habitat-lab/habitat/config/default.py (L115-140), habitat-lab/habitat/config/read_write.py (L1-29)

Signature

def get_config(
    config_path: str,
    overrides: Optional[List[str]] = None,
) -> DictConfig:
    """Load habitat-lab config."""

# Context manager for config modification
from habitat.config.read_write import read_write

with read_write(config):
    # Config is temporarily unfrozen
    config.habitat.task.lab_sensors["my_sensor"] = MySensorConfig()
# Config is re-frozen here

Import

from habitat.config.default import get_config
from habitat.config.read_write import read_write

I/O Contract

Inputs

Name Type Required Description
config DictConfig Yes Base config from get_config
Custom config instances dataclass Yes LabSensorConfig/MeasurementConfig/ActionConfig subclasses

Outputs

Name Type Description
config DictConfig Modified config with custom components added

Usage Examples

Wire Custom Components

from habitat.config.default import get_config
from habitat.config.read_write import read_write

config = get_config("habitat/config/benchmark/nav/pointnav/pointnav_habitat_test.yaml")

with read_write(config):
    config.habitat.task.lab_sensors["my_proximity"] = MyProximitySensorConfig()
    config.habitat.task.measurements["my_success"] = MySuccessMeasureConfig()
    config.habitat.task.actions["my_strafe"] = MyStrafeActionConfig()

# Config now includes custom components; create env
env = habitat.Env(config=config)

Related Pages

Implements Principle

Page Connections

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