-
Notifications
You must be signed in to change notification settings - Fork 3k
Adding Throughput Bucket Header #40340
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?
Adding Throughput Bucket Header #40340
Conversation
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 support for a new throughput bucket header to the SDK at both the request and client levels.
- Introduces the new "x-ms-cosmos-throughput-bucket" header in http_constants.py.
- Adds a new parameter "throughput_bucket" to various container and database creation/update functions.
- Updates internal request-building logic in _base.py to include the throughput bucket header.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
sdk/cosmos/azure-cosmos/azure/cosmos/http_constants.py | Adds the throughput bucket header constant. |
sdk/cosmos/azure-cosmos/azure/cosmos/database.py | Updates methods to accept and propagate a throughput_bucket parameter; includes an unexpected import. |
sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py | Adds throughput_bucket parameter support for client-level database creation. |
sdk/cosmos/azure-cosmos/azure/cosmos/container.py | Adds throughput_bucket support in item creation methods. |
sdk/cosmos/azure-cosmos/azure/cosmos/_base.py | Modifies header generation to include the throughput bucket if provided. |
Comments suppressed due to low confidence (1)
sdk/cosmos/azure-cosmos/azure/cosmos/http_constants.py:192
- [nitpick] Consider removing or clarifying the '#CHECK' comment to avoid leaving debugging markers in production code.
ThroughputBucket = "x-ms-cosmos-throughput-bucket" #CHECK
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py
Outdated
Show resolved
Hide resolved
b424ad1
to
419e374
Compare
API change check APIView has identified API level changes in this PR and created following API reviews. |
/azp run python - cosmos - ci |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Great work @andrewmathew1
Everything looks good to me. Requesting some changes. Please do add samples as well and add a section in the readme.md that our sdk supports this feature and link to the sample on how to use it.
@@ -160,6 +160,10 @@ def __init__( # pylint: disable=too-many-statements | |||
http_constants.HttpHeaders.IsContinuationExpected: False, | |||
} | |||
|
|||
throughput_bucket = kwargs.pop('throughput_bucket', None) | |||
if throughput_bucket: |
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.
what if the value is 0? how does python handle it?
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.
If the bucket id is between 1-5, it will either go to the corresponding bucket or be ignored based on if the user has set up their buckets. If its any other value like 0 or a number greater than 5 a bad request is thrown.
@@ -232,6 +237,7 @@ async def create_item( | |||
:keyword bool no_response: Indicates whether service should be instructed to skip | |||
sending response payloads. When not specified explicitly here, the default value will be determined from | |||
client-level options. | |||
:keyword int throughput_bucket: The desired throughput bucket for the client |
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.
is there any default value for this?
We should put some guidance here on the usage, etc. Please discuss with a PM to understand more on this.
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.
Discussed with Achint and he mentioned that there is no default value, it should just be null.
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.
thanks @andrewmathew1 , great job!
@@ -874,6 +874,20 @@ may have additional latencies associated with searching in the service. | |||
|
|||
You can find our sync samples [here][cosmos_index_sample] and our async samples [here][cosmos_index_sample_async] as well for additional guidance. | |||
|
|||
### Public Preview - Throughput Buckets |
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.
This should have a changelog entry for this new feature.
Description
Adding the throughput bucket header, available at the request and client level for both async and sync operations.
The throughput bucket header is able to be passed for every request on container and database operations. It's also able to be set at the overall client level. However, the header passed into the request will take precedence over the client level header if both are passed in.