tilebox-grpc 0.38.0__py3-none-any.whl → 0.40.0__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.
_tilebox/grpc/error.py CHANGED
@@ -9,6 +9,14 @@ from grpc import RpcError, StatusCode
9
9
  from grpc.aio import AioRpcError
10
10
 
11
11
 
12
+ class NetworkError(IOError):
13
+ """NetworkError indicates that a network error occurred while communicating with the server"""
14
+
15
+
16
+ class NetworkTimeoutError(NetworkError, TimeoutError):
17
+ """TimeoutError indicates that a request timed out"""
18
+
19
+
12
20
  class AuthenticationError(IOError):
13
21
  """AuthenticationError indicates that a server request failed due to a missing or invalid authentication token"""
14
22
 
@@ -60,20 +68,42 @@ class AnyRpcError(Protocol):
60
68
  def details(self) -> str: ...
61
69
 
62
70
 
63
- def translate_rpc_error(err: AnyRpcError) -> Exception:
71
+ def translate_rpc_error(err: AnyRpcError) -> BaseException: # noqa: PLR0911, C901
64
72
  # translate specific error codes to more pythonic errors
73
+
74
+ # https://grpc.io/docs/guides/error/
65
75
  match err.code():
76
+ case StatusCode.NOT_FOUND:
77
+ return NotFoundError(err.details())
78
+ case StatusCode.INVALID_ARGUMENT:
79
+ return ArgumentError(err.details())
66
80
  case StatusCode.UNAUTHENTICATED:
67
81
  return AuthenticationError(f"Unauthenticated: {err.details()}")
68
82
  case StatusCode.PERMISSION_DENIED:
69
83
  return AuthenticationError(f"Unauthorized: {err.details()}")
70
- case StatusCode.NOT_FOUND:
71
- return NotFoundError(err.details())
72
84
  case StatusCode.RESOURCE_EXHAUSTED:
73
85
  return SubscriptionLimitExceededError(err.details())
74
- case StatusCode.INVALID_ARGUMENT:
75
- return ArgumentError(err.details())
76
-
86
+ case StatusCode.DEADLINE_EXCEEDED:
87
+ # Deadline expired before server returned status
88
+ return NetworkTimeoutError(f"Request timed out: {err.details()}")
89
+ case StatusCode.UNAVAILABLE:
90
+ # Server shutting down, or some data transmitted and then the connection broke
91
+ return NetworkError(err.details())
92
+ case StatusCode.ABORTED:
93
+ return NetworkError(f"Request aborted: {err.details()}")
94
+ case StatusCode.UNKNOWN:
95
+ # Server threw an exception (or did something other than returning a status code to terminate the RPC)
96
+ return InternalServerError(f"Oops, something went wrong: {err.details()}")
97
+ case StatusCode.INTERNAL:
98
+ return InternalServerError(f"Oops, something went wrong: {err.details()}")
99
+ case StatusCode.CANCELLED:
100
+ # Client application cancelled the request
101
+ return KeyboardInterrupt(f"Request canceled by user: {err.details()}")
102
+ case StatusCode.UNIMPLEMENTED:
103
+ # Method not found on server
104
+ return NotImplementedError(err.details())
105
+
106
+ # for all other errors we raise a generic internal server error
77
107
  return InternalServerError(f"Oops, something went wrong: {err.details()}")
78
108
 
79
109
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tilebox-grpc
3
- Version: 0.38.0
3
+ Version: 0.40.0
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/
@@ -20,11 +20,11 @@ Classifier: Topic :: Scientific/Engineering
20
20
  Classifier: Topic :: Software Development
21
21
  Requires-Python: >=3.10
22
22
  Requires-Dist: anyio>=4
23
- Requires-Dist: grpcio-status>=1.67
24
- Requires-Dist: grpcio>=1.67
23
+ Requires-Dist: grpcio-status>=1.70
24
+ Requires-Dist: grpcio>=1.70
25
25
  Requires-Dist: lz4>=4
26
26
  Requires-Dist: nest-asyncio>=1.5.0
27
- Requires-Dist: protobuf>=5
27
+ Requires-Dist: protobuf>=6
28
28
  Description-Content-Type: text/markdown
29
29
 
30
30
  <h1 align="center">
@@ -1,6 +1,6 @@
1
1
  _tilebox/grpc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  _tilebox/grpc/channel.py,sha256=e0Dyn1GqgJScHcwMfNKwfLa1VPalHp_B3li3IEoKmoc,6342
3
- _tilebox/grpc/error.py,sha256=QVfLuvitYLlhWENE98zdb4m9gx0PGMsR6m1_prwkwj4,3598
3
+ _tilebox/grpc/error.py,sha256=HpxvGgYRCGejjZTPIKBc552-EzM-JuHQUDe1cjmmUyo,5102
4
4
  _tilebox/grpc/pagination.py,sha256=-KhkhQ_0IE-BgzjNAmkPac7fH55ZGICstaqRhCLvHGE,1292
5
5
  _tilebox/grpc/producer_consumer.py,sha256=NG6gUCcvYOGbplV1Vq9bFro-4cNpTHvT7eL4zlNDkkA,2154
6
6
  _tilebox/grpc/replay.py,sha256=_NC76BfmvazNrJI5MovSnPTC7kYwWZn3Au_0yPlOLsc,6006
@@ -10,6 +10,6 @@ _tilebox/grpc/aio/error.py,sha256=Lkf20vuQn9XaLj0MlQ1uqHRaenhYJ_P3rggNZyDMML8,12
10
10
  _tilebox/grpc/aio/pagination.py,sha256=6v95yqgC-m87kD96pjfpIsmY41YuxxR0Se1o3NTrkSs,1115
11
11
  _tilebox/grpc/aio/producer_consumer.py,sha256=aOZhZHD74GZEvfeZ9OzUsVk5uUIuuMQp1V7l3Y1PQ0w,2679
12
12
  _tilebox/grpc/aio/syncify.py,sha256=jhScVqEwsoNP6gLwJpnIIaBqMC3q4XqSkEfIPokYG8c,4035
13
- tilebox_grpc-0.38.0.dist-info/METADATA,sha256=MFYrj7b-FLd_pL1KR5c2rSQoMmh9LQoF0hNiNIYezOg,2955
14
- tilebox_grpc-0.38.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
- tilebox_grpc-0.38.0.dist-info/RECORD,,
13
+ tilebox_grpc-0.40.0.dist-info/METADATA,sha256=a92tXc0gegZBvP-TpOM99eaaq1ajFuNgh6l_2jCN33I,2955
14
+ tilebox_grpc-0.40.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
+ tilebox_grpc-0.40.0.dist-info/RECORD,,