Skip to content

Conversation

SBNovaScript
Copy link

In getter.py, the model param can be an invalid model as a string. In that instance, if Model.from_pretrained() fails silently and returns None, an uncaught error is thrown in this file when we attempt to eval. We can catch this by checking if model can run eval().

I chose to check for the callability of eval rather than a None check to potentially catch any future failures that aren't None but don't contain eval.

@SBNovaScript SBNovaScript force-pushed the fix/empty-model-path branch from a81a633 to e4e63e8 Compare April 3, 2025 02:37
@SBNovaScript
Copy link
Author

CC @hbredin , please let me know if you'd like any further information. Thanks!

@hbredin hbredin changed the base branch from main to develop April 3, 2025 05:16
@hbredin
Copy link
Member

hbredin commented Apr 3, 2025

Thanks. PR should be on develop branch. It says that there are conflicts. Can you please check?

@SBNovaScript SBNovaScript force-pushed the fix/empty-model-path branch from e4e63e8 to b45afff Compare April 4, 2025 08:18
@SBNovaScript
Copy link
Author

Thanks. PR should be on develop branch. It says that there are conflicts. Can you please check?

Just rebased, should be all set. Please let me know!

@SBNovaScript SBNovaScript force-pushed the fix/empty-model-path branch from b45afff to 3043fad Compare May 1, 2025 20:20
@SBNovaScript
Copy link
Author

CC @hbredin Please let me know if you'd like me to change anything, thank you!

@SBNovaScript SBNovaScript force-pushed the fix/empty-model-path branch from 3043fad to e69ffd2 Compare May 5, 2025 02:15
@hbredin hbredin requested a review from Copilot August 22, 2025 14:27
Copy link
Contributor

@Copilot Copilot AI left a 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}"
Copy link

Copilot AI Aug 22, 2025

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'.

Suggested change
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)
Copy link

Copilot AI Aug 22, 2025

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.

Suggested change
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)
Copy link

Copilot AI Aug 22, 2025

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.

Suggested change
assert f"Recieved: {model}" in str(excinfo.value)
assert f"Received: {model}" in str(excinfo.value)

Copilot uses AI. Check for mistakes.

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