Skip to content

Replace assert with ValueError in create_message()#50

Merged
BorisIvanovic merged 2 commits intoNVlabs:mainfrom
Dpakkk:fix/replace-assert-with-valueerror
Mar 5, 2026
Merged

Replace assert with ValueError in create_message()#50
BorisIvanovic merged 2 commits intoNVlabs:mainfrom
Dpakkk:fix/replace-assert-with-valueerror

Conversation

@Dpakkk
Copy link
Copy Markdown
Contributor

@Dpakkk Dpakkk commented Feb 27, 2026

Assert statements can be disabled with python -O flag, which would silently skip validation. Using ValueError ensures the check always runs and provides a clear exception type for callers to handle.

Assert statements can be disabled with python -O flag, which would
silently skip validation. Using ValueError ensures the check always
runs and provides a clear exception type for callers to handle.

Signed-off-by: Dpakkk <[email protected]>
@Dpakkk
Copy link
Copy Markdown
Contributor Author

Dpakkk commented Feb 27, 2026

Related issue: #51

Copy link
Copy Markdown
Contributor

@BorisIvanovic BorisIvanovic left a comment

Choose a reason for hiding this comment

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

Thank you very much!

Comment thread src/alpamayo_r1/helper.py Outdated
"""Construct the message using images and cot."""
assert frames.ndim == 4, f"{frames.ndim=}, expected (N, C, H, W)"
if frames.ndim != 4:
raise ValueError(f"frames.ndim={frames.ndim}, expected 4 (N, C, H, W)")
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.

Suggested change
raise ValueError(f"frames.ndim={frames.ndim}, expected 4 (N, C, H, W)")
raise ValueError(f"{frames.ndim=}, expected 4 (N, C, H, W)")

@BorisIvanovic BorisIvanovic merged commit 2d2b511 into NVlabs:main Mar 5, 2026
super-anova pushed a commit that referenced this pull request May 1, 2026
Assert statements can be disabled with python -O flag, which would
silently skip the t0_us validation. Using ValueError ensures the check
always runs and provides a clear exception type for callers to handle.

Mirrors the pattern of #50 (replace assert with ValueError in
create_message). Also includes the computed history_time_range in the
error message so callers can see the threshold they violated.

Signed-off-by: lonexreb <[email protected]>
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.

2 participants