blaxel 0.2.7rc84__py3-none-any.whl → 0.2.7rc85__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.
- blaxel/core/sandbox/__init__.py +2 -0
- blaxel/core/sandbox/process.py +14 -22
- blaxel/core/sandbox/types.py +24 -0
- {blaxel-0.2.7rc84.dist-info → blaxel-0.2.7rc85.dist-info}/METADATA +1 -1
- {blaxel-0.2.7rc84.dist-info → blaxel-0.2.7rc85.dist-info}/RECORD +7 -7
- {blaxel-0.2.7rc84.dist-info → blaxel-0.2.7rc85.dist-info}/WHEEL +0 -0
- {blaxel-0.2.7rc84.dist-info → blaxel-0.2.7rc85.dist-info}/licenses/LICENSE +0 -0
blaxel/core/sandbox/__init__.py
CHANGED
@@ -8,6 +8,7 @@ from .sandbox import (
|
|
8
8
|
from .types import (
|
9
9
|
CopyResponse,
|
10
10
|
ProcessRequestWithLog,
|
11
|
+
ProcessResponseWithLog,
|
11
12
|
SandboxConfiguration,
|
12
13
|
SandboxCreateConfiguration,
|
13
14
|
SandboxFilesystemFile,
|
@@ -30,4 +31,5 @@ __all__ = [
|
|
30
31
|
"SandboxPreviews",
|
31
32
|
"SandboxProcess",
|
32
33
|
"ProcessRequestWithLog",
|
34
|
+
"ProcessResponseWithLog",
|
33
35
|
]
|
blaxel/core/sandbox/process.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import asyncio
|
2
|
-
from typing import
|
2
|
+
from typing import Callable, Dict, Literal, Optional, Union
|
3
3
|
|
4
4
|
import httpx
|
5
5
|
|
@@ -7,7 +7,7 @@ from ..common.settings import settings
|
|
7
7
|
from .action import SandboxAction
|
8
8
|
from .client.models import ProcessResponse, SuccessResponse
|
9
9
|
from .client.models.process_request import ProcessRequest
|
10
|
-
from .types import ProcessRequestWithLog, SandboxConfiguration
|
10
|
+
from .types import ProcessRequestWithLog, ProcessResponseWithLog, SandboxConfiguration
|
11
11
|
|
12
12
|
|
13
13
|
class SandboxProcess(SandboxAction):
|
@@ -76,25 +76,14 @@ class SandboxProcess(SandboxAction):
|
|
76
76
|
return {"close": close}
|
77
77
|
|
78
78
|
async def exec(
|
79
|
-
self, process: Union[ProcessRequest, ProcessRequestWithLog
|
80
|
-
) -> ProcessResponse:
|
81
|
-
|
82
|
-
|
79
|
+
self, process: Union[ProcessRequest, ProcessRequestWithLog]
|
80
|
+
) -> Union[ProcessResponse, ProcessResponseWithLog]:
|
81
|
+
"""Execute a process in the sandbox."""
|
82
|
+
on_log: Optional[Callable[[str], None]] = None
|
83
|
+
if isinstance(process, ProcessRequestWithLog) and process.on_log:
|
83
84
|
on_log = process.on_log
|
84
|
-
process = process.to_dict()
|
85
|
-
|
86
|
-
if isinstance(process, dict):
|
87
|
-
if "on_log" in process:
|
88
|
-
on_log = process["on_log"]
|
89
|
-
del process["on_log"]
|
90
|
-
process = ProcessRequest.from_dict(process)
|
91
|
-
|
92
|
-
# Store original wait_for_completion setting
|
93
|
-
should_wait_for_completion = process.wait_for_completion
|
94
85
|
|
95
|
-
|
96
|
-
if should_wait_for_completion and on_log is not None:
|
97
|
-
process.wait_for_completion = False
|
86
|
+
should_wait_for_completion = getattr(process, "wait_for_completion", True)
|
98
87
|
|
99
88
|
async with self.get_client() as client_instance:
|
100
89
|
response = await client_instance.post("/process", json=process.to_dict())
|
@@ -118,7 +107,7 @@ class SandboxProcess(SandboxAction):
|
|
118
107
|
stream_control = self.stream_logs(result.pid, {"on_log": on_log})
|
119
108
|
try:
|
120
109
|
# Wait for process completion
|
121
|
-
result = await self.wait(result.pid, interval=
|
110
|
+
result = await self.wait(result.pid, interval=500, max_wait=1000 * 60 * 60)
|
122
111
|
finally:
|
123
112
|
# Clean up log streaming
|
124
113
|
if stream_control:
|
@@ -126,8 +115,11 @@ class SandboxProcess(SandboxAction):
|
|
126
115
|
else:
|
127
116
|
# For non-blocking execution, set up log streaming immediately if requested
|
128
117
|
if on_log is not None:
|
129
|
-
|
130
|
-
|
118
|
+
stream_control = self.stream_logs(result.pid, {"on_log": on_log})
|
119
|
+
return ProcessResponseWithLog(
|
120
|
+
result, lambda: stream_control["close"]() if stream_control else None
|
121
|
+
)
|
122
|
+
|
131
123
|
return result
|
132
124
|
|
133
125
|
async def wait(
|
blaxel/core/sandbox/types.py
CHANGED
@@ -6,6 +6,7 @@ from attrs import define as _attrs_define
|
|
6
6
|
from ..client.models import Port, Sandbox
|
7
7
|
from ..client.types import UNSET
|
8
8
|
from .client.models.process_request import ProcessRequest
|
9
|
+
from .client.models.process_response import ProcessResponse
|
9
10
|
|
10
11
|
|
11
12
|
class SessionCreateOptions:
|
@@ -182,3 +183,26 @@ class SandboxCreateConfiguration:
|
|
182
183
|
@_attrs_define
|
183
184
|
class ProcessRequestWithLog(ProcessRequest):
|
184
185
|
on_log: Callable[[str], None] = None
|
186
|
+
|
187
|
+
|
188
|
+
class ProcessResponseWithLog:
|
189
|
+
"""A process response with additional close functionality for stream management."""
|
190
|
+
|
191
|
+
def __init__(self, process_response: ProcessResponse, close_func: Callable[[], None]):
|
192
|
+
self._process_response = process_response
|
193
|
+
self._close_func = close_func
|
194
|
+
|
195
|
+
def close(self) -> None:
|
196
|
+
"""Close the log stream without terminating the process."""
|
197
|
+
self._close_func()
|
198
|
+
|
199
|
+
def __getattr__(self, name: str) -> Any:
|
200
|
+
"""Delegate attribute access to the underlying ProcessResponse."""
|
201
|
+
return getattr(self._process_response, name)
|
202
|
+
|
203
|
+
def __setattr__(self, name: str, value: Any) -> None:
|
204
|
+
"""Handle setting attributes, preserving special attributes."""
|
205
|
+
if name.startswith("_") or name == "close":
|
206
|
+
super().__setattr__(name, value)
|
207
|
+
else:
|
208
|
+
setattr(self._process_response, name, value)
|
@@ -304,15 +304,15 @@ blaxel/core/mcp/__init__.py,sha256=5VjkiQFb1QWW5QKRgwPHARlxZJ9Xqaz0diJTpM8LLF0,1
|
|
304
304
|
blaxel/core/mcp/client.py,sha256=aK3wSnsO8DmT1BZqw4eiCMF71Jwvni6Qga0DhPP806Y,5437
|
305
305
|
blaxel/core/mcp/server.py,sha256=tXySGZKgK3IllYOzYOecp58BixKBkmAIvQp_4nSM_Ww,5919
|
306
306
|
blaxel/core/models/__init__.py,sha256=HbRDsMnUFHkPC-MMkzPXh4mUqkVjqO6p3j7m00N_XSo,1722
|
307
|
-
blaxel/core/sandbox/__init__.py,sha256=
|
307
|
+
blaxel/core/sandbox/__init__.py,sha256=sDsT9d6_bQvB-7dR6ZxODYrkzqQdQznhtXTfdqcSRLI,731
|
308
308
|
blaxel/core/sandbox/action.py,sha256=9Zjkco7YkLzBThD3N2Hr5SpeEiqU_-Ktk8HlKpkpiAg,2802
|
309
309
|
blaxel/core/sandbox/filesystem.py,sha256=dyIvDdlPZO0ijD6mXXX8Yl0t75VijQ6_uMz_9rJd-_4,11317
|
310
310
|
blaxel/core/sandbox/network.py,sha256=P5jLd4AAg1zgyIK4qGWvZaDZ5BzIcxRx2ffz_JLsLMI,357
|
311
311
|
blaxel/core/sandbox/preview.py,sha256=g0uVbMsIi8gRXmmyOfSyqm1qO4Cv6rsq92fs_k884dY,6120
|
312
|
-
blaxel/core/sandbox/process.py,sha256=
|
312
|
+
blaxel/core/sandbox/process.py,sha256=L4ArSZhDmcKUl3V4llaqtJq_C3QzDTwsuOcydRmEpxY,8382
|
313
313
|
blaxel/core/sandbox/sandbox.py,sha256=y6mV2-i6TsSZGQsvBBGptR514OfgvhV0hXBMEsOBcsY,8648
|
314
314
|
blaxel/core/sandbox/session.py,sha256=3PfoekfdVzLYttsmKeK3MePhuprjqv_FDyVQTQME0OE,5277
|
315
|
-
blaxel/core/sandbox/types.py,sha256=
|
315
|
+
blaxel/core/sandbox/types.py,sha256=hf3WCk8P2e87jT4cJGuz3aZCihffun8bVb2k91YfVBU,6894
|
316
316
|
blaxel/core/sandbox/client/__init__.py,sha256=N26bD5o1jsTb48oExow6Rgivd8ylaU9jaWZfZsVilP8,128
|
317
317
|
blaxel/core/sandbox/client/client.py,sha256=tcP8cJ4Q3dV9aB3yQ01dDXO-ekfsa3WGGFz4DQAEf8I,7079
|
318
318
|
blaxel/core/sandbox/client/errors.py,sha256=gO8GBmKqmSNgAg-E5oT-oOyxztvp7V_6XG7OUTT15q0,546
|
@@ -402,7 +402,7 @@ blaxel/telemetry/instrumentation/map.py,sha256=PCzZJj39yiYVYJrxLBNP-NW-tjjYyTijw
|
|
402
402
|
blaxel/telemetry/instrumentation/utils.py,sha256=KInMYZH-mu9_wvetmf0EmgrfN3Sw8IWk2Y95v2u90_U,1901
|
403
403
|
blaxel/telemetry/log/log.py,sha256=RvQByRjZMoP_dRaAZu8oK6DTegsHs-xV4W-UIqis6CA,2461
|
404
404
|
blaxel/telemetry/log/logger.py,sha256=NPAS3g82ryROjvc_DEZaTIfrcehoLEZoP-JkLxADxc0,4113
|
405
|
-
blaxel-0.2.
|
406
|
-
blaxel-0.2.
|
407
|
-
blaxel-0.2.
|
408
|
-
blaxel-0.2.
|
405
|
+
blaxel-0.2.7rc85.dist-info/METADATA,sha256=31C827_vOZ8eKeaBRuS0i7jkp23F6n8YxzZVpmc1yto,9879
|
406
|
+
blaxel-0.2.7rc85.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
407
|
+
blaxel-0.2.7rc85.dist-info/licenses/LICENSE,sha256=p5PNQvpvyDT_0aYBDgmV1fFI_vAD2aSV0wWG7VTgRis,1069
|
408
|
+
blaxel-0.2.7rc85.dist-info/RECORD,,
|
File without changes
|
File without changes
|