blaxel 0.2.1rc74__py3-none-any.whl → 0.2.1rc75__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/process.py +23 -40
- {blaxel-0.2.1rc74.dist-info → blaxel-0.2.1rc75.dist-info}/METADATA +1 -1
- {blaxel-0.2.1rc74.dist-info → blaxel-0.2.1rc75.dist-info}/RECORD +5 -5
- {blaxel-0.2.1rc74.dist-info → blaxel-0.2.1rc75.dist-info}/WHEEL +0 -0
- {blaxel-0.2.1rc74.dist-info → blaxel-0.2.1rc75.dist-info}/licenses/LICENSE +0 -0
blaxel/core/sandbox/process.py
CHANGED
@@ -10,21 +10,6 @@ from .client.models.process_request import ProcessRequest
|
|
10
10
|
from .types import SandboxConfiguration
|
11
11
|
|
12
12
|
|
13
|
-
class ProcessResponseWithLogs(ProcessResponse):
|
14
|
-
"""Extended ProcessResponse that adds a logs property."""
|
15
|
-
|
16
|
-
logs: Optional[str] = None
|
17
|
-
|
18
|
-
@classmethod
|
19
|
-
def from_process_response(cls, process_response: ProcessResponse, logs: Optional[str] = None):
|
20
|
-
"""Create ProcessResponseWithLogs from an existing ProcessResponse."""
|
21
|
-
# Create a new instance from the dict representation
|
22
|
-
instance = cls.from_dict(process_response.to_dict())
|
23
|
-
# Add the logs
|
24
|
-
instance.logs = logs
|
25
|
-
return instance
|
26
|
-
|
27
|
-
|
28
13
|
class SandboxProcess(SandboxAction):
|
29
14
|
def __init__(self, sandbox_config: SandboxConfiguration):
|
30
15
|
super().__init__(sandbox_config)
|
@@ -94,13 +79,19 @@ class SandboxProcess(SandboxAction):
|
|
94
79
|
self,
|
95
80
|
process: Union[ProcessRequest, Dict[str, Any]],
|
96
81
|
on_log: Optional[Callable[[str], None]] = None,
|
97
|
-
) ->
|
82
|
+
) -> ProcessResponse:
|
98
83
|
if isinstance(process, dict):
|
99
84
|
process = ProcessRequest.from_dict(process)
|
100
85
|
|
86
|
+
# Store original wait_for_completion setting
|
87
|
+
should_wait_for_completion = process.wait_for_completion
|
88
|
+
|
89
|
+
# Always start process without wait_for_completion to avoid server-side blocking
|
90
|
+
if should_wait_for_completion and on_log is not None:
|
91
|
+
process.wait_for_completion = False
|
92
|
+
|
101
93
|
async with self.get_client() as client_instance:
|
102
94
|
response = await client_instance.post("/process", json=process.to_dict())
|
103
|
-
|
104
95
|
# Parse JSON response only once, with better error handling
|
105
96
|
response_data = None
|
106
97
|
if response.content:
|
@@ -114,32 +105,24 @@ class SandboxProcess(SandboxAction):
|
|
114
105
|
self.handle_response_error(response, response_data, None)
|
115
106
|
result = ProcessResponse.from_dict(response_data)
|
116
107
|
|
117
|
-
#
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
# Wait for completion if requested
|
123
|
-
logs = None
|
124
|
-
if process.wait_for_completion:
|
108
|
+
# Handle wait_for_completion with parallel log streaming
|
109
|
+
if should_wait_for_completion:
|
110
|
+
stream_control = None
|
111
|
+
if on_log is not None:
|
112
|
+
stream_control = self.stream_logs(result.pid, {"on_log": on_log})
|
125
113
|
try:
|
126
|
-
# Wait for process
|
127
|
-
result = await self.wait(result.pid)
|
128
|
-
|
129
|
-
#
|
130
|
-
logs = await self.logs(result.pid, "all")
|
131
|
-
except Exception as e:
|
132
|
-
# If waiting fails, still try to return what we have
|
114
|
+
# Wait for process completion
|
115
|
+
result = await self.wait(result.pid, interval=50)
|
116
|
+
finally:
|
117
|
+
# Clean up log streaming
|
133
118
|
if stream_control:
|
134
119
|
stream_control["close"]()
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
# Return wrapped response with logs
|
142
|
-
return ProcessResponseWithLogs.from_process_response(result, logs)
|
120
|
+
else:
|
121
|
+
# For non-blocking execution, set up log streaming immediately if requested
|
122
|
+
if on_log is not None:
|
123
|
+
stream = self.stream_logs(result.pid, {"on_log": on_log})
|
124
|
+
result.additional_properties["close"] = stream["close"]
|
125
|
+
return result
|
143
126
|
|
144
127
|
async def wait(
|
145
128
|
self, identifier: str, max_wait: int = 60000, interval: int = 1000
|
@@ -309,7 +309,7 @@ blaxel/core/sandbox/action.py,sha256=9Zjkco7YkLzBThD3N2Hr5SpeEiqU_-Ktk8HlKpkpiAg
|
|
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=M6FulOxPghUBpb5fLxu1Rd3ekLeCbZ_dgt4s1X2Cneo,5354
|
312
|
-
blaxel/core/sandbox/process.py,sha256=
|
312
|
+
blaxel/core/sandbox/process.py,sha256=7zEngDTs2XiNsMm9TZ4lEDUiRpS3af8dw60pEvRuHDY,8357
|
313
313
|
blaxel/core/sandbox/sandbox.py,sha256=tsRGvkb2dnGM5pmOiIxWvOmT42P9BDXWtW3h6_CIffI,5802
|
314
314
|
blaxel/core/sandbox/session.py,sha256=4SH1tyXcQ9UqJx4lMwxAlp7x9Te_anDrdSEG6AlNkvU,4496
|
315
315
|
blaxel/core/sandbox/types.py,sha256=gmNAt8x7PrJZHpw2_2aWWDE5uG6H-uEgdIKTYIw4G0g,2981
|
@@ -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.1rc75.dist-info/METADATA,sha256=y5tYQNgSQuYwy1K_GYhy_h_oxz5iKupOB3-U_zVRN9I,9879
|
406
|
+
blaxel-0.2.1rc75.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
407
|
+
blaxel-0.2.1rc75.dist-info/licenses/LICENSE,sha256=p5PNQvpvyDT_0aYBDgmV1fFI_vAD2aSV0wWG7VTgRis,1069
|
408
|
+
blaxel-0.2.1rc75.dist-info/RECORD,,
|
File without changes
|
File without changes
|