Skip to content
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

removeFeedRangeFromPublicClassType #37935

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions sdk/cosmos/azure-cosmos/azure/cosmos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
)
from .partition_key import PartitionKey
from .permission import Permission
from ._feed_range import FeedRange

__all__ = (
"CosmosClient",
Expand All @@ -67,7 +66,6 @@
"ConnectionRetryPolicy",
"ThroughputProperties",
"CosmosDict",
"CosmosList",
"FeedRange"
"CosmosList"
)
__version__ = VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ def from_initial_state(

feed_range: Optional[FeedRangeInternal] = None
if change_feed_state_context.get("feedRange"):
feed_range = change_feed_state_context.get("feedRange")
feed_range_str = base64.b64decode(change_feed_state_context["feedRange"]).decode('utf-8')
feed_range_json = json.loads(feed_range_str)
feed_range = FeedRangeInternalEpk.from_json(feed_range_json)
elif change_feed_state_context.get("partitionKey"):
if change_feed_state_context.get("partitionKeyFeedRange"):
feed_range =\
Expand Down Expand Up @@ -412,4 +414,4 @@ def from_initial_state(
feed_range=feed_range,
change_feed_start_from=change_feed_start_from,
continuation=None)
raise RuntimeError("feed_range is empty")
raise ValueError("feed_range is empty")
70 changes: 0 additions & 70 deletions sdk/cosmos/azure-cosmos/azure/cosmos/_feed_range.py

This file was deleted.

17 changes: 7 additions & 10 deletions sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from azure.core.tracing.decorator_async import distributed_trace_async # type: ignore

from ._cosmos_client_connection_async import CosmosClientConnection
from .._change_feed.feed_range_internal import FeedRangeInternalEpk
from .._cosmos_responses import CosmosDict, CosmosList
from ._scripts import ScriptsProxy
from .._base import (
Expand All @@ -42,7 +43,6 @@
GenerateGuidId,
_set_properties_cache
)
from .._feed_range import FeedRange, FeedRangeEpk
from .._routing.routing_range import Range
from ..offer import ThroughputProperties
from ..partition_key import (
Expand Down Expand Up @@ -534,16 +534,15 @@ def query_items_change_feed(
def query_items_change_feed(
self,
*,
feed_range: FeedRange,
feed_range: str,
max_item_count: Optional[int] = None,
start_time: Optional[Union[datetime, Literal["Now", "Beginning"]]] = None,
priority: Optional[Literal["High", "Low"]] = None,
**kwargs: Any
) -> AsyncItemPaged[Dict[str, Any]]:
"""Get a sorted list of items that were changed, in the order in which they were modified.

:keyword feed_range: The feed range that is used to define the scope.
:type feed_range: ~azure.cosmos.FeedRange
:keyword str feed_range: The feed range that is used to define the scope.
:keyword int max_item_count: Max number of items to be returned in the enumeration operation.
:keyword start_time: The start time to start processing chang feed items.
Beginning: Processing the change feed items from the beginning of the change feed.
Expand Down Expand Up @@ -621,8 +620,7 @@ def query_items_change_feed( # pylint: disable=unused-argument
"""Get a sorted list of items that were changed, in the order in which they were modified.

:keyword str continuation: The continuation token retrieved from previous response.
:keyword feed_range: The feed range that is used to define the scope.
:type feed_range: ~azure.cosmos.FeedRange
:keyword str feed_range: The feed range that is used to define the scope.
:keyword partition_key: The partition key that is used to define the scope
(logical partition or a subset of a container)
:type partition_key: Union[str, int, float, bool, List[Union[str, int, float, bool]]]
Expand Down Expand Up @@ -692,8 +690,7 @@ def query_items_change_feed( # pylint: disable=unused-argument
self._get_epk_range_for_partition_key(kwargs.pop('partition_key'))

if kwargs.get("feed_range") is not None:
feed_range: FeedRangeEpk = kwargs.pop('feed_range')
change_feed_state_context["feedRange"] = feed_range._feed_range_internal
change_feed_state_context["feedRange"] = kwargs.pop('feed_range')

feed_options["containerProperties"] = self._get_properties()
feed_options["changeFeedStateContext"] = change_feed_state_context
Expand Down Expand Up @@ -1299,7 +1296,7 @@ async def read_feed_ranges(
*,
force_refresh: Optional[bool] = False,
**kwargs: Any
) -> List[FeedRange]:
) -> List[str]:
""" Obtains a list of feed ranges that can be used to parallelize feed operations.

:keyword bool force_refresh:
Expand All @@ -1318,5 +1315,5 @@ async def read_feed_ranges(
[Range("", "FF", True, False)],
**kwargs)

return [FeedRangeEpk(Range.PartitionKeyRangeToRange(partitionKeyRange))
return [FeedRangeInternalEpk(Range.PartitionKeyRangeToRange(partitionKeyRange)).__str__()
for partitionKeyRange in partition_key_ranges]
17 changes: 7 additions & 10 deletions sdk/cosmos/azure-cosmos/azure/cosmos/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
GenerateGuidId,
_set_properties_cache
)
from ._change_feed.feed_range_internal import FeedRangeInternalEpk
from ._cosmos_client_connection import CosmosClientConnection
from ._cosmos_responses import CosmosDict, CosmosList
from ._feed_range import FeedRange, FeedRangeEpk
from ._routing.routing_range import Range
from .offer import Offer, ThroughputProperties
from .partition_key import (
Expand Down Expand Up @@ -354,7 +354,7 @@ def query_items_change_feed(
def query_items_change_feed(
self,
*,
feed_range: FeedRange,
feed_range: str,
max_item_count: Optional[int] = None,
start_time: Optional[Union[datetime, Literal["Now", "Beginning"]]] = None,
priority: Optional[Literal["High", "Low"]] = None,
Expand All @@ -363,8 +363,7 @@ def query_items_change_feed(

"""Get a sorted list of items that were changed, in the order in which they were modified.

:keyword feed_range: The feed range that is used to define the scope.
:type feed_range: ~azure.cosmos.FeedRange
:keyword str feed_range: The feed range that is used to define the scope.
:keyword int max_item_count: Max number of items to be returned in the enumeration operation.
:keyword start_time: The start time to start processing chang feed items.
Beginning: Processing the change feed items from the beginning of the change feed.
Expand Down Expand Up @@ -441,8 +440,7 @@ def query_items_change_feed(
"""Get a sorted list of items that were changed, in the order in which they were modified.

:keyword str continuation: The continuation token retrieved from previous response.
:keyword feed_range: The feed range that is used to define the scope.
:type feed_range: ~azure.cosmos.FeedRange
:keyword str feed_range: The feed range that is used to define the scope.
:keyword partition_key: The partition key that is used to define the scope
(logical partition or a subset of a container)
:type partition_key: Union[str, int, float, bool, List[Union[str, int, float, bool]]]
Expand Down Expand Up @@ -528,8 +526,7 @@ def query_items_change_feed(
self._get_epk_range_for_partition_key(kwargs.pop('partition_key'))

if kwargs.get("feed_range") is not None:
feed_range: FeedRangeEpk = kwargs.pop('feed_range')
change_feed_state_context["feedRange"] = feed_range._feed_range_internal
change_feed_state_context["feedRange"] = kwargs.pop('feed_range')

container_properties = self._get_properties()
feed_options["changeFeedStateContext"] = change_feed_state_context
Expand Down Expand Up @@ -1368,7 +1365,7 @@ def read_feed_ranges(
self,
*,
force_refresh: Optional[bool] = False,
**kwargs: Any) -> List[FeedRange]:
**kwargs: Any) -> List[str]:

""" Obtains a list of feed ranges that can be used to parallelize feed operations.

Expand All @@ -1387,5 +1384,5 @@ def read_feed_ranges(
[Range("", "FF", True, False)], # default to full range
**kwargs)

return [FeedRangeEpk(Range.PartitionKeyRangeToRange(partitionKeyRange))
return [FeedRangeInternalEpk(Range.PartitionKeyRangeToRange(partitionKeyRange)).__str__()
for partitionKeyRange in partition_key_ranges]
Loading