Skip to content

Commit bd66044

Browse files
xinlian12annie-mac
andauthored
remove feedRange as public Class Type (Azure#37935)
Co-authored-by: annie-mac <[email protected]>
1 parent 231cc64 commit bd66044

File tree

5 files changed

+19
-95
lines changed

5 files changed

+19
-95
lines changed

sdk/cosmos/azure-cosmos/azure/cosmos/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
)
4444
from .partition_key import PartitionKey
4545
from .permission import Permission
46-
from ._feed_range import FeedRange
4746

4847
__all__ = (
4948
"CosmosClient",
@@ -67,7 +66,6 @@
6766
"ConnectionRetryPolicy",
6867
"ThroughputProperties",
6968
"CosmosDict",
70-
"CosmosList",
71-
"FeedRange"
69+
"CosmosList"
7270
)
7371
__version__ = VERSION

sdk/cosmos/azure-cosmos/azure/cosmos/_change_feed/change_feed_state.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,9 @@ def from_initial_state(
383383

384384
feed_range: Optional[FeedRangeInternal] = None
385385
if change_feed_state_context.get("feedRange"):
386-
feed_range = change_feed_state_context.get("feedRange")
386+
feed_range_str = base64.b64decode(change_feed_state_context["feedRange"]).decode('utf-8')
387+
feed_range_json = json.loads(feed_range_str)
388+
feed_range = FeedRangeInternalEpk.from_json(feed_range_json)
387389
elif change_feed_state_context.get("partitionKey"):
388390
if change_feed_state_context.get("partitionKeyFeedRange"):
389391
feed_range =\
@@ -412,4 +414,4 @@ def from_initial_state(
412414
feed_range=feed_range,
413415
change_feed_start_from=change_feed_start_from,
414416
continuation=None)
415-
raise RuntimeError("feed_range is empty")
417+
raise ValueError("feed_range is empty")

sdk/cosmos/azure-cosmos/azure/cosmos/_feed_range.py

Lines changed: 0 additions & 70 deletions
This file was deleted.

sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from azure.core.tracing.decorator_async import distributed_trace_async # type: ignore
3333

3434
from ._cosmos_client_connection_async import CosmosClientConnection
35+
from .._change_feed.feed_range_internal import FeedRangeInternalEpk
3536
from .._cosmos_responses import CosmosDict, CosmosList
3637
from ._scripts import ScriptsProxy
3738
from .._base import (
@@ -42,7 +43,6 @@
4243
GenerateGuidId,
4344
_set_properties_cache
4445
)
45-
from .._feed_range import FeedRange, FeedRangeEpk
4646
from .._routing.routing_range import Range
4747
from ..offer import ThroughputProperties
4848
from ..partition_key import (
@@ -534,16 +534,15 @@ def query_items_change_feed(
534534
def query_items_change_feed(
535535
self,
536536
*,
537-
feed_range: FeedRange,
537+
feed_range: str,
538538
max_item_count: Optional[int] = None,
539539
start_time: Optional[Union[datetime, Literal["Now", "Beginning"]]] = None,
540540
priority: Optional[Literal["High", "Low"]] = None,
541541
**kwargs: Any
542542
) -> AsyncItemPaged[Dict[str, Any]]:
543543
"""Get a sorted list of items that were changed, in the order in which they were modified.
544544
545-
:keyword feed_range: The feed range that is used to define the scope.
546-
:type feed_range: ~azure.cosmos.FeedRange
545+
:keyword str feed_range: The feed range that is used to define the scope.
547546
:keyword int max_item_count: Max number of items to be returned in the enumeration operation.
548547
:keyword start_time: The start time to start processing chang feed items.
549548
Beginning: Processing the change feed items from the beginning of the change feed.
@@ -621,8 +620,7 @@ def query_items_change_feed( # pylint: disable=unused-argument
621620
"""Get a sorted list of items that were changed, in the order in which they were modified.
622621
623622
:keyword str continuation: The continuation token retrieved from previous response.
624-
:keyword feed_range: The feed range that is used to define the scope.
625-
:type feed_range: ~azure.cosmos.FeedRange
623+
:keyword str feed_range: The feed range that is used to define the scope.
626624
:keyword partition_key: The partition key that is used to define the scope
627625
(logical partition or a subset of a container)
628626
:type partition_key: Union[str, int, float, bool, List[Union[str, int, float, bool]]]
@@ -692,8 +690,7 @@ def query_items_change_feed( # pylint: disable=unused-argument
692690
self._get_epk_range_for_partition_key(kwargs.pop('partition_key'))
693691

694692
if kwargs.get("feed_range") is not None:
695-
feed_range: FeedRangeEpk = kwargs.pop('feed_range')
696-
change_feed_state_context["feedRange"] = feed_range._feed_range_internal
693+
change_feed_state_context["feedRange"] = kwargs.pop('feed_range')
697694

698695
feed_options["containerProperties"] = self._get_properties()
699696
feed_options["changeFeedStateContext"] = change_feed_state_context
@@ -1299,7 +1296,7 @@ async def read_feed_ranges(
12991296
*,
13001297
force_refresh: Optional[bool] = False,
13011298
**kwargs: Any
1302-
) -> List[FeedRange]:
1299+
) -> List[str]:
13031300
""" Obtains a list of feed ranges that can be used to parallelize feed operations.
13041301
13051302
:keyword bool force_refresh:
@@ -1318,5 +1315,5 @@ async def read_feed_ranges(
13181315
[Range("", "FF", True, False)],
13191316
**kwargs)
13201317

1321-
return [FeedRangeEpk(Range.PartitionKeyRangeToRange(partitionKeyRange))
1318+
return [FeedRangeInternalEpk(Range.PartitionKeyRangeToRange(partitionKeyRange)).__str__()
13221319
for partitionKeyRange in partition_key_ranges]

sdk/cosmos/azure-cosmos/azure/cosmos/container.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
GenerateGuidId,
3939
_set_properties_cache
4040
)
41+
from ._change_feed.feed_range_internal import FeedRangeInternalEpk
4142
from ._cosmos_client_connection import CosmosClientConnection
4243
from ._cosmos_responses import CosmosDict, CosmosList
43-
from ._feed_range import FeedRange, FeedRangeEpk
4444
from ._routing.routing_range import Range
4545
from .offer import Offer, ThroughputProperties
4646
from .partition_key import (
@@ -354,7 +354,7 @@ def query_items_change_feed(
354354
def query_items_change_feed(
355355
self,
356356
*,
357-
feed_range: FeedRange,
357+
feed_range: str,
358358
max_item_count: Optional[int] = None,
359359
start_time: Optional[Union[datetime, Literal["Now", "Beginning"]]] = None,
360360
priority: Optional[Literal["High", "Low"]] = None,
@@ -363,8 +363,7 @@ def query_items_change_feed(
363363

364364
"""Get a sorted list of items that were changed, in the order in which they were modified.
365365
366-
:keyword feed_range: The feed range that is used to define the scope.
367-
:type feed_range: ~azure.cosmos.FeedRange
366+
:keyword str feed_range: The feed range that is used to define the scope.
368367
:keyword int max_item_count: Max number of items to be returned in the enumeration operation.
369368
:keyword start_time: The start time to start processing chang feed items.
370369
Beginning: Processing the change feed items from the beginning of the change feed.
@@ -441,8 +440,7 @@ def query_items_change_feed(
441440
"""Get a sorted list of items that were changed, in the order in which they were modified.
442441
443442
:keyword str continuation: The continuation token retrieved from previous response.
444-
:keyword feed_range: The feed range that is used to define the scope.
445-
:type feed_range: ~azure.cosmos.FeedRange
443+
:keyword str feed_range: The feed range that is used to define the scope.
446444
:keyword partition_key: The partition key that is used to define the scope
447445
(logical partition or a subset of a container)
448446
:type partition_key: Union[str, int, float, bool, List[Union[str, int, float, bool]]]
@@ -528,8 +526,7 @@ def query_items_change_feed(
528526
self._get_epk_range_for_partition_key(kwargs.pop('partition_key'))
529527

530528
if kwargs.get("feed_range") is not None:
531-
feed_range: FeedRangeEpk = kwargs.pop('feed_range')
532-
change_feed_state_context["feedRange"] = feed_range._feed_range_internal
529+
change_feed_state_context["feedRange"] = kwargs.pop('feed_range')
533530

534531
container_properties = self._get_properties()
535532
feed_options["changeFeedStateContext"] = change_feed_state_context
@@ -1368,7 +1365,7 @@ def read_feed_ranges(
13681365
self,
13691366
*,
13701367
force_refresh: Optional[bool] = False,
1371-
**kwargs: Any) -> List[FeedRange]:
1368+
**kwargs: Any) -> List[str]:
13721369

13731370
""" Obtains a list of feed ranges that can be used to parallelize feed operations.
13741371
@@ -1387,5 +1384,5 @@ def read_feed_ranges(
13871384
[Range("", "FF", True, False)], # default to full range
13881385
**kwargs)
13891386

1390-
return [FeedRangeEpk(Range.PartitionKeyRangeToRange(partitionKeyRange))
1387+
return [FeedRangeInternalEpk(Range.PartitionKeyRangeToRange(partitionKeyRange)).__str__()
13911388
for partitionKeyRange in partition_key_ranges]

0 commit comments

Comments
 (0)