scalebox-sdk 0.1.4__py3-none-any.whl → 0.1.25__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.
- scalebox/__init__.py +1 -1
- scalebox/api/__init__.py +128 -128
- scalebox/api/client/__init__.py +8 -8
- scalebox/api/client/api/sandboxes/get_sandboxes.py +5 -3
- scalebox/api/client/api/sandboxes/get_sandboxes_sandbox_id_metrics.py +2 -2
- scalebox/api/client/api/sandboxes/post_sandboxes.py +2 -2
- scalebox/api/client/client.py +288 -288
- scalebox/api/client/models/listed_sandbox.py +11 -9
- scalebox/api/client/models/new_sandbox.py +1 -1
- scalebox/api/client/models/sandbox.py +125 -125
- scalebox/api/client/models/sandbox_state.py +1 -0
- scalebox/api/client/types.py +46 -46
- scalebox/code_interpreter/code_interpreter_async.py +370 -369
- scalebox/code_interpreter/code_interpreter_sync.py +318 -317
- scalebox/connection_config.py +92 -92
- scalebox/csx_desktop/main.py +12 -12
- scalebox/generated/api_pb2_connect.py +17 -66
- scalebox/sandbox_async/commands/command.py +307 -307
- scalebox/sandbox_async/commands/command_handle.py +187 -187
- scalebox/sandbox_async/commands/pty.py +187 -187
- scalebox/sandbox_async/filesystem/filesystem.py +557 -557
- scalebox/sandbox_async/filesystem/watch_handle.py +61 -61
- scalebox/sandbox_async/main.py +647 -646
- scalebox/sandbox_async/sandbox_api.py +365 -365
- scalebox/sandbox_async/utils.py +7 -7
- scalebox/sandbox_sync/__init__.py +2 -2
- scalebox/sandbox_sync/commands/command.py +300 -300
- scalebox/sandbox_sync/commands/command_handle.py +150 -150
- scalebox/sandbox_sync/commands/pty.py +181 -181
- scalebox/sandbox_sync/filesystem/filesystem.py +543 -543
- scalebox/sandbox_sync/filesystem/watch_handle.py +66 -66
- scalebox/sandbox_sync/main.py +789 -790
- scalebox/sandbox_sync/sandbox_api.py +356 -356
- scalebox/test/CODE_INTERPRETER_TESTS_READY.md +256 -256
- scalebox/test/README.md +164 -164
- scalebox/test/aclient.py +72 -72
- scalebox/test/code_interpreter_centext.py +21 -21
- scalebox/test/code_interpreter_centext_sync.py +21 -21
- scalebox/test/code_interpreter_test.py +1 -1
- scalebox/test/code_interpreter_test_sync.py +1 -1
- scalebox/test/run_all_validation_tests.py +334 -334
- scalebox/test/test_basic.py +78 -78
- scalebox/test/test_code_interpreter_async_comprehensive.py +2653 -2653
- scalebox/test/{test_code_interpreter_e2bsync_comprehensive.py → test_code_interpreter_execcode.py} +328 -392
- scalebox/test/test_code_interpreter_sync_comprehensive.py +3416 -3412
- scalebox/test/test_csx_desktop_examples.py +130 -0
- scalebox/test/test_sandbox_async_comprehensive.py +736 -738
- scalebox/test/test_sandbox_stress_and_edge_cases.py +778 -778
- scalebox/test/test_sandbox_sync_comprehensive.py +779 -770
- scalebox/test/test_sandbox_usage_examples.py +987 -987
- scalebox/test/testacreate.py +24 -24
- scalebox/test/testagetinfo.py +18 -18
- scalebox/test/testcodeinterpreter_async.py +508 -508
- scalebox/test/testcodeinterpreter_sync.py +239 -239
- scalebox/test/testcomputeuse.py +2 -2
- scalebox/test/testnovnc.py +12 -12
- scalebox/test/testsandbox_api.py +15 -0
- scalebox/test/testsandbox_async.py +202 -118
- scalebox/test/testsandbox_sync.py +71 -38
- scalebox/version.py +2 -2
- {scalebox_sdk-0.1.4.dist-info → scalebox_sdk-0.1.25.dist-info}/METADATA +104 -103
- {scalebox_sdk-0.1.4.dist-info → scalebox_sdk-0.1.25.dist-info}/RECORD +66 -66
- scalebox/test/test_code_interpreter_e2basync_comprehensive.py +0 -2655
- scalebox/test/test_e2b_first.py +0 -11
- {scalebox_sdk-0.1.4.dist-info → scalebox_sdk-0.1.25.dist-info}/WHEEL +0 -0
- {scalebox_sdk-0.1.4.dist-info → scalebox_sdk-0.1.25.dist-info}/entry_points.txt +0 -0
- {scalebox_sdk-0.1.4.dist-info → scalebox_sdk-0.1.25.dist-info}/licenses/LICENSE +0 -0
- {scalebox_sdk-0.1.4.dist-info → scalebox_sdk-0.1.25.dist-info}/top_level.txt +0 -0
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
from typing import List
|
|
2
|
-
|
|
3
|
-
from ...exceptions import SandboxException
|
|
4
|
-
from ...generated import api_pb2_connect
|
|
5
|
-
from ...generated.api_pb2 import GetWatcherEventsRequest, RemoveWatcherRequest
|
|
6
|
-
from ...generated.rpc import handle_rpc_exception
|
|
7
|
-
from ...sandbox.filesystem.watch_handle import FilesystemEvent, map_event_type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class WatchHandle:
|
|
11
|
-
"""
|
|
12
|
-
Handle for watching filesystem events.
|
|
13
|
-
It is used to get the latest events that have occurred in the watched directory.
|
|
14
|
-
|
|
15
|
-
Use `.stop()` to stop watching the directory.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
def __init__(
|
|
19
|
-
self,
|
|
20
|
-
rpc: api_pb2_connect.FilesystemClient,
|
|
21
|
-
watcher_id: str,
|
|
22
|
-
):
|
|
23
|
-
self._rpc = rpc
|
|
24
|
-
self._watcher_id = watcher_id
|
|
25
|
-
self._closed = False
|
|
26
|
-
|
|
27
|
-
def stop(self):
|
|
28
|
-
"""
|
|
29
|
-
Stop watching the directory.
|
|
30
|
-
After you stop the watcher you won't be able to get the events anymore.
|
|
31
|
-
"""
|
|
32
|
-
try:
|
|
33
|
-
self._rpc.remove_watcher(RemoveWatcherRequest(watcher_id=self._watcher_id))
|
|
34
|
-
except Exception as e:
|
|
35
|
-
raise handle_rpc_exception(e)
|
|
36
|
-
|
|
37
|
-
self._closed = True
|
|
38
|
-
|
|
39
|
-
def get_new_events(self) -> List[FilesystemEvent]:
|
|
40
|
-
"""
|
|
41
|
-
Get the latest events that have occurred in the watched directory since the last call, or from the beginning of the watching, up until now.
|
|
42
|
-
|
|
43
|
-
:return: List of filesystem events
|
|
44
|
-
"""
|
|
45
|
-
if self._closed:
|
|
46
|
-
raise SandboxException("The watcher is already stopped")
|
|
47
|
-
|
|
48
|
-
try:
|
|
49
|
-
r = self._rpc.get_watcher_events(
|
|
50
|
-
GetWatcherEventsRequest(watcher_id=self._watcher_id)
|
|
51
|
-
)
|
|
52
|
-
except Exception as e:
|
|
53
|
-
raise handle_rpc_exception(e)
|
|
54
|
-
|
|
55
|
-
events = []
|
|
56
|
-
for event in r.events:
|
|
57
|
-
event_type = map_event_type(event.type)
|
|
58
|
-
if event_type:
|
|
59
|
-
events.append(
|
|
60
|
-
FilesystemEvent(
|
|
61
|
-
name=event.name,
|
|
62
|
-
type=event_type,
|
|
63
|
-
)
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
return events
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
from ...exceptions import SandboxException
|
|
4
|
+
from ...generated import api_pb2_connect
|
|
5
|
+
from ...generated.api_pb2 import GetWatcherEventsRequest, RemoveWatcherRequest
|
|
6
|
+
from ...generated.rpc import handle_rpc_exception
|
|
7
|
+
from ...sandbox.filesystem.watch_handle import FilesystemEvent, map_event_type
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class WatchHandle:
|
|
11
|
+
"""
|
|
12
|
+
Handle for watching filesystem events.
|
|
13
|
+
It is used to get the latest events that have occurred in the watched directory.
|
|
14
|
+
|
|
15
|
+
Use `.stop()` to stop watching the directory.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
rpc: api_pb2_connect.FilesystemClient,
|
|
21
|
+
watcher_id: str,
|
|
22
|
+
):
|
|
23
|
+
self._rpc = rpc
|
|
24
|
+
self._watcher_id = watcher_id
|
|
25
|
+
self._closed = False
|
|
26
|
+
|
|
27
|
+
def stop(self):
|
|
28
|
+
"""
|
|
29
|
+
Stop watching the directory.
|
|
30
|
+
After you stop the watcher you won't be able to get the events anymore.
|
|
31
|
+
"""
|
|
32
|
+
try:
|
|
33
|
+
self._rpc.remove_watcher(RemoveWatcherRequest(watcher_id=self._watcher_id))
|
|
34
|
+
except Exception as e:
|
|
35
|
+
raise handle_rpc_exception(e)
|
|
36
|
+
|
|
37
|
+
self._closed = True
|
|
38
|
+
|
|
39
|
+
def get_new_events(self) -> List[FilesystemEvent]:
|
|
40
|
+
"""
|
|
41
|
+
Get the latest events that have occurred in the watched directory since the last call, or from the beginning of the watching, up until now.
|
|
42
|
+
|
|
43
|
+
:return: List of filesystem events
|
|
44
|
+
"""
|
|
45
|
+
if self._closed:
|
|
46
|
+
raise SandboxException("The watcher is already stopped")
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
r = self._rpc.get_watcher_events(
|
|
50
|
+
GetWatcherEventsRequest(watcher_id=self._watcher_id)
|
|
51
|
+
)
|
|
52
|
+
except Exception as e:
|
|
53
|
+
raise handle_rpc_exception(e)
|
|
54
|
+
|
|
55
|
+
events = []
|
|
56
|
+
for event in r.events:
|
|
57
|
+
event_type = map_event_type(event.type)
|
|
58
|
+
if event_type:
|
|
59
|
+
events.append(
|
|
60
|
+
FilesystemEvent(
|
|
61
|
+
name=event.name,
|
|
62
|
+
type=event_type,
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
return events
|