Skip to content

Conversation

@mpurland
Copy link

@mpurland mpurland commented Nov 9, 2025

Description of changes

Complete migration to Pydantic v2, removing all v1 compatibility layers
and updating dependencies for Python 3.14.0 support.

Dependencies:

  • Update pydantic from >=1.9 to >=2.0,<3.0 in main package
  • Add pydantic-settings>=2.0,<3.0 (BaseSettings moved to separate package)
  • Update client pydantic to >=2.12.4
  • Remove graphlib_backport (built-in since Python 3.9)

chromadb/config.py:

  • Remove Pydantic v1/v2 compatibility detection layer
  • Import BaseSettings from pydantic_settings instead of pydantic
  • Convert @validator to @field_validator with mode="before" and @classmethod
  • Convert inner class Config to model_config dict
  • Add type annotations to chroma_coordinator_host, chroma_logservice_host, and chroma_logservice_port (Pydantic v2 requirement)
  • Add extra="ignore" to model_config to handle extra environment variables (Pydantic v2 forbids extra fields by default, unlike v1)

chromadb/server/fastapi/init.py:

  • Remove validate_model() compatibility function
  • Replace all validate_model(Model, data) calls with Model.model_validate(data) (20 occurrences across v1 and v2 API endpoints)

chromadb/types.py:

  • Remove get_model_fields() compatibility method
  • Replace self.get_model_fields() with type(self).model_fields (4 occurrences in getitem, setitem, eq)

rust/python_bindings/Cargo.toml:

  • Update version from "0.1.0" to "1.3.3" to match git tags

All compatibility shims removed for a cleaner Pydantic v2-only codebase.
Tested with Python 3.14.0.

Test plan

  1. Setup venv as necessary. Installs should be in the intended venv. e.g. source /path/to/venv/bin/activatge

  2. Clone onnxruntime (1.23.2) and install
    Install works after manually cloning onnxruntime (latest 1.23.2), building from source, and installing.
    On Mac:
    ./build.sh --config Release --build_wheel --parallel --skip_tests --use_coreml

Produces this artifact in

build/MacOS/Release/dist/onnxruntime-1.24.0-cp314-cp314-macosx_15_0_arm64.whl

pip install onnxruntime-1.24.0-cp314-cp314-macosx_15_0_arm64.whl

  1. Clone pypika and install
    Install via:
pip install build
python -m build
pip install dist/pypika-0.48.9-py2.py3-none-any.whl
  1. Clone this chroma fork as source
    pip install -e .

Latest chromadb should be working in Python 3.14.0 with your project.

I hope this helps other people trying to get recent ChromaDB working with Python 3.14.0.

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

Pydantic V1 to Pydantic V2. This allows projects to use Pydantic V2. This is a breaking change.

Observability plan

This is a breaking change.

Documentation Changes

Yes, since dependencies were updated. Pydantic V2.

  Complete migration to Pydantic v2, removing all v1 compatibility layers
  and updating dependencies for Python 3.14.0 support.

  Dependencies:
  - Update pydantic from >=1.9 to >=2.0,<3.0 in main package
  - Add pydantic-settings>=2.0,<3.0 (BaseSettings moved to separate package)
  - Update client pydantic to >=2.12.4
  - Remove graphlib_backport (built-in since Python 3.9)

  chromadb/config.py:
  - Remove Pydantic v1/v2 compatibility detection layer
  - Import BaseSettings from pydantic_settings instead of pydantic
  - Convert @validator to @field_validator with mode="before" and @classmethod
  - Convert inner class Config to model_config dict
  - Add type annotations to chroma_coordinator_host, chroma_logservice_host,
    and chroma_logservice_port (Pydantic v2 requirement)
  - Add extra="ignore" to model_config to handle extra environment variables
    (Pydantic v2 forbids extra fields by default, unlike v1)

  chromadb/server/fastapi/__init__.py:
  - Remove validate_model() compatibility function
  - Replace all validate_model(Model, data) calls with Model.model_validate(data)
    (20 occurrences across v1 and v2 API endpoints)

  chromadb/types.py:
  - Remove get_model_fields() compatibility method
  - Replace self.get_model_fields() with type(self).model_fields
    (4 occurrences in __getitem__, __setitem__, __eq__)

  rust/python_bindings/Cargo.toml:
  - Update version from "0.1.0" to "1.3.3" to match git tags

  All compatibility shims removed for a cleaner Pydantic v2-only codebase.
  Tested with Python 3.14.0.
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@propel-code-bot
Copy link
Contributor

Fully migrate ChromaDB to Pydantic v2 and enable Python 3.14 support

This PR removes the dual-support layer for Pydantic v1 and upgrades the entire code-base, build tooling and dependencies to Pydantic v2. By doing so ChromaDB now compiles and runs on the upcoming Python 3.14 release and aligns with the wider ecosystem shift toward the v2 API surface. Most changes touch configuration models, validators, and helper utilities that previously straddled both Pydantic versions, while core database behaviour remains untouched.

All v1-specific shims (e.g. custom validators, Config inner classes, helper wrappers) are dropped in favour of the v2 model_validate, @field_validator, and model_config patterns. Dependency declarations are updated accordingly—pydantic>=2.0,<3.0 plus the new pydantic-settings package—and obsolete backports are removed. This inevitably introduces a breaking change for downstream users still pinned to v1 but simplifies the codebase and future maintenance.

Key Changes

• Bumps core dependency to pydantic>=2.0,<3.0 and introduces pydantic-settings>=2.0,<3.0
• Removes all v1 compatibility shims (validate_model, get_model_fields, inner Config classes)
• Rewrites validators to use @field_validator and replaces Config with model_config dictionaries
• Updates FastAPI server, config models, and type helpers to use native Pydantic v2 APIs
• Drops graphlib_backport and bumps rust/python_bindings crate version in Cargo.toml
• Refreshes pyproject.toml, requirements files and Cargo.lock to reflect new bounds

Affected Areas

• chromadb/config.py
• chromadb/server/fastapi
• chromadb/types.py
• build & packaging files (pyproject.toml, requirements*.txt, Cargo.toml/lock)
• CI matrix / Python version support

This summary was automatically generated by @propel-code-bot

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.

1 participant