Conversation
…e_functors The code previously assumed 'add' always existed in active_functors, which caused KeyError in configurations without observation functors in 'add' mode. Added a conditional check before iterating over 'add' functors to prevent this error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes a runtime KeyError in LeRobotRecorder when the environment’s ObservationManager.active_functors does not define an 'add' mode, making dataset feature generation robust across different observation-manager configurations.
Changes:
- Guard iteration over add-mode observation functors with an
'add' in active_functorscheck. - Add a clarifying inline comment for the add-mode functor handling block.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Add extra observation in `add` mode based on functor config | ||
| if "add" in self._env.observation_manager.active_functors: | ||
| for functor_name in self._env.observation_manager.active_functors["add"]: |
There was a problem hiding this comment.
This change adds a new behavior path when observation_manager.active_functors does not contain an 'add' key, but the existing LeRobotRecorder tests appear to always set active_functors={"add": []} in the mock env. Please add a unit test that exercises _build_features() / _modify_feature_names() with active_functors missing 'add' to prevent regressions of the original KeyError.
| logger.log_warning( | ||
| f"Asset with UID '{asset_uid}' is not RigidObject, Articulation or Robot. Cannot assign feature names based on asset properties." | ||
| ) | ||
| # Add extra observation in `add` mode based on functor config |
There was a problem hiding this comment.
The inline comment says "Add extra observation in add mode", but this block doesn’t add observations; it only updates features[obs_key]["names"] for observations created via add-mode functors. Consider rewording to avoid misleading readers.
| # Add extra observation in `add` mode based on functor config | |
| # Update feature names for observations created via `add` mode functors |
Description
This PR fixes a KeyError that occurs in
LeRobotRecorderwhen theactive_functorsdictionary does not contain an 'add' key.Previously, the code assumed that
active_functors["add"]always existed, which caused a runtime error in configurations where observation functors are not registered in 'add' mode. The fix adds a conditional check (if "add" in self._env.observation_manager.active_functors:) before iterating over the add-mode functors.This is a non-breaking change that makes the code more robust for different observation manager configurations.
Type of change
Checklist
black .command to format the code base.🤖 Generated with Claude Code