-
Notifications
You must be signed in to change notification settings - Fork 2k
[ENH] Eventual consistency in clients #5947
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
Merged
HammadB
merged 1 commit into
hammad/eventual_consistency_frontend
from
hammad/eventual_consistency_python_client
Jan 9, 2026
+311
−10
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| Include, | ||
| Metadata, | ||
| Metadatas, | ||
| ReadLevel, | ||
| Where, | ||
| QueryResult, | ||
| GetResult, | ||
|
|
||
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| """Tests for the Search API endpoint.""" | ||
|
|
||
| from typing import Tuple | ||
| from uuid import uuid4 | ||
|
|
||
| import pytest | ||
|
|
||
| from chromadb.api import ClientAPI | ||
| from chromadb.api.models.Collection import Collection | ||
| from chromadb.api.types import Embeddings, ReadLevel | ||
| from chromadb.execution.expression import Knn, Search | ||
| from chromadb.test.conftest import ( | ||
| ClientFactories, | ||
| is_spann_disabled_mode, | ||
| skip_reason_spann_disabled, | ||
| ) | ||
|
|
||
|
|
||
| def _create_test_collection( | ||
| client_factories: ClientFactories, | ||
| ) -> Tuple[Collection, ClientAPI]: | ||
| """Create a test collection with some data.""" | ||
| client = client_factories.create_client_from_system() | ||
| client.reset() | ||
|
|
||
| collection_name = f"search_api_test_{uuid4().hex}" | ||
| collection = client.get_or_create_collection(name=collection_name) | ||
|
|
||
| return collection, client | ||
|
|
||
|
|
||
| @pytest.mark.skipif(is_spann_disabled_mode, reason=skip_reason_spann_disabled) | ||
| def test_search_with_read_level_index_and_wal( | ||
| client_factories: ClientFactories, | ||
| ) -> None: | ||
| """Test search with ReadLevel.INDEX_AND_WAL (default) returns results.""" | ||
| collection, _ = _create_test_collection(client_factories) | ||
|
|
||
| # Add some data | ||
| collection.add( | ||
| ids=["doc1", "doc2", "doc3"], | ||
| documents=["apple fruit", "banana fruit", "car vehicle"], | ||
| embeddings=[[0.1, 0.2, 0.3, 0.4], [0.2, 0.3, 0.4, 0.5], [0.9, 0.8, 0.7, 0.6]], | ||
| ) | ||
|
|
||
| # Search with explicit INDEX_AND_WAL (default behavior) | ||
| search = Search().rank(Knn(query=[0.1, 0.2, 0.3, 0.4], limit=10)) | ||
| results = collection.search(search, read_level=ReadLevel.INDEX_AND_WAL) | ||
|
|
||
| assert results["ids"] is not None | ||
| assert len(results["ids"]) == 1 | ||
| assert len(results["ids"][0]) > 0 | ||
|
|
||
|
|
||
| @pytest.mark.skipif(is_spann_disabled_mode, reason=skip_reason_spann_disabled) | ||
| def test_search_with_read_level_index_only( | ||
| client_factories: ClientFactories, | ||
| ) -> None: | ||
| """Test search with ReadLevel.INDEX_ONLY returns results.""" | ||
| collection, _ = _create_test_collection(client_factories) | ||
|
|
||
| # Add some data | ||
| collection.add( | ||
| ids=["doc1", "doc2", "doc3"], | ||
| documents=["apple fruit", "banana fruit", "car vehicle"], | ||
| embeddings=[[0.1, 0.2, 0.3, 0.4], [0.2, 0.3, 0.4, 0.5], [0.9, 0.8, 0.7, 0.6]], | ||
| ) | ||
|
|
||
| # Search with INDEX_ONLY - this skips the WAL | ||
| # Note: Results may or may not include recent writes depending on compaction state | ||
| search = Search().rank(Knn(query=[0.1, 0.2, 0.3, 0.4], limit=10)) | ||
| results = collection.search(search, read_level=ReadLevel.INDEX_ONLY) | ||
|
|
||
| # Just verify the API works and returns a valid response structure | ||
| assert results["ids"] is not None | ||
| assert len(results["ids"]) == 1 | ||
| # Results may be empty if data hasn't been compacted yet, which is expected behavior | ||
|
|
||
|
|
||
| @pytest.mark.skipif(is_spann_disabled_mode, reason=skip_reason_spann_disabled) | ||
| def test_search_default_read_level( | ||
| client_factories: ClientFactories, | ||
| ) -> None: | ||
| """Test search without explicit read_level uses default (INDEX_AND_WAL).""" | ||
| collection, _ = _create_test_collection(client_factories) | ||
|
|
||
| # Add some data | ||
| collection.add( | ||
| ids=["doc1", "doc2"], | ||
| documents=["hello world", "goodbye world"], | ||
| embeddings=[[0.1, 0.2, 0.3, 0.4], [0.5, 0.6, 0.7, 0.8]], | ||
| ) | ||
|
|
||
| # Search without specifying read_level (should use default) | ||
| search = Search().rank(Knn(query=[0.1, 0.2, 0.3, 0.4], limit=10)) | ||
| results = collection.search(search) | ||
|
|
||
| # Should return results since default is INDEX_AND_WAL (full consistency) | ||
| assert results["ids"] is not None | ||
| assert len(results["ids"]) == 1 | ||
| assert len(results["ids"][0]) > 0 | ||
|
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.