-
Notifications
You must be signed in to change notification settings - Fork 26.5k
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
Migrate to Pydantic v2 #27933
Comments
please migrate to pydantic v2 🤗 |
Please do this! |
Hi @lmmx, thanks for raising this! We can certainly think about having v2 with v1 fallback support. However, I suspect the previous difficulty being raised was that it's hard to manage fallbacks when there's an incompatibility with a third-party library we interface with. Completely agree that pinning to an old version is brittle and it's best we update if and when possible. WDYT @ydshieh? |
Hi, thank you for asking! For now, I can (at least) trigger a CI run with |
A PR (and its CI) is opened #28728 🤞 ! |
CircleCI is good. I still need to check with docker image and other CI on github |
Docker image is fine https://github.com/huggingface/transformers/actions/runs/7669130818/job/20902409442 (the failure at the end is not related to |
Feature request
Pydantic v2 was released five months ago in June 2023.
Transformers has pinned to v1 (#24596), which should only be used as a temporary solution.
Leaving it this way means that the many new features of Pydantic 2 are missed, and leaves little hope for the library to keep pace as a roadmap to v3 is already emerging.
In #24597 it was mentioned that part of the barrier was (at the time) in external dependencies that couple Transformers to v1:
These barriers should at the very least be enumerated, I’m sure there are ways to deal with them without holding the entire repo’s development back.
Libraries such as SQLModel have included support for both v1 and v2.
The pin adopted in Transformers has already begun to cause clashes with other libraries on v2 such as Gradio (v2.4.2 as raised in #27273)
I fully appreciate the need to maintain backcompatibility and it is possible to support both, as examples like SQLModel have demonstrated.
Motivation
The syntax of Pydantic v1 is incompatible with v2. Backpinning should only be used as a temporary measure, it is not a sustainable long-term approach. Specifically, the pin would be relaxed to
pydantic<3.0.0
as in SQLModel.Your contribution
I am opening this feature request to begin discussion and hopefully contribute to its resolution.
The text was updated successfully, but these errors were encountered: