Fix get_collection/create_collection Raises docstring (#5492)#7112
Open
adityasingh2400 wants to merge 1 commit into
Open
Fix get_collection/create_collection Raises docstring (#5492)#7112adityasingh2400 wants to merge 1 commit into
adityasingh2400 wants to merge 1 commit into
Conversation
The Raises section on get_collection said ValueError, but the implementation actually raises NotFoundError; same shape for create_collection raising UniqueConstraintError rather than ValueError. Update the docstrings in chromadb/api/__init__.py, async_api.py and client.py so async and sync clients line up with the real exception types. Fixes chroma-core#5492
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
The
Raisessection onClientAPI.get_collectionsaysValueError, but the implementation inchromadb/api/segment.pyactually raisesNotFoundError. The same mismatch shows up oncreate_collection, whoseRaiseslistsValueErrorfor duplicate names while the SysDB / gRPC path raisesUniqueConstraintError. The async client and the concreteClientwrapper have the same drift, so callers consulting any of the three files get the wrong exception type to catch.This PR updates the docstrings in
chromadb/api/__init__.py,chromadb/api/async_api.py, andchromadb/api/client.pyso the sync and async clients describe the exceptions that are actually raised:get_collection:ValueErrorbecomesNotFoundError.create_collection: the duplicate-name entry becomesUniqueConstraintError; the existingValueError: If the collection name is invalid.entry is kept since name validation does raiseValueError.Client.get_collectionandClient.create_collection: add the missingNotFoundError/UniqueConstraintErrorentries alongside the existing embedding-functionValueErrorentry, which is still raised byvalidate_embedding_function_conflict_on_create/_on_get.Both
NotFoundErrorandUniqueConstraintErrorare already exported fromchromadb/errors.py, so users canfrom chromadb.errors import NotFoundError, UniqueConstraintErrorand catch them today.Fixes #5492.
This also supersedes the Python portion of #6369, which has been idle for roughly three months and bundles unrelated
.github/workflows/_rust-tests.ymlGCS credential changes that aren't appropriate for a docs fix.Test plan
Docstring-only change with no runtime behavior. Verified by reading
chromadb/api/segment.py(raise NotFoundError(...)at line 338 forget_collection) andchromadb/db/impl/grpc/client.py(raise UniqueConstraintError()for duplicate-collection paths), and confirming the existingValueErrorraises inchromadb/api/client.pycome fromvalidate_embedding_function_conflict_on_create/_on_getinchromadb/api/collection_configuration.py.Documentation Changes
This PR is itself the documentation change. No updates needed in the docs repo.