Fixes broken VideoRecorder test imports and config field names#5207
Fixes broken VideoRecorder test imports and config field names#5207kellyguo11 merged 2 commits intodevelopfrom
Conversation
The test file added in #5011 was broken at collection time: it used importlib to load a nonexistent sibling file, referenced obsolete config field names, and used patch() targets that cannot resolve when the video_recording subpackages are not installed. - Replace importlib file loader with normal package import - Rename config fields to match VideoRecorderCfg (env_render_mode, camera_position, camera_target, window_width, window_height) - Use patch.dict(sys.modules) instead of patch() for optional deps
Greptile SummaryThis PR fixes a broken test file ( Confidence Score: 5/5Safe to merge — fixes a broken test file with no production code changes. All three root causes (importlib misuse, wrong config field names, unresolvable patch targets) are correctly addressed. Config fields are verified against VideoRecorderCfg. The patch.dict(sys.modules) approach is the right idiom for optional deps. No P0 or P1 findings. No files require special attention.
|
| Filename | Overview |
|---|---|
| source/isaaclab/test/envs/test_video_recorder.py | Rewritten test file: correct package import, field names match VideoRecorderCfg, patch.dict used for optional deps; all test logic looks sound against the implementation. |
Sequence Diagram
sequenceDiagram
participant Test
participant VideoRecorder
participant _resolve_video_backend
participant kit_mod as isaaclab_physx backend
participant newton_mod as isaaclab_newton backend
Note over Test: test_init_perspective_mode_creates_kit_capture
Test->>VideoRecorder: __init__(cfg, scene)
VideoRecorder->>_resolve_video_backend: patched → returns "kit"
VideoRecorder->>kit_mod: create_isaacsim_kit_perspective_video(kcfg)
kit_mod-->>VideoRecorder: fake_capture
VideoRecorder-->>Test: vr._capture == fake_capture ✓
Note over Test: test_init_newton_backend_creates_newton_capture
Test->>VideoRecorder: __init__(cfg, scene)
VideoRecorder->>_resolve_video_backend: patched → returns "newton_gl"
VideoRecorder->>newton_mod: create_newton_gl_perspective_video(ncfg)
newton_mod-->>VideoRecorder: fake_capture
VideoRecorder-->>Test: vr._capture == fake_capture ✓
Note over Test: test_render_rgb_array_* tests
Test->>VideoRecorder: render_rgb_array()
alt _backend is None or _capture is None
VideoRecorder-->>Test: None
else backend active
VideoRecorder->>VideoRecorder: _capture.render_rgb_array()
VideoRecorder-->>Test: np.ndarray (720x1280x3)
end
Reviews (1): Last reviewed commit: "Fix broken VideoRecorder test imports an..." | Re-trigger Greptile
There was a problem hiding this comment.
Clean bugfix — reviewed the diff against VideoRecorderCfg and the VideoRecorder.__init__ on develop. Everything checks out.
What was broken (from #5011):
importlib.util.spec_from_file_locationtried to load a non-existent siblingvideo_recorder.pyin the test directory- Config fields (
render_mode,camera_eye,camera_lookat,gl_viewer_width,gl_viewer_height,video_mode,fallback_camera_cfg,video_num_tiles) didn't match the actualVideoRecorderCfgdataclass patch()targets for the optionalisaaclab_physx/isaaclab_newtonsubpackages can't resolve when those packages aren't installed
What this PR fixes:
- ✅ Imports directly from
isaaclab.envs.utils.video_recorder— correct package path - ✅ Config fields now match
VideoRecorderCfgexactly:env_render_mode,camera_position,camera_target,window_width,window_height - ✅
patch.dict(sys.modules, ...)is the right pattern for mocking lazy/optional imports that happen inside__init__— avoids the import-resolution issue entirely - ✅ Removed
fallback_camera_cfgfrom the kit test (field doesn't exist in the cfg) - ✅ Docstring updated to reference
env_render_mode
No backward-compatibility concerns — this only touches a test file, and the test was broken at collection time before this PR.
…-sim#5207) The test file added in isaac-sim#5011 was broken at collection time: it used importlib to load a nonexistent sibling file, referenced obsolete config field names, and used patch() targets that cannot resolve when the video_recording subpackages are not installed. - Replace importlib file loader with normal package import - Rename config fields to match VideoRecorderCfg (env_render_mode, camera_position, camera_target, window_width, window_height) - Use patch.dict(sys.modules) instead of patch() for optional dep ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Checklist - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there
The test file added in #5011 was broken at collection time: it used importlib to load a nonexistent sibling file, referenced obsolete config field names, and used patch() targets that cannot resolve when the video_recording subpackages are not installed.
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there