Skip to content

Commit

Permalink
Merge branch 'main' into enable_bandit_all
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangyan99 committed Nov 12, 2024
2 parents 37c2b5c + fb67611 commit d1bcb7f
Show file tree
Hide file tree
Showing 146 changed files with 790 additions and 965 deletions.
4 changes: 2 additions & 2 deletions eng/common/pipelines/templates/jobs/docindex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ jobs:
name: azsdk-pool-mms-win-2022-general
steps:
- task: UsePythonVersion@0
displayName: 'Use Python 3.9'
displayName: 'Use Python 3.11'
inputs:
versionSpec: '3.9'
versionSpec: '3.11'

- pwsh: |
Invoke-WebRequest -Uri "https://github.com/dotnet/docfx/releases/download/v2.43.2/docfx.zip" `
Expand Down
4 changes: 2 additions & 2 deletions scripts/release_helper/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from typing import Any, List

# assignee dict which will be assigned to handle issues
_JAVA_OWNER = {'azure-sdk'}
_JAVA_ASSIGNEE = {'weidongxu-microsoft', 'haolingdong-msft', 'XiaofeiCao', 'v-hongli1'}
_JAVA_OWNER = {'azure-sdk', 'haolingdong-msft'}
_JAVA_ASSIGNEE = {'weidongxu-microsoft', 'XiaofeiCao', 'v-hongli1'}


class IssueProcessJava(IssueProcess):
Expand Down
34 changes: 21 additions & 13 deletions sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,6 @@ def query_items_change_feed(
@distributed_trace
def query_items_change_feed( # pylint: disable=unused-argument
self,
*args: Any,
**kwargs: Any
) -> AsyncItemPaged[Dict[str, Any]]:

Expand All @@ -636,7 +635,6 @@ def query_items_change_feed( # pylint: disable=unused-argument
request. Once the user has reached their provisioned throughput, low priority requests are throttled
before high priority requests start getting throttled. Feature must first be enabled at the account level.
:keyword Callable response_hook: A callable invoked with the response metadata.
:param Any args: args
:returns: An AsyncItemPaged of items (dicts).
:rtype: AsyncItemPaged[Dict[str, Any]]
"""
Expand Down Expand Up @@ -1292,10 +1290,11 @@ async def execute_item_batch(
return await self.client_connection.Batch(
collection_link=self.container_link, batch_operations=batch_operations, options=request_options, **kwargs)

async def read_feed_ranges(
@distributed_trace
def read_feed_ranges(
self,
*,
force_refresh: Optional[bool] = False,
force_refresh: bool = False,
**kwargs: Any
) -> AsyncIterable[Dict[str, Any]]:
""" Obtains a list of feed ranges that can be used to parallelize feed operations.
Expand All @@ -1313,17 +1312,26 @@ async def read_feed_ranges(
if force_refresh is True:
self.client_connection.refresh_routing_map_provider()

partition_key_ranges =\
await self.client_connection._routing_map_provider.get_overlapping_ranges(
self.container_link,
# default to full range
[Range("", "FF", True, False)],
**kwargs)
async def get_next(continuation_token:str) -> List[Dict[str, Any]]: # pylint: disable=unused-argument
partition_key_ranges = \
await self.client_connection._routing_map_provider.get_overlapping_ranges( # pylint: disable=protected-access
self.container_link,
# default to full range
[Range("", "FF", True, False)],
**kwargs)

feed_ranges = [FeedRangeInternalEpk(Range.PartitionKeyRangeToRange(partitionKeyRange)).to_dict()
for partitionKeyRange in partition_key_ranges]

feed_ranges = [FeedRangeInternalEpk(Range.PartitionKeyRangeToRange(partitionKeyRange)).to_dict()
for partitionKeyRange in partition_key_ranges]
return feed_ranges

return AsyncList(feed_ranges)
async def extract_data(feed_ranges_response: List[Dict[str, Any]]):
return None, AsyncList(feed_ranges_response)

return AsyncItemPaged(
get_next,
extract_data
)

async def get_latest_session_token(
self,
Expand Down
25 changes: 17 additions & 8 deletions sdk/cosmos/azure-cosmos/azure/cosmos/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,10 +1362,11 @@ def delete_all_items_by_partition_key(
self.client_connection.DeleteAllItemsByPartitionKey(
collection_link=self.container_link, options=request_options, **kwargs)

@distributed_trace
def read_feed_ranges(
self,
*,
force_refresh: Optional[bool] = False,
force_refresh: bool = False,
**kwargs: Any) -> Iterable[Dict[str, Any]]:

""" Obtains a list of feed ranges that can be used to parallelize feed operations.
Expand All @@ -1383,14 +1384,22 @@ def read_feed_ranges(
if force_refresh is True:
self.client_connection.refresh_routing_map_provider()

partition_key_ranges =\
self.client_connection._routing_map_provider.get_overlapping_ranges(
self.container_link,
[Range("", "FF", True, False)], # default to full range
**kwargs)
def get_next(continuation_token:str) -> List[Dict[str, Any]]: # pylint: disable=unused-argument
partition_key_ranges = \
self.client_connection._routing_map_provider.get_overlapping_ranges( # pylint: disable=protected-access
self.container_link,
[Range("", "FF", True, False)], # default to full range
**kwargs)

feed_ranges = [FeedRangeInternalEpk(Range.PartitionKeyRangeToRange(partitionKeyRange)).to_dict()
for partitionKeyRange in partition_key_ranges]

return feed_ranges

def extract_data(feed_ranges_response: List[Dict[str, Any]]):
return None, iter(feed_ranges_response)

return [FeedRangeInternalEpk(Range.PartitionKeyRangeToRange(partitionKeyRange)).to_dict()
for partitionKeyRange in partition_key_ranges]
return ItemPaged(get_next, extract_data)

def get_latest_session_token(
self,
Expand Down
1 change: 0 additions & 1 deletion sdk/cosmos/azure-cosmos/samples/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@

# Query a sorted list of items that were changed for one feed range
# [START query_items_change_feed_from_beginning]
feed_ranges = container.read_feed_ranges()
for item in container.query_items_change_feed(feed_range=feed_ranges[0], start_time="Beginning"):
print(json.dumps(item, indent=True))
# [END query_items_change_feed_from_beginning]
3 changes: 1 addition & 2 deletions sdk/cosmos/azure-cosmos/samples/examples_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ async def examples_async():

# Get the feed ranges list from container.
# [START read_feed_ranges]
feed_ranges = [feed_range async for feed_range in await container.read_feed_ranges()]
feed_ranges = [feed_range async for feed_range in container.read_feed_ranges()]
# [END read_feed_ranges]

# Get a feed range from a partition key.
Expand Down Expand Up @@ -296,7 +296,6 @@ async def examples_async():
# The asynchronous client returns asynchronous iterators for its query methods;
# as such, we iterate over it by using an async for loop
# [START query_items_change_feed_from_beginning]
feed_ranges = [feed_range async for feed_range in await container.read_feed_ranges()]
async for item in container.query_items_change_feed(feed_range=feed_ranges[0], start_time="Beginning"):
print(json.dumps(item, indent=True))
# [END query_items_change_feed_from_beginning]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def storing_session_tokens_container_feed_ranges(container):
# to store session tokens in a cache by feed range from the partition key.
feed_ranges_and_session_tokens = []
previous_session_token = ""
feed_ranges = [feed_range async for feed_range in await container.read_feed_ranges()]
feed_ranges = [feed_range async for feed_range in container.read_feed_ranges()]

# populating cache with session tokens
for i in range(5):
Expand Down
6 changes: 3 additions & 3 deletions sdk/cosmos/azure-cosmos/test/test_change_feed_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TestChangeFeedAsync:
async def test_get_feed_ranges(self, setup):
created_collection = await setup["created_db"].create_container("get_feed_ranges_" + str(uuid.uuid4()),
PartitionKey(path="/pk"))
result = [feed_range async for feed_range in await created_collection.read_feed_ranges()]
result = [feed_range async for feed_range in created_collection.read_feed_ranges()]
assert len(result) == 1

@pytest.mark.parametrize("change_feed_filter_param", ["partitionKey", "partitionKeyRangeId", "feedRange"])
Expand All @@ -57,7 +57,7 @@ async def test_query_change_feed_with_different_filter_async(self, change_feed_f
elif change_feed_filter_param == "partitionKeyRangeId":
filter_param = {"partition_key_range_id": "0"}
elif change_feed_filter_param == "feedRange":
feed_ranges = [feed_range async for feed_range in await created_collection.read_feed_ranges()]
feed_ranges = [feed_range async for feed_range in created_collection.read_feed_ranges()]
assert len(feed_ranges) == 1
filter_param = {"feed_range": feed_ranges[0]}
else:
Expand All @@ -69,7 +69,7 @@ async def test_query_change_feed_with_different_filter_async(self, change_feed_f
assert len(iter_list) == 0

# Read change feed from current should return an empty list
query_iterable = created_collection.query_items_change_feed(filter_param)
query_iterable = created_collection.query_items_change_feed(**filter_param)
iter_list = [item async for item in query_iterable]
assert len(iter_list) == 0
if 'Etag' in created_collection.client_connection.last_response_headers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ async def create_items_logical_pk(container, target_pk_range, previous_session_t
@staticmethod
async def create_items_physical_pk(container, pk_feed_range, previous_session_token, feed_ranges_and_session_tokens, hpk=False):
target_session_token = ""
container_feed_ranges = [feed_range async for feed_range in await container.read_feed_ranges()]
container_feed_ranges = [feed_range async for feed_range in container.read_feed_ranges()]
target_feed_range = None
for feed_range in container_feed_ranges:
if await container.is_feed_range_subset(feed_range, pk_feed_range):
Expand Down
Loading

0 comments on commit d1bcb7f

Please sign in to comment.