Skip to content

fix(video): replace assertions with proper exceptions in video frame decoding#3016

Merged
imstevenpmwork merged 1 commit intohuggingface:mainfrom
jashshah999:fix/video-utils-assertions-to-exceptions
Feb 25, 2026
Merged

fix(video): replace assertions with proper exceptions in video frame decoding#3016
imstevenpmwork merged 1 commit intohuggingface:mainfrom
jashshah999:fix/video-utils-assertions-to-exceptions

Conversation

@jashshah999
Copy link
Copy Markdown
Contributor

@jashshah999 jashshah999 commented Feb 24, 2026

Summary

  • Replaced assert statements with FrameTimestampError exceptions in decode_video_frames_torchvision and decode_video_frames_torchcodec for timestamp tolerance and frame count validation
  • Removed AssertionError from the except clause in LeRobotDataset.__init__, which was masking video timestamp errors by silently triggering a dataset re-download instead of surfacing the actual problem

Why this matters

  1. Assertions can be silently disabled with python -O, making these runtime checks disappear entirely
  2. Users hitting timestamp tolerance issues during training/eval get an unhelpful AssertionError traceback instead of the descriptive FrameTimestampError that already exists in the codebase for this purpose
  3. In LeRobotDataset.__init__, AssertionError was caught alongside FileNotFoundError, causing video timestamp problems to trigger unnecessary re-downloads rather than surfacing the real error

Test plan

  • All 60 dataset tests pass
  • FrameTimestampError is already a ValueError subclass, so existing error handling that catches ValueError will continue to work

…decoding

Replaced assert statements with FrameTimestampError exceptions in
decode_video_frames_torchvision and decode_video_frames_torchcodec.

Assertions are unsuitable for runtime validation because they can be
silently disabled with python -O, and they produce unhelpful
AssertionError tracebacks. The codebase already defines
FrameTimestampError for this exact purpose but it was only used
in one of the three validation sites.

Also removed AssertionError from the except clause in
LeRobotDataset.__init__, which was masking video timestamp errors
by silently triggering a dataset re-download instead of surfacing
the actual problem.
@github-actions github-actions Bot added the dataset Issues regarding data inputs, processing, or datasets label Feb 24, 2026
@imstevenpmwork imstevenpmwork self-assigned this Feb 25, 2026
@imstevenpmwork imstevenpmwork self-requested a review February 25, 2026 10:21
Copy link
Copy Markdown
Collaborator

@imstevenpmwork imstevenpmwork left a comment

Choose a reason for hiding this comment

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

LGTM!

@imstevenpmwork imstevenpmwork merged commit 0317a15 into huggingface:main Feb 25, 2026
8 checks passed
pkooij pushed a commit that referenced this pull request Feb 27, 2026
…decoding (#3016)

Replaced assert statements with FrameTimestampError exceptions in
decode_video_frames_torchvision and decode_video_frames_torchcodec.

Assertions are unsuitable for runtime validation because they can be
silently disabled with python -O, and they produce unhelpful
AssertionError tracebacks. The codebase already defines
FrameTimestampError for this exact purpose but it was only used
in one of the three validation sites.

Also removed AssertionError from the except clause in
LeRobotDataset.__init__, which was masking video timestamp errors
by silently triggering a dataset re-download instead of surfacing
the actual problem.
xianglunkai pushed a commit to xianglunkai/lerobot that referenced this pull request Feb 28, 2026
…decoding (huggingface#3016)

Replaced assert statements with FrameTimestampError exceptions in
decode_video_frames_torchvision and decode_video_frames_torchcodec.

Assertions are unsuitable for runtime validation because they can be
silently disabled with python -O, and they produce unhelpful
AssertionError tracebacks. The codebase already defines
FrameTimestampError for this exact purpose but it was only used
in one of the three validation sites.

Also removed AssertionError from the except clause in
LeRobotDataset.__init__, which was masking video timestamp errors
by silently triggering a dataset re-download instead of surfacing
the actual problem.
sorelferris pushed a commit to sorelferris/lerobot that referenced this pull request Mar 1, 2026
…decoding (huggingface#3016)

Replaced assert statements with FrameTimestampError exceptions in
decode_video_frames_torchvision and decode_video_frames_torchcodec.

Assertions are unsuitable for runtime validation because they can be
silently disabled with python -O, and they produce unhelpful
AssertionError tracebacks. The codebase already defines
FrameTimestampError for this exact purpose but it was only used
in one of the three validation sites.

Also removed AssertionError from the except clause in
LeRobotDataset.__init__, which was masking video timestamp errors
by silently triggering a dataset re-download instead of surfacing
the actual problem.
lu391see pushed a commit to lu391see/lerobot_tactile that referenced this pull request Mar 24, 2026
…decoding (huggingface#3016)

Replaced assert statements with FrameTimestampError exceptions in
decode_video_frames_torchvision and decode_video_frames_torchcodec.

Assertions are unsuitable for runtime validation because they can be
silently disabled with python -O, and they produce unhelpful
AssertionError tracebacks. The codebase already defines
FrameTimestampError for this exact purpose but it was only used
in one of the three validation sites.

Also removed AssertionError from the except clause in
LeRobotDataset.__init__, which was masking video timestamp errors
by silently triggering a dataset re-download instead of surfacing
the actual problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dataset Issues regarding data inputs, processing, or datasets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants