tilebox-grpc 0.35.0__py3-none-any.whl → 0.36.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ from collections.abc import AsyncIterator, Awaitable, Callable
2
+
3
+ from _tilebox.grpc.pagination import AnyResultPage, Pagination
4
+
5
+
6
+ async def paginated_request(
7
+ paging_request: Callable[[Pagination], Awaitable[AnyResultPage]],
8
+ initial_page: Pagination,
9
+ ) -> AsyncIterator[AnyResultPage]:
10
+ """Make a paginated request to a gRPC service endpoint.
11
+
12
+ The endpoint is expected to return a next_page field, which is used for subsequent requests. Once no such
13
+ next_page field is returned, the request is completed.
14
+
15
+ Args:
16
+ paging_request: A function that takes a page as input and returns a Datapoints object
17
+ Often this will be a functools.partial object that wraps a gRPC service endpoint
18
+ and only leaves the page argument remaining
19
+ initial_page: The initial page to request
20
+
21
+ Yields:
22
+ Datapoints: The individual pages of the response
23
+ """
24
+ response = await paging_request(initial_page)
25
+ yield response
26
+
27
+ while response.next_page.starting_after is not None:
28
+ response = await paging_request(response.next_page)
29
+ yield response
@@ -0,0 +1,42 @@
1
+ from collections.abc import Callable, Iterator
2
+ from typing import Protocol, TypeVar
3
+ from uuid import UUID
4
+
5
+
6
+ class Pagination(Protocol):
7
+ limit: int | None
8
+ starting_after: UUID | None
9
+
10
+
11
+ class ResultPage(Protocol):
12
+ @property
13
+ def next_page(self) -> Pagination: ...
14
+
15
+
16
+ AnyResultPage = TypeVar("AnyResultPage", bound=ResultPage)
17
+
18
+
19
+ def paginated_request(
20
+ paging_request: Callable[[Pagination], AnyResultPage],
21
+ initial_page: Pagination,
22
+ ) -> Iterator[AnyResultPage]:
23
+ """Make a paginated request to a gRPC service endpoint.
24
+
25
+ The endpoint is expected to return a next_page field, which is used for subsequent requests. Once no such
26
+ next_page field is returned, the request is completed.
27
+
28
+ Args:
29
+ paging_request: A function that takes a page as input and returns a Datapoints object
30
+ Often this will be a functools.partial object that wraps a gRPC service endpoint
31
+ and only leaves the page argument remaining
32
+ initial_page: The initial page to request
33
+
34
+ Yields:
35
+ Datapoints: The individual pages of the response
36
+ """
37
+ response = paging_request(initial_page)
38
+ yield response
39
+
40
+ while response.next_page.starting_after is not None:
41
+ response = paging_request(response.next_page)
42
+ yield response
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tilebox-grpc
3
- Version: 0.35.0
3
+ Version: 0.36.1
4
4
  Summary: GRPC / Protocol Buffers functions for Tilebox
5
5
  Project-URL: Homepage, https://tilebox.com
6
6
  Project-URL: Documentation, https://docs.tilebox.com/
@@ -1,13 +1,15 @@
1
1
  _tilebox/grpc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  _tilebox/grpc/channel.py,sha256=2uBAHcmKdGCzqVHhTsISAVirI9bQxXNfbC4GGM6RyHM,5332
3
3
  _tilebox/grpc/error.py,sha256=QVfLuvitYLlhWENE98zdb4m9gx0PGMsR6m1_prwkwj4,3598
4
+ _tilebox/grpc/pagination.py,sha256=-KhkhQ_0IE-BgzjNAmkPac7fH55ZGICstaqRhCLvHGE,1292
4
5
  _tilebox/grpc/producer_consumer.py,sha256=NG6gUCcvYOGbplV1Vq9bFro-4cNpTHvT7eL4zlNDkkA,2154
5
6
  _tilebox/grpc/replay.py,sha256=_NC76BfmvazNrJI5MovSnPTC7kYwWZn3Au_0yPlOLsc,6006
6
7
  _tilebox/grpc/aio/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
8
  _tilebox/grpc/aio/channel.py,sha256=KPmMTDDW0WGCO1ZKQ7NBauE1M7NK5FxuAa2HCMYc-r8,2317
8
9
  _tilebox/grpc/aio/error.py,sha256=Lkf20vuQn9XaLj0MlQ1uqHRaenhYJ_P3rggNZyDMML8,1222
10
+ _tilebox/grpc/aio/pagination.py,sha256=6v95yqgC-m87kD96pjfpIsmY41YuxxR0Se1o3NTrkSs,1115
9
11
  _tilebox/grpc/aio/producer_consumer.py,sha256=aOZhZHD74GZEvfeZ9OzUsVk5uUIuuMQp1V7l3Y1PQ0w,2679
10
12
  _tilebox/grpc/aio/syncify.py,sha256=jhScVqEwsoNP6gLwJpnIIaBqMC3q4XqSkEfIPokYG8c,4035
11
- tilebox_grpc-0.35.0.dist-info/METADATA,sha256=nNM3uXJUsWrpPp2vH7fWqEw2GxM34GMAKwdh5i6KLHs,2323
12
- tilebox_grpc-0.35.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
- tilebox_grpc-0.35.0.dist-info/RECORD,,
13
+ tilebox_grpc-0.36.1.dist-info/METADATA,sha256=cevm7Kk4WIhrX7MRy4fwLvdrRSlqCa4tN5DbZGeeW_o,2323
14
+ tilebox_grpc-0.36.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
+ tilebox_grpc-0.36.1.dist-info/RECORD,,