contree-sdk 0.4.0.dev3__py3-none-any.whl → 0.4.0.dev4__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.
- contree_sdk/_internals/io/operation_waiter.py +17 -2
- contree_sdk/sdk/client/_base.py +1 -19
- {contree_sdk-0.4.0.dev3.dist-info → contree_sdk-0.4.0.dev4.dist-info}/METADATA +3 -3
- {contree_sdk-0.4.0.dev3.dist-info → contree_sdk-0.4.0.dev4.dist-info}/RECORD +6 -6
- {contree_sdk-0.4.0.dev3.dist-info → contree_sdk-0.4.0.dev4.dist-info}/WHEEL +1 -1
- {contree_sdk-0.4.0.dev3.dist-info → contree_sdk-0.4.0.dev4.dist-info}/licenses/LICENSE +0 -0
|
@@ -6,6 +6,7 @@ from asyncio import Event, Lock, Queue, create_task, gather, shield
|
|
|
6
6
|
from collections import defaultdict
|
|
7
7
|
from contextlib import asynccontextmanager, suppress
|
|
8
8
|
from dataclasses import dataclass
|
|
9
|
+
from datetime import timedelta
|
|
9
10
|
from sys import version_info
|
|
10
11
|
from types import EllipsisType
|
|
11
12
|
from typing import TYPE_CHECKING, Literal, TypeVar, overload
|
|
@@ -21,6 +22,7 @@ from contree_client.models import (
|
|
|
21
22
|
|
|
22
23
|
from contree_sdk._internals.io.typing import AsyncWritable, Writable
|
|
23
24
|
from contree_sdk._internals.io.writer_wrapper import EOF, WriterToQueue, WriterWrapper
|
|
25
|
+
from contree_sdk._internals.utils.circuit_retrier import CircuitRetrier
|
|
24
26
|
from contree_sdk.sdk.exceptions import (
|
|
25
27
|
CancelledOperationError,
|
|
26
28
|
ContreeApiError,
|
|
@@ -31,6 +33,7 @@ from contree_sdk.sdk.exceptions import (
|
|
|
31
33
|
NotFoundError,
|
|
32
34
|
OperationTimedOutError,
|
|
33
35
|
)
|
|
36
|
+
from contree_sdk.sdk.exceptions.api import ApiTimeoutError, ContreeTransportError, TooEarlyError, TooManyRequestsError
|
|
34
37
|
from contree_sdk.utils.models.operation import OperationEventType, OperationStatus
|
|
35
38
|
|
|
36
39
|
|
|
@@ -84,6 +87,19 @@ class OperationWaiter:
|
|
|
84
87
|
self.operation_id = operation_id
|
|
85
88
|
self._client = client
|
|
86
89
|
self._output_limit = client.config.default_truncate_output_at
|
|
90
|
+
import_timeout = client.config.operation_import_timeout or client.config.operation_timeout
|
|
91
|
+
spawn_timeout = client.config.operation_run_timeout or client.config.operation_timeout
|
|
92
|
+
self._stream_retrier = CircuitRetrier(
|
|
93
|
+
exceptions=[
|
|
94
|
+
TooManyRequestsError,
|
|
95
|
+
ApiTimeoutError,
|
|
96
|
+
ContreeTransportError,
|
|
97
|
+
NotFoundError,
|
|
98
|
+
TooEarlyError,
|
|
99
|
+
EventStreamInterruptedError,
|
|
100
|
+
],
|
|
101
|
+
retry_timeout=timedelta(seconds=max(spawn_timeout, import_timeout)),
|
|
102
|
+
)
|
|
87
103
|
self._output_by_spid = defaultdict(lambda: defaultdict(bytearray))
|
|
88
104
|
self._local_output_dropped: dict[int | None, dict[StreamName, int]] = defaultdict(lambda: defaultdict(int))
|
|
89
105
|
# IO objects by spid and stream name
|
|
@@ -231,10 +247,9 @@ class OperationWaiter:
|
|
|
231
247
|
async def wait_for_result(
|
|
232
248
|
self, *, operation_timeout: float | None = None, spid: int | None = MAIN_SPID
|
|
233
249
|
) -> tuple[EventDataCompletion, EventDataExit | None]:
|
|
234
|
-
retrier = self._client._default_retrier
|
|
235
250
|
try:
|
|
236
251
|
async with self._operation_canceller(), timeout(operation_timeout):
|
|
237
|
-
await
|
|
252
|
+
await self._stream_retrier(self._load_events)
|
|
238
253
|
except (TimeoutError, asyncio.TimeoutError) as e:
|
|
239
254
|
raise OperationTimedOutError(operation_uuid=self.operation_id) from e
|
|
240
255
|
|
contree_sdk/sdk/client/_base.py
CHANGED
|
@@ -27,14 +27,7 @@ from contree_sdk._internals.utils.circuit_retrier import CircuitRetrier
|
|
|
27
27
|
from contree_sdk.auth import IAMAuth
|
|
28
28
|
from contree_sdk.config import ContreeConfig
|
|
29
29
|
from contree_sdk.sdk.exceptions import ContreeError, UnknownContreeError
|
|
30
|
-
from contree_sdk.sdk.exceptions.api import
|
|
31
|
-
ApiTimeoutError,
|
|
32
|
-
ContreeTransportError,
|
|
33
|
-
EventStreamInterruptedError,
|
|
34
|
-
NotFoundError,
|
|
35
|
-
TooEarlyError,
|
|
36
|
-
TooManyRequestsError,
|
|
37
|
-
)
|
|
30
|
+
from contree_sdk.sdk.exceptions.api import ApiTimeoutError, TooManyRequestsError
|
|
38
31
|
from contree_sdk.sdk.objects.image._base import _ContreeImageBase
|
|
39
32
|
from contree_sdk.utils.models.auth import WhoAmI
|
|
40
33
|
|
|
@@ -90,14 +83,6 @@ class _ContreeBase:
|
|
|
90
83
|
self._config = config
|
|
91
84
|
self._token_info: WhoAmI | None = None
|
|
92
85
|
start_exceptions = [TooManyRequestsError, ApiTimeoutError]
|
|
93
|
-
stream_exceptions = [
|
|
94
|
-
TooManyRequestsError,
|
|
95
|
-
ApiTimeoutError,
|
|
96
|
-
ContreeTransportError,
|
|
97
|
-
NotFoundError,
|
|
98
|
-
TooEarlyError,
|
|
99
|
-
EventStreamInterruptedError,
|
|
100
|
-
]
|
|
101
86
|
import_timeout = config.operation_import_timeout or config.operation_timeout
|
|
102
87
|
spawn_timeout = config.operation_run_timeout or config.operation_timeout
|
|
103
88
|
self._import_retrier = CircuitRetrier(
|
|
@@ -106,9 +91,6 @@ class _ContreeBase:
|
|
|
106
91
|
self._spawn_retrier = CircuitRetrier(
|
|
107
92
|
exceptions=start_exceptions, retry_timeout=timedelta(seconds=spawn_timeout)
|
|
108
93
|
)
|
|
109
|
-
self._default_retrier = CircuitRetrier(
|
|
110
|
-
exceptions=stream_exceptions, retry_timeout=timedelta(seconds=max(spawn_timeout, import_timeout))
|
|
111
|
-
)
|
|
112
94
|
self._waiters: WeakValueDictionary[UUID, OperationWaiter] = WeakValueDictionary()
|
|
113
95
|
self._waiters_lock = Lock()
|
|
114
96
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: contree-sdk
|
|
3
|
-
Version: 0.4.0.
|
|
3
|
+
Version: 0.4.0.dev4
|
|
4
4
|
Summary: SDK for ConTree container runtime with versioned filesystem state
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
License-File: LICENSE
|
|
@@ -16,7 +16,7 @@ Requires-Python: <3.15,>=3.10
|
|
|
16
16
|
Requires-Dist: aiofiles
|
|
17
17
|
Requires-Dist: async-timeout; python_version < '3.11'
|
|
18
18
|
Requires-Dist: cattrs
|
|
19
|
-
Requires-Dist: contree-client~=0.2.
|
|
19
|
+
Requires-Dist: contree-client~=0.2.1.dev0
|
|
20
20
|
Requires-Dist: strenum
|
|
21
21
|
Requires-Dist: typing-extensions; python_version < '3.13'
|
|
22
22
|
Provides-Extra: aiohttp
|
|
@@ -8,7 +8,7 @@ contree_sdk/_internals/client/provider.py,sha256=n2-fv0SjPfn1652DNn3vlsIwQDNnn-3
|
|
|
8
8
|
contree_sdk/_internals/client/transport.py,sha256=6Vu8wW8KL4MQNAouLFDbQVLGXOs2apAYz6PBWbK0MuE,4823
|
|
9
9
|
contree_sdk/_internals/io/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
10
|
contree_sdk/_internals/io/codecs.py,sha256=qwJaP1mPo-o-7OBMkcbND1eVT4aB0c1C_YcaG9xQJjs,782
|
|
11
|
-
contree_sdk/_internals/io/operation_waiter.py,sha256=
|
|
11
|
+
contree_sdk/_internals/io/operation_waiter.py,sha256=Sfn10qi8e-Qvc4D7-UJuRk9hQjTyP0Kizw5M7By5ydA,11478
|
|
12
12
|
contree_sdk/_internals/io/typing.py,sha256=rRQ8AKWXu-aOW9syYN8XQZEofqaM4NzbOyuwzOL5Si4,1739
|
|
13
13
|
contree_sdk/_internals/io/wiring.py,sha256=wyWquuoZgUdE85VCJBBKo6lqTikSEU6IH0IzwBonTyQ,3433
|
|
14
14
|
contree_sdk/_internals/io/writer_wrapper.py,sha256=ELLPkvA74sDYJKyU6y3qjGnRmJiDx-RXv6Otp9L7mYk,2490
|
|
@@ -28,7 +28,7 @@ contree_sdk/langchain/sandbox.py,sha256=dy4MgMMVzDvsfR353hB7eOHUTBeS6bxUnl2CStL3
|
|
|
28
28
|
contree_sdk/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
29
|
contree_sdk/sdk/client/__init__.py,sha256=4_tscZTYTtQ2wd8bEaGqJEDBY0kZ30Z6axS5IRiAkog,98
|
|
30
30
|
contree_sdk/sdk/client/_async.py,sha256=urdvKAjLFQwRHjsaJ57V1ZHR_IQjY1xRHUuNMaIlCaQ,1298
|
|
31
|
-
contree_sdk/sdk/client/_base.py,sha256=
|
|
31
|
+
contree_sdk/sdk/client/_base.py,sha256=WUyQ47EvFNJkznznoX8IfvYR1uZKI6eWojz0yO_mU6E,8167
|
|
32
32
|
contree_sdk/sdk/client/_sync.py,sha256=_YAv7pgZlGubt-GRTk3cVv_fgGhWsruL53ecpOiaj4c,1385
|
|
33
33
|
contree_sdk/sdk/exceptions/__init__.py,sha256=s6HQmYd8gOESEHpfSXQGg88-LR6gKCqWtfV0O43XvDw,1373
|
|
34
34
|
contree_sdk/sdk/exceptions/api.py,sha256=g2nKi1uA2iVNj6PbTtkN59ecLcfGQX99VyLVq8ov9tQ,1579
|
|
@@ -81,7 +81,7 @@ contree_sdk/utils/models/file.py,sha256=9izWiiCiH1t2AU6GgY0pHaIztHDVdjVoUZQP3NOL
|
|
|
81
81
|
contree_sdk/utils/models/image.py,sha256=bhFHRO8FTKKtCwU2efxNuST7rAnr5sMeP3jAS_BQcgc,88
|
|
82
82
|
contree_sdk/utils/models/operation.py,sha256=0hQi-IGbAP6_Ao32YBJHJ9KwXK2unHWpRLjmlacu0ow,523
|
|
83
83
|
contree_sdk/utils/models/stream.py,sha256=Ckorhu_-5dVQPfaaFpr7HVjoN00a_c9d7fqTisOyz3c,315
|
|
84
|
-
contree_sdk-0.4.0.
|
|
85
|
-
contree_sdk-0.4.0.
|
|
86
|
-
contree_sdk-0.4.0.
|
|
87
|
-
contree_sdk-0.4.0.
|
|
84
|
+
contree_sdk-0.4.0.dev4.dist-info/METADATA,sha256=x7RDv3AzvBKbF4Ca1SKXSjU0Wac896yn6b7Qlj6xBTo,17491
|
|
85
|
+
contree_sdk-0.4.0.dev4.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
86
|
+
contree_sdk-0.4.0.dev4.dist-info/licenses/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
|
|
87
|
+
contree_sdk-0.4.0.dev4.dist-info/RECORD,,
|
|
File without changes
|