supervisely 6.73.255__py3-none-any.whl → 6.73.256__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.
Potentially problematic release.
This version of supervisely might be problematic. Click here for more details.
- supervisely/api/api.py +16 -8
- supervisely/io/network_exceptions.py +14 -2
- {supervisely-6.73.255.dist-info → supervisely-6.73.256.dist-info}/METADATA +1 -1
- {supervisely-6.73.255.dist-info → supervisely-6.73.256.dist-info}/RECORD +8 -8
- {supervisely-6.73.255.dist-info → supervisely-6.73.256.dist-info}/LICENSE +0 -0
- {supervisely-6.73.255.dist-info → supervisely-6.73.256.dist-info}/WHEEL +0 -0
- {supervisely-6.73.255.dist-info → supervisely-6.73.256.dist-info}/entry_points.txt +0 -0
- {supervisely-6.73.255.dist-info → supervisely-6.73.256.dist-info}/top_level.txt +0 -0
supervisely/api/api.py
CHANGED
|
@@ -69,6 +69,7 @@ from supervisely.io.network_exceptions import (
|
|
|
69
69
|
process_requests_exception,
|
|
70
70
|
process_requests_exception_async,
|
|
71
71
|
process_unhandled_request,
|
|
72
|
+
RetryableRequestException,
|
|
72
73
|
)
|
|
73
74
|
from supervisely.project.project_meta import ProjectMeta
|
|
74
75
|
from supervisely.sly_logger import logger
|
|
@@ -1283,16 +1284,20 @@ class Api:
|
|
|
1283
1284
|
Api._raise_for_status_httpx(resp)
|
|
1284
1285
|
|
|
1285
1286
|
hhash = resp.headers.get("x-content-checksum-sha256", None)
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1287
|
+
try:
|
|
1288
|
+
for chunk in resp.iter_raw(chunk_size):
|
|
1289
|
+
yield chunk, hhash
|
|
1290
|
+
total_streamed += len(chunk)
|
|
1291
|
+
except Exception as e:
|
|
1292
|
+
raise RetryableRequestException(repr(e))
|
|
1293
|
+
|
|
1289
1294
|
if expected_size != 0 and total_streamed != expected_size:
|
|
1290
1295
|
raise ValueError(
|
|
1291
1296
|
f"Streamed size does not match the expected: {total_streamed} != {expected_size}"
|
|
1292
1297
|
)
|
|
1293
1298
|
logger.trace(f"Streamed size: {total_streamed}, expected size: {expected_size}")
|
|
1294
1299
|
return
|
|
1295
|
-
except (httpx.RequestError, httpx.HTTPStatusError) as e:
|
|
1300
|
+
except (httpx.RequestError, httpx.HTTPStatusError, RetryableRequestException) as e:
|
|
1296
1301
|
if (
|
|
1297
1302
|
isinstance(e, httpx.HTTPStatusError)
|
|
1298
1303
|
and resp.status_code == 400
|
|
@@ -1531,9 +1536,12 @@ class Api:
|
|
|
1531
1536
|
|
|
1532
1537
|
# received hash of the content to check integrity of the data stream
|
|
1533
1538
|
hhash = resp.headers.get("x-content-checksum-sha256", None)
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1539
|
+
try:
|
|
1540
|
+
async for chunk in resp.aiter_raw(chunk_size):
|
|
1541
|
+
yield chunk, hhash
|
|
1542
|
+
total_streamed += len(chunk)
|
|
1543
|
+
except Exception as e:
|
|
1544
|
+
raise RetryableRequestException(repr(e))
|
|
1537
1545
|
|
|
1538
1546
|
if expected_size != 0 and total_streamed != expected_size:
|
|
1539
1547
|
raise ValueError(
|
|
@@ -1541,7 +1549,7 @@ class Api:
|
|
|
1541
1549
|
)
|
|
1542
1550
|
logger.trace(f"Streamed size: {total_streamed}, expected size: {expected_size}")
|
|
1543
1551
|
return
|
|
1544
|
-
except (httpx.RequestError, httpx.HTTPStatusError) as e:
|
|
1552
|
+
except (httpx.RequestError, httpx.HTTPStatusError, RetryableRequestException) as e:
|
|
1545
1553
|
if (
|
|
1546
1554
|
isinstance(e, httpx.HTTPStatusError)
|
|
1547
1555
|
and resp.status_code == 400
|
|
@@ -28,6 +28,14 @@ RETRY_STATUS_CODES = {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
class RetryableRequestException(Exception):
|
|
32
|
+
"""Exception that indicates that the request should be retried."""
|
|
33
|
+
|
|
34
|
+
def __init__(self, message, response=None):
|
|
35
|
+
super().__init__(message)
|
|
36
|
+
self.response = response
|
|
37
|
+
|
|
38
|
+
|
|
31
39
|
async def process_requests_exception_async(
|
|
32
40
|
external_logger,
|
|
33
41
|
exc,
|
|
@@ -50,6 +58,8 @@ async def process_requests_exception_async(
|
|
|
50
58
|
except Exception:
|
|
51
59
|
pass
|
|
52
60
|
|
|
61
|
+
is_retryable_exception = isinstance(exc, RetryableRequestException)
|
|
62
|
+
|
|
53
63
|
is_connection_error = isinstance(
|
|
54
64
|
exc,
|
|
55
65
|
(
|
|
@@ -82,7 +92,7 @@ async def process_requests_exception_async(
|
|
|
82
92
|
except (AttributeError, ValueError):
|
|
83
93
|
pass
|
|
84
94
|
|
|
85
|
-
if is_connection_error
|
|
95
|
+
if any([is_connection_error, is_server_retryable_error, is_retryable_exception]):
|
|
86
96
|
await process_retryable_request_async(
|
|
87
97
|
external_logger,
|
|
88
98
|
exc,
|
|
@@ -136,6 +146,8 @@ def process_requests_exception(
|
|
|
136
146
|
except Exception:
|
|
137
147
|
pass
|
|
138
148
|
|
|
149
|
+
is_retryable_exception = isinstance(exc, RetryableRequestException)
|
|
150
|
+
|
|
139
151
|
is_connection_error = isinstance(
|
|
140
152
|
exc,
|
|
141
153
|
(
|
|
@@ -168,7 +180,7 @@ def process_requests_exception(
|
|
|
168
180
|
except (AttributeError, ValueError):
|
|
169
181
|
pass
|
|
170
182
|
|
|
171
|
-
if is_connection_error
|
|
183
|
+
if any([is_connection_error, is_server_retryable_error, is_retryable_exception]):
|
|
172
184
|
process_retryable_request(
|
|
173
185
|
external_logger,
|
|
174
186
|
exc,
|
|
@@ -22,7 +22,7 @@ supervisely/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
22
22
|
supervisely/api/advanced_api.py,sha256=Nd5cCnHFWc3PSUrCtENxTGtDjS37_lCHXsgXvUI3Ti8,2054
|
|
23
23
|
supervisely/api/agent_api.py,sha256=ShWAIlXcWXcyI9fqVuP5GZVCigCMJmjnvdGUfLspD6Y,8890
|
|
24
24
|
supervisely/api/annotation_api.py,sha256=kB9l0NhQEkunGDC9fWjNzf5DdhqRF1tv-RRnIbkV2k0,64941
|
|
25
|
-
supervisely/api/api.py,sha256=
|
|
25
|
+
supervisely/api/api.py,sha256=dPoEMolFr7PTSUIb2g_0DhhVFObnbUfylTyGeaQ1vnI,65747
|
|
26
26
|
supervisely/api/app_api.py,sha256=-T4sISQ7POyR2yirf1kEWj4JaJFpJxCyRWqbf_99Jak,67036
|
|
27
27
|
supervisely/api/dataset_api.py,sha256=eovT6l62jgjlRyCZ6IvoudUBfDxv9Hjj3Ap8IuCLd7I,41290
|
|
28
28
|
supervisely/api/file_api.py,sha256=7yWt8lRQ4UfLmnMZ9T18UXzu8jihrtHtcqi6GZJG-0w,83414
|
|
@@ -693,7 +693,7 @@ supervisely/io/fs_cache.py,sha256=985gvBGzveLcDudgz10E4EWVjP9jxdU1Pa0GFfCBoCA,65
|
|
|
693
693
|
supervisely/io/github_utils.py,sha256=jGmvQJ5bjtACuSFABzrxL0jJdh14SezovrHp8T-9y8g,1779
|
|
694
694
|
supervisely/io/json.py,sha256=VvyqXZl22nb6_DJK3TUOPetd5xq9xwRFKumWqsGs7iI,8679
|
|
695
695
|
supervisely/io/multipart_stream_decoder.py,sha256=rCheeSCAGdw2tNyaWEYa4dvoIDuldXOxH86RVB82c78,14417
|
|
696
|
-
supervisely/io/network_exceptions.py,sha256=
|
|
696
|
+
supervisely/io/network_exceptions.py,sha256=XnSmxLRyJmHtGyU7Wn5sZcidRjP3fU8ovRhNkVekU9Q,9153
|
|
697
697
|
supervisely/labeling_jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
698
698
|
supervisely/labeling_jobs/constants.py,sha256=GF_pwF9fC9_DGbpD3cAk3llifskAxpDmyuXwxM1f3Hw,104
|
|
699
699
|
supervisely/labeling_jobs/utils.py,sha256=XOGF2cbnTGbXFdT5jGL1LIPQfiCEJgRkmKNIjTlFois,22656
|
|
@@ -1054,9 +1054,9 @@ supervisely/worker_proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
1054
1054
|
supervisely/worker_proto/worker_api_pb2.py,sha256=VQfi5JRBHs2pFCK1snec3JECgGnua3Xjqw_-b3aFxuM,59142
|
|
1055
1055
|
supervisely/worker_proto/worker_api_pb2_grpc.py,sha256=3BwQXOaP9qpdi0Dt9EKG--Lm8KGN0C5AgmUfRv77_Jk,28940
|
|
1056
1056
|
supervisely_lib/__init__.py,sha256=7-3QnN8Zf0wj8NCr2oJmqoQWMKKPKTECvjH9pd2S5vY,159
|
|
1057
|
-
supervisely-6.73.
|
|
1058
|
-
supervisely-6.73.
|
|
1059
|
-
supervisely-6.73.
|
|
1060
|
-
supervisely-6.73.
|
|
1061
|
-
supervisely-6.73.
|
|
1062
|
-
supervisely-6.73.
|
|
1057
|
+
supervisely-6.73.256.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
1058
|
+
supervisely-6.73.256.dist-info/METADATA,sha256=72afsXjOqMyFiNEiucSqL5BYeopIsrEg5AZClsQec8k,33573
|
|
1059
|
+
supervisely-6.73.256.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
1060
|
+
supervisely-6.73.256.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
|
|
1061
|
+
supervisely-6.73.256.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
|
|
1062
|
+
supervisely-6.73.256.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|