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

Fix ModelHubMixin when class is a dataclass #2159

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Mar 26, 2024

When the ModelHubMixin class happens to be a dataclass, __init__ method will accept **kwargs when
inspecting it. However, due to how dataclasses work, we cannot forward arbitrary kwargs to the __init__.
This test ensures that the from_pretrained method does not raise an error when the class is a dataclass.

This PR fixes the SetFit integration (see #2157). However, this is not a pattern we want to promote. Dataclasses are meant to store data. Model classes are more complex and doesn't play well with internal values.

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

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for the offline explainer!

@Wauplin
Copy link
Contributor Author

Wauplin commented Mar 26, 2024

Thanks for the review @LysandreJik. Will merge and make a patch release

@Wauplin Wauplin merged commit a9453d9 into main Mar 26, 2024
15 of 16 checks passed
@Wauplin Wauplin deleted the 2157-fix-model-hub-mixin-if-is-dataclass branch March 26, 2024 13:39
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.

3 participants