Add excluded locations on client and request levels#40298
Add excluded locations on client and request levels#40298allenkim0129 merged 33 commits intoAzure:mainfrom
Conversation
|
API change check APIView has identified API level changes in this PR and created following API reviews. |
|
/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). |
|
I created a new PR since there were some conflict with branch merges which ended up including more reviewer than required. Previous PR with comments: #40298 |
|
/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). |
There was a problem hiding this comment.
Copilot reviewed 28 out of 28 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
sdk/cosmos/azure-cosmos/azure/cosmos/_request_object.py:80
- [nitpick] Consider adding type validation in set_excluded_location_from_options to ensure that options['excludedLocations'] is actually a list of strings.
def set_excluded_location_from_options(self, options: Mapping[str, Any]) -> None:
sdk/cosmos/azure-cosmos/azure/cosmos/_location_cache.py:168
- [nitpick] Although returning a fallback endpoint keeps the service available, consider logging a warning to highlight that all regional endpoints were excluded and the fallback is being used.
if not applicable_endpoints:
|
This PR was created to remove unnecesary commits from the last PR. #40022 The previous PR will have all related comments from previous commits. |
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
simorenoh
left a comment
There was a problem hiding this comment.
This looks great overall, thanks Allen! Just had a couple of comments/ questions 👍
kushagraThapar
left a comment
There was a problem hiding this comment.
Amazing work @allenkim0129
Great development + test coverage. Thanks for the efforts on this.
One thing though, we should add a section in the readme.md as well, noting this feature and pointing to the sample from the readme.md
|
/azp run python - cosmos - tests |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
|
/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). |
* Add Excluded Locations Feature * Added multi-region tests * Fix _AddParitionKey to pass options to sub methods * Added initial live tests * Updated live-platform-matrix for multi-region tests * Add cosmosQuery mark to TestQuery * Correct spelling * Fixed live platform matrix syntax * Changed Multi-regions * Added client level ExcludedLocation for async * Update Live test settings * Added Async tests * Add more live tests for all other Python versions * Fix Async test failure * Fix live test failures * Fix live test failures * Fix live test failures * Add test_delete_all_items_by_partition_key * Remove test_delete_all_items_by_partition_key * Added missing doc for excluded_locations in async client * Remove duplicate functions * Fix live tests with multi write locations * Fixed bug with endpoint routing with multi write region partition key API calls * Adding emulator tests for delete_all_items_by_partition_key API * minimized duplicate codes * Added Async emulator tests * Nit: Changed test names * Addressed comments about documents * Address comments about method naming * Updated document to add more details of request level excluded_locations --------- Co-authored-by: Kushagra Thapar <kuthapar@microsoft.com>
Changes
This change will add excluded locations on
clientandrequestlevels.Design doc: https://microsoft-my.sharepoint.com/:w:/p/allekim/EWf4tc65_f9GiOv9aD2XkLMBD9h2ZAAXCcFTKghjutvqcg?e=AlD8w1
On Client level:
excluded_locationsparameter. This set will filter any existing preferred locations. If excluded locations filtered all preferred locations, Cosmos DB will use the default endpoints.On Request level:
excluded_locationsparameters along with any other parameters for Container level APIs. Thisexcluded_locationparameter will override the existing exlcuded locations on client level. This means also means that if a user can manupilate the client level excluded locations for the specific request. Moreover, if a user wants to skip all client level excluded locations, the user can simply pass an empty list[]of excluded locations to skip all excluded location filters.Client level API works with
excluded_location(11 APIs):Other Changes:
Bug Fix
can_use_multiple_write_locations_for_requestcheck method, becausePartitionKeyresource type was not included during the check.All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines