Skip to content

Conversation

@allenkim0129
Copy link
Contributor

Description

Added tests for Spherical quantizer types.

Since Spaherical quantizer type hasn't been released to production, I have tested locally with Stage accounts.

Remove @unittest.skip once it is released to production.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@allenkim0129 allenkim0129 changed the title Add tests for spherical Quantizer Type. Add tests for Spherical Quantizer Type. Dec 22, 2025
@allenkim0129 allenkim0129 changed the title Add tests for Spherical Quantizer Type. Add tests for Spherical Quantizer Type. Dec 22, 2025
@allenkim0129 allenkim0129 marked this pull request as ready for review December 23, 2025 19:32
@allenkim0129 allenkim0129 requested a review from a team as a code owner December 23, 2025 19:32
Copilot AI review requested due to automatic review settings December 23, 2025 19:32
Copy link
Contributor

Copilot AI left a 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_policy to validate vector indexing policies
  • Added asynchronous test method test_create_valid_vector_indexing_policy_async with 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']
Copy link

Copilot AI Dec 23, 2025

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.

Suggested change
assert properties['indexingPolicy']['vectorIndexes'] == indexing_policy['vectorIndexes']
assert properties['indexingPolicy']['vectorIndexes'] == indexing_policy['vectorIndexes']
self.test_db.delete_container(created_container.id)

Copilot uses AI. Check for mistakes.
Copy link
Member

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.

Comment on lines +55 to +61
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']
Copy link

Copilot AI Dec 23, 2025

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Copy link
Member

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']
Copy link
Member

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.

Comment on lines +55 to +61
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']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, thanks!

@kushagraThapar kushagraThapar dismissed their stale review December 29, 2025 21:50

Dismissing my own review to not block the PR after the comments have been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants