-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[BUG] Test that query result shapes are correct in invariants #2807
[BUG] Test that query result shapes are correct in invariants #2807
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
@@ -261,10 +259,14 @@ def ann_accuracy( | |||
include=["embeddings", "documents", "metadatas", "distances"], # type: ignore[list-item] | |||
) | |||
|
|||
_query_results_are_correct_shape(query_results, n_results) | |||
|
|||
# Assert fields are not None for type checking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had to bring this back out for typechecker :(
query_results: types.QueryResult, n_results: int | ||
) -> None: | ||
for result_type in ["distances", "embeddings", "documents", "metadatas"]: | ||
assert query_results[result_type] is not None # type: ignore[literal-required] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushed asserts down for debuggability
@@ -308,6 +309,55 @@ def test_persist_embeddings_state( | |||
) # type: ignore | |||
|
|||
|
|||
def test_delete_less_than_k( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: rename and clean up
LGTM! Counting is the hardest problem... |
@@ -205,7 +205,7 @@ fn merge_results( | |||
let mut brute_force_index = 0; | |||
|
|||
// TODO: This doesn't have to clone the user IDs, but it's easier for now | |||
while (result_user_ids.len() <= k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eww
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge logic in both local and distributed look fine
Description of changes
Summarize the changes made by this PR.
PersistentLocalHnswSegment
wherequery_vectors
can return results with lengths different thann_results
. This PR implements a test both displays and catches this issue.Test plan
How are these changes tested?
pytest
for python,yarn test
for js,cargo test
for rust