Skip to content

Fixes broken VideoRecorder test imports and config field names#5207

Merged
kellyguo11 merged 2 commits intodevelopfrom
antoiner/fix/test-video-recorder-import
Apr 9, 2026
Merged

Fixes broken VideoRecorder test imports and config field names#5207
kellyguo11 merged 2 commits intodevelopfrom
antoiner/fix/test-video-recorder-import

Conversation

@AntoineRichard
Copy link
Copy Markdown
Collaborator

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 dep

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • 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.

- 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
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Apr 8, 2026
@AntoineRichard AntoineRichard changed the title Fix broken VideoRecorder test imports and config field names Fixes broken VideoRecorder test imports and config field names Apr 8, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 8, 2026

Greptile Summary

This PR fixes a broken test file (test_video_recorder.py) introduced in #5011 by replacing an invalid importlib file-loader import with a direct package import, aligning config field names to VideoRecorderCfg (env_render_mode, camera_position, camera_target, window_width, window_height), and switching from patch() to patch.dict(sys.modules, …) for optional backend dependencies that may not be installed.

Confidence Score: 5/5

Safe 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.

Vulnerabilities

No security concerns identified.

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "Fix broken VideoRecorder test imports an..." | Re-trigger Greptile

Copy link
Copy Markdown

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_location tried to load a non-existent sibling video_recorder.py in 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 actual VideoRecorderCfg dataclass
  • patch() targets for the optional isaaclab_physx / isaaclab_newton subpackages 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 VideoRecorderCfg exactly: 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_cfg from 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.

@kellyguo11 kellyguo11 merged commit 83151c7 into develop Apr 9, 2026
25 of 29 checks passed
@kellyguo11 kellyguo11 deleted the antoiner/fix/test-video-recorder-import branch April 9, 2026 00:19
mmichelis pushed a commit to mmichelis/IsaacLab that referenced this pull request Apr 10, 2026
…-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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants