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

Upgrade to Pydantic 2.0 #1539

Open
picklelo opened this issue Aug 7, 2023 · 10 comments
Open

Upgrade to Pydantic 2.0 #1539

picklelo opened this issue Aug 7, 2023 · 10 comments
Labels
enhancement Anything you want improved feature request A feature you wanted added to reflex

Comments

@picklelo
Copy link
Contributor

picklelo commented Aug 7, 2023

We should update to the latest Pydantic version to benefit from performance improvements and compatibility with other libraries that are migrating.

@masenf
Copy link
Collaborator

masenf commented Aug 8, 2023

Blockers:

  • sqlmodel
  • ModelField no longer exists, need to find a replacement API

@lxbxinwei
Copy link

+1, Recommend!

@ElijahAhianyo ElijahAhianyo added enhancement Anything you want improved feature request A feature you wanted added to reflex labels Aug 8, 2023
@danik292
Copy link
Contributor

I can help you with this.

@masenf
Copy link
Collaborator

masenf commented Aug 22, 2023

Sounds great! Have you worked with pydantic internals much before?

There's a branch that some contributors have started working on getting sqlmodel going with pydantic v2 that is where I started a few weeks ago: fastapi/sqlmodel#632

Then the next step is getting reflex Base working with pydantic v2. I don't remember the exact errors I was hitting a few weeks ago, but trying to find a public alternative to ModelField was one of the main blockers. Since all reflex Vars and State is based on pydantic, there's quite a bit to fix up.

Good luck, check in and let us know how it's going.

Getting to pydantic v2 / sqlalchemy v2 will be big for Reflex.

@danik292
Copy link
Contributor

Sounds great! Have you worked with pydantic internals much before?

NO i hevent.😣

@benedikt-bartscher
Copy link
Contributor

sqlmodel 0.0.14 has been released with pydantic v2 support: https://github.com/tiangolo/sqlmodel/releases/tag/0.0.14

@deanchanter
Copy link

This is blocking me as most of the libraries I am using on my project have moved to Pydantic 2!

@ericfeunekes
Copy link

but trying to find a public alternative to ModelField was one of the main blockers.

@masenf I'm not sure how you're using ModelField internally, but does this help: https://docs.pydantic.dev/2.0/migration/#changes-to-validators-allowed-signatures

Looks like there is an approach documented for migration.

@jspaezp
Copy link

jspaezp commented Feb 19, 2024

I would add to the issues the fact that reflex-hosting-cli also depends on pydantic <2, so anyone that wants to contribute to the migration needs to handled that as well (I don't believe I have access to that repo ... LMK if there is anything I need to do to get access and potentially help with the migration)

Poetry output when resolving deps
Because reflex-hosting-cli (0.1.4) depends on pydantic (>=1.10.2,<2.0.0)

@masenf
Copy link
Collaborator

masenf commented Feb 19, 2024

There is a WiP branch: masenf/pydantic-v2 that I started on, but has been put on hold while the team worked on the radix components.

Now that's done, work may resume on pydantic v2 upgrade... but there are quite a few non-trivial bits that were blocking before and I don't think any of them have been resolved. Moving to v2 will require architectural work, and it's not clear if reflex should take that pydantic v2 dependency or try to retool onto dataclasses/attrs and raw sqlalchemy instead.

Pydantic v1 was great for getting Reflex off the ground, but if the work required to accommodate v2 is too great, then it might make more sense to not take the dependency at all and reduce the footprint and abstraction layers needed to use Reflex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Anything you want improved feature request A feature you wanted added to reflex
Projects
None yet
Development

No branches or pull requests

9 participants