Skip to content

Fail a run whose viewport recording wrote no video - #1811

Open
xyao-nv wants to merge 1 commit into
mainfrom
xyao/fix/check_viewport_video_written
Open

xyao-nv wants to merge 1 commit into
mainfrom
xyao/fix/check_viewport_video_written

Conversation

@xyao-nv

@xyao-nv xyao-nv commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Fail a run when --record_viewport_video writes no viewport MP4. After the rollout, the new write_viewport_video() writes the clip the recorder still holds and asserts that it exists.

Why this change?

#1808 records the viewport with Isaac Lab's VideoRecorder, and fails before the rollout when no active visualizer can capture frames. The recorder can still end up writing no clip. When a visualizer's render_rgb_array() returns None, the recorder catches the error, logs it, and stops capturing. It also only logs a clip that fails to write. In both cases the run finishes and exits 0 without a viewport video. This was raised in the review of #1808.

What changes?

  • write_viewport_video(env, video_cfg) closes the environment's video recorders, which writes the clip still being recorded. It then asserts that a <viewport_name_prefix>_*.mp4 exists in the video directory. An episode-driven rollout usually stops before its video length, so without this its clip is written only when the environment closes.
  • The policy runner and each Experiment Runner rebuild call it right after the rollout. It runs on the success path rather than in env.close(), so a rollout error is still the error reported, and the Experiment Runner still writes placement diagnostics when the check fails.
  • It does nothing without --record_viewport_video. The review GUI's sim preview is unchanged: it already checks for its MP4 after closing the environment.

A run whose rollout succeeded but whose video is missing now fails. Its episode results are already on disk.

Validation

  • A unit test stands in a visualizer whose render_rgb_array() returns None, and another checks that a rollout shorter than its video length still gets its clip written. I did not reproduce a frame-capture failure in Isaac Sim.

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5RetriggerView in Greptile

[Medium impact] Viewport recording changes outcomes for policy and experiment runs that enable it.

The PR appears safe to merge with non-blocking improvements for reused output directories and camera cleanup.

Findings

  1. P2 Old clips hide recording failures ▶
  2. P2 Failed check skips camera cleanup ▶

Summary

The PR flushes viewport recordings after successful rollouts and fails when no matching MP4 exists.

  • Viewport-recorded runs save their clip and stop if the MP4 is missing.

Reviews (1) · Last reviewed commit: "Fail a run whose viewport recording wrot..." · Reviewed by Greptile

Comment on lines +194 to +195
clip_pattern = f"{video_cfg.viewport_name_prefix}_*.mp4"
assert any(Path(video_cfg.video_base_dir).glob(clip_pattern)), (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Old clips hide recording failures

write_viewport_video() accepts an old clip as proof that this rollout wrote one. build_and_run() accepts a caller-chosen output directory and reuses the same prefixes. If an API caller retries into that directory, this check can pass even when the new recorder writes nothing. Require an empty destination or check that this recording created or replaced the clip.

if policy.is_remote:
policy.shutdown_remote(kill_server=args_cli.remote_kill_on_exit)

write_viewport_video(env, video_cfg)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Failed check skips camera cleanup

If the viewport check fails here, policy_runner skips env.close(). With both recording flags enabled, a step-limited rollout can still have camera encoders open. CameraObsVideoRecorder.close() must close those encoders and delete incomplete episode videos, but SimulationAppContext exits immediately on this exception without cleanup. Put environment cleanup in a finally block while keeping the viewport check on the success path.

Isaac Lab's VideoRecorder only logs a frame it could not capture, for
example when the visualizer's render_rgb_array() returns None, or a clip
it could not write. The rollout then finished without a viewport video.

write_viewport_video() runs after the rollout. It writes the clip the
recorder still holds, which an episode-driven rollout can stop short of,
and asserts that a viewport clip exists. The policy runner and each
Experiment Runner rebuild call it on the success path, so a rollout error
is still the error reported.

Signed-off-by: Xinjie Yao <[email protected]>
@xyao-nv
xyao-nv force-pushed the xyao/fix/check_viewport_video_written branch from 0be67ff to 7d7c44c Compare December 2, 2026 00:04
@arena-review-bot

Copy link
Copy Markdown
Contributor

The PR changed while this review was running. Please run /review to retry.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant