-
Notifications
You must be signed in to change notification settings - Fork 950
fix(task): model can sometimes be None #1855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
a81a633
to
e4e63e8
Compare
CC @hbredin , please let me know if you'd like any further information. Thanks! |
Thanks. PR should be on develop branch. It says that there are conflicts. Can you please check? |
e4e63e8
to
b45afff
Compare
Just rebased, should be all set. Please let me know! |
b45afff
to
3043fad
Compare
CC @hbredin Please let me know if you'd like me to change anything, thank you! |
3043fad
to
e69ffd2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a potential runtime error in the get_model
function by adding validation to ensure the loaded model has a callable eval
method before attempting to use it. The fix addresses cases where Model.from_pretrained()
might fail silently and return None
or an invalid object.
Key changes:
- Added validation to check if the model has a callable
eval
method before invoking it - Added comprehensive test coverage for the new validation logic
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/pyannote/audio/pipelines/utils/getter.py | Added validation check for callable eval method with descriptive error message |
tests/utils/test_getter.py | Added comprehensive test suite covering edge cases and normal functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
raise ValueError( | ||
"The model could not be loaded. " | ||
"Please check the checkpoint path or the model name. " | ||
f"Recieved: {model}" |
Copilot
AI
Aug 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a spelling error in the error message. 'Recieved' should be 'Received'.
f"Recieved: {model}" | |
f"Received: {model}" |
Copilot uses AI. Check for mistakes.
get_model(model) | ||
|
||
assert "The model could not be loaded" in str(excinfo.value) | ||
assert f"Recieved: {model}" in str(excinfo.value) |
Copilot
AI
Aug 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a spelling error in the test assertion. 'Recieved' should be 'Received' to match the corrected error message.
assert f"Recieved: {model}" in str(excinfo.value) | |
assert f"Received: {model}" in str(excinfo.value) |
Copilot uses AI. Check for mistakes.
get_model(model) | ||
|
||
assert "The model could not be loaded" in str(excinfo.value) | ||
assert f"Recieved: {model}" in str(excinfo.value) |
Copilot
AI
Aug 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a spelling error in the test assertion. 'Recieved' should be 'Received' to match the corrected error message.
assert f"Recieved: {model}" in str(excinfo.value) | |
assert f"Received: {model}" in str(excinfo.value) |
Copilot uses AI. Check for mistakes.
In
getter.py
, themodel
param can be an invalid model as a string. In that instance, ifModel.from_pretrained()
fails silently and returnsNone
, an uncaught error is thrown in this file when we attempt toeval
. We can catch this by checking ifmodel
can runeval()
.I chose to check for the callability of
eval
rather than aNone
check to potentially catch any future failures that aren'tNone
but don't containeval
.