-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add tests for Spherical Quantizer Type. #44502
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
base: main
Are you sure you want to change the base?
Add tests for Spherical Quantizer Type. #44502
Conversation
spherical Quantizer Type.Spherical Quantizer Type.
Spherical Quantizer Type.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.
Pull request overview
This PR adds test coverage for the new Spherical quantizer type in Cosmos DB vector policies. The tests are currently skipped with @unittest.skip decorator since the Spherical quantizer type has not yet been released to production.
Key changes:
- Added shared test data dictionary (
VectorPolicyTestData) containing configuration for testing multiple quantizer types including the new spherical type - Added synchronous test method
test_create_valid_vector_indexing_policyto validate vector indexing policies - Added asynchronous test method
test_create_valid_vector_indexing_policy_asyncwith equivalent validation
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| sdk/cosmos/azure-cosmos/tests/test_vector_policy.py | Added VectorPolicyTestData dictionary with test configurations for multiple quantizer types (flat, quantizedFlat with product, diskANN with product, and diskANN with spherical) and new synchronous test method to validate indexing policies |
| sdk/cosmos/azure-cosmos/tests/test_vector_policy_async.py | Added import for VectorPolicyTestData and new asynchronous test method that mirrors the synchronous version for testing vector indexing policies |
| vector_embedding_policy=vector_embedding_policy, | ||
| indexing_policy=indexing_policy) | ||
| properties = created_container.read() | ||
| assert properties['indexingPolicy']['vectorIndexes'] == indexing_policy['vectorIndexes'] |
Copilot
AI
Dec 23, 2025
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.
The test creates a container but does not clean it up afterward. This could lead to resource leaks if the test is run multiple times. Add a cleanup step by calling self.test_db.delete_container() with the container ID after the assertions, similar to how test_create_vector_embedding_container handles cleanup.
| assert properties['indexingPolicy']['vectorIndexes'] == indexing_policy['vectorIndexes'] | |
| assert properties['indexingPolicy']['vectorIndexes'] == indexing_policy['vectorIndexes'] | |
| self.test_db.delete_container(created_container.id) |
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.
agreed with this comment, please add cleanup logic.
| created_container = await self.test_db.create_container( | ||
| id="container_" + str(uuid.uuid4()), | ||
| partition_key=PartitionKey(path="/id"), | ||
| vector_embedding_policy=vector_embedding_policy, | ||
| indexing_policy=indexing_policy) | ||
| properties = await created_container.read() | ||
| assert properties['indexingPolicy']['vectorIndexes'] == indexing_policy['vectorIndexes'] |
Copilot
AI
Dec 23, 2025
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.
The test creates a container but does not clean it up afterward. This could lead to resource leaks if the test is run multiple times. Add a cleanup step by calling await self.test_db.delete_container() with the container ID after the assertions, similar to how test_create_vector_embedding_container_async handles cleanup.
| created_container = await self.test_db.create_container( | |
| id="container_" + str(uuid.uuid4()), | |
| partition_key=PartitionKey(path="/id"), | |
| vector_embedding_policy=vector_embedding_policy, | |
| indexing_policy=indexing_policy) | |
| properties = await created_container.read() | |
| assert properties['indexingPolicy']['vectorIndexes'] == indexing_policy['vectorIndexes'] | |
| container_id = "container_" + str(uuid.uuid4()) | |
| created_container = await self.test_db.create_container( | |
| id=container_id, | |
| partition_key=PartitionKey(path="/id"), | |
| vector_embedding_policy=vector_embedding_policy, | |
| indexing_policy=indexing_policy) | |
| properties = await created_container.read() | |
| assert properties['indexingPolicy']['vectorIndexes'] == indexing_policy['vectorIndexes'] | |
| await self.test_db.delete_container(container_id) |
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.
Same here, thanks!
| vector_embedding_policy=vector_embedding_policy, | ||
| indexing_policy=indexing_policy) | ||
| properties = created_container.read() | ||
| assert properties['indexingPolicy']['vectorIndexes'] == indexing_policy['vectorIndexes'] |
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.
agreed with this comment, please add cleanup logic.
| created_container = await self.test_db.create_container( | ||
| id="container_" + str(uuid.uuid4()), | ||
| partition_key=PartitionKey(path="/id"), | ||
| vector_embedding_policy=vector_embedding_policy, | ||
| indexing_policy=indexing_policy) | ||
| properties = await created_container.read() | ||
| assert properties['indexingPolicy']['vectorIndexes'] == indexing_policy['vectorIndexes'] |
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.
Same here, thanks!
Dismissing my own review to not block the PR after the comments have been resolved.
Description
Added tests for Spherical quantizer types.
Since
Spahericalquantizer type hasn't been released to production, I have tested locally withStageaccounts.Remove
@unittest.skiponce it is released to production.All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines