Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Facebookresearch Habitat lab SessionRecorder init

From Leeroopedia
Knowledge Sources
Domains Human_in_the_Loop, Data_Collection
Last Updated 2026-02-15 02:00 GMT

Overview

Concrete session data recorder for HITL rearrangement experiments, capturing per-frame and per-episode data with serialization to compressed JSON, provided by habitat-hitl examples.

Description

The SessionRecorder class records interactive session data at multiple granularities: per-frame action/observation snapshots, per-episode metrics and metadata, and session-level connection records. It produces SessionOutput and EpisodeOutput dataclasses that are serialized using save_as_json_gzip and optionally uploaded to S3.

Usage

Instantiated during HITL session setup and called per-frame during interactive execution. Data is finalized and saved when the session ends.

Code Reference

Source Location

  • Repository: habitat-lab
  • File: examples/hitl/rearrange_v2/session_recorder.py
  • Lines: L91-116 (__init__), L126-155 (start_episode), L157-174 (end_episode), L176-193 (record_frame)

Signature

class SessionRecorder:
    def __init__(
        self,
        config: Dict[str, Any],
        connection_records: Dict[int, ConnectionRecord],
        episode_indices: List[int],
    ):
        """
        Args:
            config: Session configuration dict
            connection_records: User connection records
            episode_indices: List of episode indices to record
        """

    def start_episode(self, episode_index: int) -> None: ...
    def end_episode(self) -> None: ...
    def record_frame(self, frame_data: Dict) -> None: ...

Import

# From the HITL rearrange_v2 example
from examples.hitl.rearrange_v2.session_recorder import SessionRecorder
# Also uses:
from habitat_hitl.core.serialize_utils import save_as_json_gzip

I/O Contract

Inputs

Name Type Required Description
config Dict[str, Any] Yes Session configuration
connection_records Dict[int, ConnectionRecord] Yes User connection records
episode_indices List[int] Yes Episodes to record
frame_data Dict Yes Per-frame data passed to record_frame

Outputs

Name Type Description
SessionOutput dataclass Session-level data with connection records
List[EpisodeOutput] dataclass list Per-episode frame data and metrics
Files .json.gz Compressed JSON session files

Usage Examples

Record a Session

from examples.hitl.rearrange_v2.session_recorder import SessionRecorder

recorder = SessionRecorder(
    config=session_config,
    connection_records=connection_records,
    episode_indices=[0, 1, 2],
)

recorder.start_episode(episode_index=0)
for frame in episode_frames:
    recorder.record_frame(frame)
recorder.end_episode()

Related Pages

Implements Principle

Requires Environment

Page Connections

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