Added Priority Based Execution for Sync and Async Clients#43917
Added Priority Based Execution for Sync and Async Clients#43917andrewmathew1 merged 10 commits intoAzure:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds client-level priority configuration for Azure Cosmos DB clients (both sync and async), allowing users to set a default priority level for all requests made by a client. This complements the existing request-level priority feature, with request-level priority taking precedence when both are set.
- Added
priority_levelparameter toCosmosClientconstructors in both sync and async implementations - Client-level priority is stored in default headers and applied to all requests
- Comprehensive documentation and examples demonstrating client-level priority, request-level priority, and precedence behavior
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py | Implements client-level priority by adding priority_level parameter and storing it in default_headers |
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py | Async implementation of client-level priority, mirroring the sync implementation |
| sdk/cosmos/azure-cosmos/tests/test_headers.py | Adds tests for client-level priority and request-level precedence in sync client |
| sdk/cosmos/azure-cosmos/tests/test_headers_async.py | Adds tests for client-level priority and request-level precedence in async client |
| sdk/cosmos/azure-cosmos/samples/examples.py | Demonstrates client-level priority usage and precedence with practical examples |
| sdk/cosmos/azure-cosmos/samples/examples_async.py | Demonstrates async client-level priority usage and precedence with practical examples |
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
simorenoh
left a comment
There was a problem hiding this comment.
Some small comments but overall the changes seem to be good, thanks Andrew!
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Co-authored-by: Simon Moreno <30335873+simorenoh@users.noreply.github.com>
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
* Added priority level for clients * added to changelog and docstring * changed item to queried_item for pylint * made suggested changes * fixed sample bug * Update sdk/cosmos/azure-cosmos/CHANGELOG.md Co-authored-by: Simon Moreno <30335873+simorenoh@users.noreply.github.com> * Changed test pipeline from West US to West Central US * added changes to vector index policy tests * bugfixes for vector policy tests --------- Co-authored-by: Andrew Mathew <andrewmathew@microsoft.com> Co-authored-by: Simon Moreno <30335873+simorenoh@users.noreply.github.com>
Description
Priority-based execution is a capability which allows users to specify priority for the request sent to Azure Cosmos DB. Based on the priority specified by the user, if there are more requests than the configured RU/s in a second, then Azure Cosmos DB will throttle low priority requests to allow high priority requests to execute. Previously this was only available at the request level now entire clients can be set to a low or high priority level. The request priority level will take precedence over the client priority level in case both are set.