fix: use installed package version for /version endpoint#7414
fix: use installed package version for /version endpoint#7414Functionhx wants to merge 1 commit into
Conversation
Fixes chroma-core#1341 The /version endpoint returns a hardcoded version string. This changes __version__ to read from importlib.metadata.version('chromadb') so it reflects the actual installed package version. Falls back to '0.0.0' if the package is not installed.
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
eeshsaxena
left a comment
There was a problem hiding this comment.
This looks correct to me. I confirmed the distribution name in pyproject.toml is chromadb, so version("chromadb") resolves the installed package version, and __version__ is what the /version endpoint (segment.py) and the client User-Agent header (fastapi.py/async_fastapi.py) report - so this makes all of them track the real installed version instead of a hardcoded string that drifts. The PackageNotFoundError -> "0.0.0" guard is the right shape.
One thing worth being aware of: the fallback path is hit when the package has no installed metadata - i.e. running straight from a source checkout without an install. A normal pip install/pip install -e . both write metadata, so version("chromadb") works there; it's only a bare source run that would now report 0.0.0 (previously it showed the hardcoded string). That seems like an acceptable trade for not letting the hardcoded value go stale, but flagging it in case any dev workflow relies on __version__ being meaningful without an install.
Deferring to the maintainers.
|
Thanks! Yeah, 0.0.0 is intentional — better than silently reporting a stale version after an upgrade. The bare-source case is pretty rare in practice. Happy to tweak if maintainers prefer something else. |
Fixes #1341
The /version endpoint currently returns a hardcoded version string. This changes version to read from importlib.metadata.version('chromadb') so it reflects the actual installed package version. Falls back to '0.0.0' if the package is not installed.