-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 Support for Pydantic v2 #1045
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
That PR is doing the opposite of what mine is, its further ensuring Pydantic is pinned below 2 where as this PR enables support for both 1.x and 2.x depending on the needs of all the libraries a project is importing.
outright support for v2 is probably not recommended right off the bat. Several other large projects like langchain, llama index, etc are all implementing this same strategy of unpinning <2 and enabling cross compatibility. This would unblock projects in the short term that are (reasonably) frustrated they can't upgrade several core libraries because of a few packages. Right now, the five lines of chromadb we use in our code base for a niche use case is blocking us from upgrading fastapi and several libraries that have minor CVEs so this is a pretty important upgrade. In the long term, full v2-only support will require auditing all dependancies of chromadb and submitting PRs on those repos where open source to ensure you can safely install pydantic 2.x.x with them.
Was having trouble getting my env running, would appreciate help fixing tests if my recent commit doesn't fix them! |
Thanks, I've been waiting for this. |
@srhinos unfortunately the pinned version of fastapi does not work with pydantic 2.x. What do you think should your change also include unpinning fastapi? What consequences will that have to other parts of the code? |
@tazarov afaik we pinned to the current version of fastapi mostly because of pydantic v2 as well. we'd like to support it bidirectionally! |
@jeffchuber gets sketchy when I unpin things: pip freeze | grep -E 'fastapi|numpy|pydantic'
fastapi==0.103.0
numpy==1.25.2
pydantic==2.3.0
pydantic_core==2.6.3 I just stopped it when most tests started failing: =================================== 142 failed, 212 passed, 4 xfailed, 4 xpassed, 12069 warnings in 533.74s (0:08:53) =================================== Most errors are like this: FAILED chromadb/test/property/test_filtering.py::test_empty_filter[fastapi_persistent] - Exception: {"detail":[{"type":"missing","loc":["query","collection"],"msg":"Field required","input":null,"url":"https://errors.pydantic.dev/2.3/v/mi...
FAILED chromadb/test/property/test_filtering.py::test_boolean_metadata[fastapi_persistent] - Exception: {"detail":[{"type":"missing","loc":["query","collection"],"msg":"Field required","input":null,"url":"https://errors.pydantic.dev/2.3/v/mi... |
I didn't get these same errors locally, instead got some flakey testing errors:
but rerunning all these tests had them pass so locally, saw a fully passing test suite. EDIT: Noticed I wasn't running pydantic 2 and FastAPI 0.100.0 so getting same errors now :( |
LMK if there's anything we (the pydantic team) can do to get this over the line. Seems a shame that chromadb is preventing people from adopting pydantic v2. |
I tried digging into this issue for ~20 mins but couldn't properly decipher chroma's implementation of FastAPI. The test calls a consumer of a backend api thats causing the failure but I just can't find where the backend is actually being hit at. ex: this test is calling this function which should be making a call to the backend which is ingested @ here but I'm not seeing that function actually trigger while running tests. if I could find the actual code location of where the pydantic model is being parsed without the proper fields, I could easily correct it but I gave it like an hr of digging before I cut my losses and went back to work on something else. |
I don't think this is working due to how fastapi switches support for v1 fastapi/fastapi#9966 It seems like it does not support pydantic.v1 imports. |
I added some color here, would love people's thoughts. |
Description of changes
Summarize the changes made by this PR.
Test plan
How are these changes tested?
pytest
for python,yarn test
for jsDocumentation Changes
Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs repository?
Yes, no changes necessary.