Skip to content

fix: replace assert statements with raise ValueError in EncDecMultiTaskModel#15444

Open
stanley1208 wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
stanley1208:fix/replace-assert-with-raise-aed-model
Open

fix: replace assert statements with raise ValueError in EncDecMultiTaskModel#15444
stanley1208 wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
stanley1208:fix/replace-assert-with-raise-aed-model

Conversation

@stanley1208
Copy link
Contributor

What does this PR do?

Replace 5 assert statements with explicit raise ValueError in EncDecMultiTaskModel and its prompt parsing utility, per the Contributor guidelines which state:

"RaiseError is preferred to assert"

assert statements are silently removed when Python runs with the -O (optimize) flag, meaning invalid inputs would pass through uncaught in production. raise ValueError always executes regardless of optimization flags.

Changes:

  • Line 549: Validate timestamps parameter with raise ValueError instead of assert
  • Line 614: Validate use_lhotse config with raise ValueError instead of assert
  • Line 1415: Validate multi-turn prompt format with raise ValueError instead of assert
  • Line 1427: Validate prompt dict values with raise ValueError instead of assert
  • Line 1441: Validate prompt["slots"] type with raise ValueError instead of assert

Collection: ASR

Changelog

  • Replace 5 assert statements with raise ValueError in aed_multitask_models.py
  • All error messages preserved from original assertions

Before your PR is "Ready for review"

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests? (N/A — no behavior change, error type changes from AssertionError to ValueError)
  • Did you add or update any necessary documentation?

PR Type:

  • Bugfix

…skModel

Signed-off-by: stanley1208 <stanley.mei08@gmail.com>
Made-with: Cursor
@github-actions github-actions bot added the ASR label Feb 26, 2026
@stanley1208
Copy link
Contributor Author

@nithinraok Ready for review — replaces 5 assert statements with raise ValueError per CONTRIBUTING.md guidelines. No behavior change, just safer error handling. Thanks!

@pzelasko
Copy link
Collaborator

Looks good, please fix the checks

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants