Replace assert with ValueError in load_physical_aiavdataset()#73
Merged
super-anova merged 1 commit intoNVlabs:mainfrom May 1, 2026
Merged
Conversation
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 NVlabs#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]>
super-anova
approved these changes
May 1, 2026
Collaborator
|
Thanks for creating the PR! |
This was referenced May 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the
assertstatement inload_physical_aiavdataset()with aValueError, mirroring the pattern of merged PR #50 (which made the same change inhelper.create_message()).Why
assertstatements are stripped when Python runs with-O(optimization mode), so thet0_usvalidation would silently disappear and downstream timestamp arithmetic would produce confusing failures (negative offsets, out-of-range queries) instead of a clear input-validation error.ValueErroris the correct exception type for invalid argument values and is always raised regardless of optimization flags.Change
src/alpamayo_r1/load_physical_aiavdataset.py:The error message now includes the actual computed threshold so the caller can see which value they violated.
Test plan
python -c "import ast; ast.parse(open('src/alpamayo_r1/load_physical_aiavdataset.py').read())"— syntax OKt0_usgreater thannum_history_steps * time_step * 1_000_000proceeds as before; smaller/equal values now raiseValueErrorwith a descriptive message instead ofAssertionError.f"{name=}"is consistent with the project style (already used inhelper.pyafter Replace assert with ValueError in create_message() #50).References
create_message()inhelper.py