Skip to content
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

Update config class check in auto factory #29854

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

Rocketknight1
Copy link
Member

@Rocketknight1 Rocketknight1 commented Mar 25, 2024

Our code for custom classes checks that model_class.config_class matches config_class, but this test is behaving oddly - it's returning a failure even though the two classes look identical to me. I changed the test to a string comparison test instead - it's possible that we're just initializing the two classes in slightly different ways, and that's creating two different objects that still represent the same class.

Update: The underlying cause is not my original PR, but PR #29262. The check is failing because we now use importlib.machinery.SourceFileLoader() rather than importlib.import_module, and this causes the two classes to not be equal (even though all their attributes are the same). I think the string comparison test should work fine as a solution for now!

Fixes #29828

(Probably) fixes #30149

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Rocketknight1
Copy link
Member Author

Pinging @amyeroberts for a quick review here, since we now have two issues complaining about it!

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

Thanks!

@amyeroberts
Copy link
Collaborator

Only concern is that we won't catch things if the attributes aren't the same

@Rocketknight1
Copy link
Member Author

I'm tentatively hopeful based on my testing, but I admit there are some mysteries in the import machinery that I don't fully understand.

@Rocketknight1 Rocketknight1 merged commit d71f5b3 into main Apr 10, 2024
21 checks passed
@Rocketknight1 Rocketknight1 deleted the update_config_class_check branch April 10, 2024 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants