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

Add Pydantic v2 support #213

Closed
wants to merge 3 commits into from
Closed

Conversation

mrwyattii
Copy link
Contributor

No description provided.

@ringohoffman
Copy link
Contributor

ringohoffman commented Sep 25, 2023

From the migration guide:

Due to performance overhead and implementation complexity, we have now deprecated support for specifying json_encoders in the model config. This functionality was originally added for the purpose of achieving custom serialization logic, and we think the new serialization decorators are a better choice in most common scenarios.

I think this would be effectively the same as json_encoders={torch.dtype: lambda x: str(x)}:

    @field_serializer('dtype')
    def serialize_dtype(
        self, v: Union[torch.dtype, DtypeEnum], info: SerializationInfo
    ) -> str:
        if isinstance(v, torch.dtype):
            return str(v)
        return str(v.value)

@loadams
Copy link
Contributor

loadams commented Aug 19, 2024

Closing this instance as it is repetitive with the actual pydantic PR that will be merged

@loadams loadams closed this Aug 19, 2024
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