scalebox-sdk 0.1.25__py3-none-any.whl → 1.0.1__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 +2 -2
- scalebox/api/__init__.py +3 -1
- scalebox/api/client/api/sandboxes/post_sandboxes_sandbox_id_connect.py +193 -0
- scalebox/api/client/models/connect_sandbox.py +59 -0
- scalebox/api/client/models/error.py +2 -2
- scalebox/api/client/models/listed_sandbox.py +19 -1
- scalebox/api/client/models/new_sandbox.py +10 -0
- scalebox/api/client/models/sandbox.py +13 -0
- scalebox/api/client/models/sandbox_detail.py +24 -0
- scalebox/cli.py +125 -125
- scalebox/client/aclient.py +57 -57
- scalebox/client/client.py +102 -102
- scalebox/code_interpreter/__init__.py +12 -12
- scalebox/code_interpreter/charts.py +230 -230
- scalebox/code_interpreter/constants.py +3 -3
- scalebox/code_interpreter/exceptions.py +13 -13
- scalebox/code_interpreter/models.py +485 -485
- scalebox/connection_config.py +34 -1
- scalebox/csx_connect/__init__.py +1 -1
- scalebox/csx_connect/client.py +485 -485
- scalebox/csx_desktop/main.py +651 -651
- scalebox/exceptions.py +83 -83
- scalebox/generated/api.py +61 -61
- scalebox/generated/api_pb2.py +203 -203
- scalebox/generated/api_pb2.pyi +956 -956
- scalebox/generated/api_pb2_connect.py +1407 -1407
- scalebox/generated/rpc.py +50 -50
- scalebox/sandbox/main.py +146 -139
- scalebox/sandbox/sandbox_api.py +105 -91
- scalebox/sandbox/signature.py +40 -40
- scalebox/sandbox/utils.py +34 -34
- scalebox/sandbox_async/main.py +226 -44
- scalebox/sandbox_async/sandbox_api.py +124 -3
- scalebox/sandbox_sync/main.py +205 -130
- scalebox/sandbox_sync/sandbox_api.py +119 -3
- scalebox/test/CODE_INTERPRETER_TESTS_READY.md +323 -323
- scalebox/test/README.md +329 -329
- scalebox/test/bedrock_openai_adapter.py +67 -0
- scalebox/test/code_interpreter_test.py +34 -34
- scalebox/test/code_interpreter_test_sync.py +34 -34
- scalebox/test/run_stress_code_interpreter_sync.py +166 -0
- scalebox/test/simple_upload_example.py +123 -0
- scalebox/test/stabitiy_test.py +310 -0
- scalebox/test/test_browser_use.py +25 -0
- scalebox/test/test_browser_use_scalebox.py +61 -0
- scalebox/test/test_code_interpreter_sync_comprehensive.py +115 -65
- scalebox/test/test_connect_pause_async.py +277 -0
- scalebox/test/test_connect_pause_sync.py +267 -0
- scalebox/test/test_desktop_sandbox_sf.py +117 -0
- scalebox/test/test_download_url.py +49 -0
- scalebox/test/test_sandbox_async_comprehensive.py +1 -1
- scalebox/test/test_sandbox_object_storage_example.py +146 -0
- scalebox/test/test_sandbox_object_storage_example_async.py +156 -0
- scalebox/test/test_sf.py +137 -0
- scalebox/test/test_watch_dir_async.py +56 -0
- scalebox/test/testacreate.py +1 -1
- scalebox/test/testagetinfo.py +1 -1
- scalebox/test/testcomputeuse.py +243 -243
- scalebox/test/testsandbox_api.py +1 -3
- scalebox/test/testsandbox_sync.py +1 -1
- scalebox/test/upload_100mb_example.py +355 -0
- scalebox/utils/httpcoreclient.py +297 -297
- scalebox/utils/httpxclient.py +403 -403
- scalebox/version.py +2 -2
- {scalebox_sdk-0.1.25.dist-info → scalebox_sdk-1.0.1.dist-info}/METADATA +1 -1
- {scalebox_sdk-0.1.25.dist-info → scalebox_sdk-1.0.1.dist-info}/RECORD +70 -53
- {scalebox_sdk-0.1.25.dist-info → scalebox_sdk-1.0.1.dist-info}/WHEEL +1 -1
- {scalebox_sdk-0.1.25.dist-info → scalebox_sdk-1.0.1.dist-info}/entry_points.txt +0 -0
- {scalebox_sdk-0.1.25.dist-info → scalebox_sdk-1.0.1.dist-info}/licenses/LICENSE +0 -0
- {scalebox_sdk-0.1.25.dist-info → scalebox_sdk-1.0.1.dist-info}/top_level.txt +0 -0
scalebox/exceptions.py
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
def sandbox_timeout_exception(message: str) -> "TimeoutException":
|
|
2
|
-
return TimeoutException(
|
|
3
|
-
f"{message}: This error is likely due to sandbox timeout. You can modify the sandbox timeout by passing 'timeout' when starting the sandbox or calling '.set_timeout' on the sandbox with the desired timeout."
|
|
4
|
-
)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def request_timeout_error() -> Exception:
|
|
8
|
-
return TimeoutException(
|
|
9
|
-
"Request timed out — the 'request_timeout' option can be used to increase this timeout",
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def execution_timeout_error() -> Exception:
|
|
14
|
-
return TimeoutException(
|
|
15
|
-
"Execution timed out — the 'timeout' option can be used to increase this timeout",
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class SandboxException(Exception):
|
|
20
|
-
"""
|
|
21
|
-
Base class for all sandbox errors.
|
|
22
|
-
|
|
23
|
-
Raised when a general sandbox exception occurs.
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
pass
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class TimeoutException(SandboxException):
|
|
30
|
-
"""
|
|
31
|
-
Raised when a timeout occurs.
|
|
32
|
-
|
|
33
|
-
The `unavailable` exception type is caused by sandbox timeout.\n
|
|
34
|
-
The `canceled` exception type is caused by exceeding request timeout.\n
|
|
35
|
-
The `deadline_exceeded` exception type is caused by exceeding the timeout for process, watch, etc.\n
|
|
36
|
-
The `unknown` exception type is sometimes caused by the sandbox timeout when the request is not processed correctly.\n
|
|
37
|
-
"""
|
|
38
|
-
|
|
39
|
-
pass
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
class InvalidArgumentException(SandboxException):
|
|
43
|
-
"""
|
|
44
|
-
Raised when an invalid argument is provided.
|
|
45
|
-
"""
|
|
46
|
-
|
|
47
|
-
pass
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
class NotEnoughSpaceException(SandboxException):
|
|
51
|
-
"""
|
|
52
|
-
Raised when there is not enough disk space.
|
|
53
|
-
"""
|
|
54
|
-
|
|
55
|
-
pass
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
class NotFoundException(SandboxException):
|
|
59
|
-
"""
|
|
60
|
-
Raised when a resource is not found.
|
|
61
|
-
"""
|
|
62
|
-
|
|
63
|
-
pass
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
class AuthenticationException(SandboxException):
|
|
67
|
-
"""
|
|
68
|
-
Raised when authentication fails.
|
|
69
|
-
"""
|
|
70
|
-
|
|
71
|
-
pass
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
class TemplateException(SandboxException):
|
|
75
|
-
"""
|
|
76
|
-
Exception raised when the template uses old envd version. It isn't compatible with the new SDK.
|
|
77
|
-
"""
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
class RateLimitException(SandboxException):
|
|
81
|
-
"""
|
|
82
|
-
Raised when the API rate limit is exceeded.
|
|
83
|
-
"""
|
|
1
|
+
def sandbox_timeout_exception(message: str) -> "TimeoutException":
|
|
2
|
+
return TimeoutException(
|
|
3
|
+
f"{message}: This error is likely due to sandbox timeout. You can modify the sandbox timeout by passing 'timeout' when starting the sandbox or calling '.set_timeout' on the sandbox with the desired timeout."
|
|
4
|
+
)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def request_timeout_error() -> Exception:
|
|
8
|
+
return TimeoutException(
|
|
9
|
+
"Request timed out — the 'request_timeout' option can be used to increase this timeout",
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def execution_timeout_error() -> Exception:
|
|
14
|
+
return TimeoutException(
|
|
15
|
+
"Execution timed out — the 'timeout' option can be used to increase this timeout",
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class SandboxException(Exception):
|
|
20
|
+
"""
|
|
21
|
+
Base class for all sandbox errors.
|
|
22
|
+
|
|
23
|
+
Raised when a general sandbox exception occurs.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class TimeoutException(SandboxException):
|
|
30
|
+
"""
|
|
31
|
+
Raised when a timeout occurs.
|
|
32
|
+
|
|
33
|
+
The `unavailable` exception type is caused by sandbox timeout.\n
|
|
34
|
+
The `canceled` exception type is caused by exceeding request timeout.\n
|
|
35
|
+
The `deadline_exceeded` exception type is caused by exceeding the timeout for process, watch, etc.\n
|
|
36
|
+
The `unknown` exception type is sometimes caused by the sandbox timeout when the request is not processed correctly.\n
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class InvalidArgumentException(SandboxException):
|
|
43
|
+
"""
|
|
44
|
+
Raised when an invalid argument is provided.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class NotEnoughSpaceException(SandboxException):
|
|
51
|
+
"""
|
|
52
|
+
Raised when there is not enough disk space.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
pass
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class NotFoundException(SandboxException):
|
|
59
|
+
"""
|
|
60
|
+
Raised when a resource is not found.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
pass
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class AuthenticationException(SandboxException):
|
|
67
|
+
"""
|
|
68
|
+
Raised when authentication fails.
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
pass
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class TemplateException(SandboxException):
|
|
75
|
+
"""
|
|
76
|
+
Exception raised when the template uses old envd version. It isn't compatible with the new SDK.
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class RateLimitException(SandboxException):
|
|
81
|
+
"""
|
|
82
|
+
Raised when the API rate limit is exceeded.
|
|
83
|
+
"""
|
scalebox/generated/api.py
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import json
|
|
2
|
-
|
|
3
|
-
import httpx
|
|
4
|
-
|
|
5
|
-
from ..exceptions import (
|
|
6
|
-
AuthenticationException,
|
|
7
|
-
InvalidArgumentException,
|
|
8
|
-
NotEnoughSpaceException,
|
|
9
|
-
NotFoundException,
|
|
10
|
-
SandboxException,
|
|
11
|
-
sandbox_timeout_exception,
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
ENVD_API_UPLOAD_FILES_ROUTE = "/upload"
|
|
15
|
-
ENVD_API_DOWNLOAD_FILES_ROUTE = "/download"
|
|
16
|
-
ENVD_API_FILES_ROUTE = "/files"
|
|
17
|
-
ENVD_API_HEALTH_ROUTE = "/health"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def get_message(e: httpx.Response) -> str:
|
|
21
|
-
try:
|
|
22
|
-
message = e.json().get("message", e.text)
|
|
23
|
-
except json.JSONDecodeError:
|
|
24
|
-
message = e.text
|
|
25
|
-
|
|
26
|
-
return message
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def handle_envd_api_exception(res: httpx.Response):
|
|
30
|
-
if res.is_success:
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
res.read()
|
|
34
|
-
|
|
35
|
-
return format_envd_api_exception(res.status_code, get_message(res))
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
async def ahandle_envd_api_exception(res: httpx.Response):
|
|
39
|
-
if res.is_success:
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
await res.aread()
|
|
43
|
-
|
|
44
|
-
return format_envd_api_exception(res.status_code, get_message(res))
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def format_envd_api_exception(status_code: int, message: str):
|
|
48
|
-
if status_code == 400:
|
|
49
|
-
return InvalidArgumentException(message)
|
|
50
|
-
elif status_code == 401:
|
|
51
|
-
return AuthenticationException(message)
|
|
52
|
-
elif status_code == 404:
|
|
53
|
-
return NotFoundException(message)
|
|
54
|
-
elif status_code == 429:
|
|
55
|
-
return SandboxException(f"{message}: The requests are being rate limited.")
|
|
56
|
-
elif status_code == 502:
|
|
57
|
-
return sandbox_timeout_exception(message)
|
|
58
|
-
elif status_code == 507:
|
|
59
|
-
return NotEnoughSpaceException(message)
|
|
60
|
-
else:
|
|
61
|
-
return SandboxException(f"{status_code}: {message}")
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
import httpx
|
|
4
|
+
|
|
5
|
+
from ..exceptions import (
|
|
6
|
+
AuthenticationException,
|
|
7
|
+
InvalidArgumentException,
|
|
8
|
+
NotEnoughSpaceException,
|
|
9
|
+
NotFoundException,
|
|
10
|
+
SandboxException,
|
|
11
|
+
sandbox_timeout_exception,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
ENVD_API_UPLOAD_FILES_ROUTE = "/upload"
|
|
15
|
+
ENVD_API_DOWNLOAD_FILES_ROUTE = "/download"
|
|
16
|
+
ENVD_API_FILES_ROUTE = "/files"
|
|
17
|
+
ENVD_API_HEALTH_ROUTE = "/health"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_message(e: httpx.Response) -> str:
|
|
21
|
+
try:
|
|
22
|
+
message = e.json().get("message", e.text)
|
|
23
|
+
except json.JSONDecodeError:
|
|
24
|
+
message = e.text
|
|
25
|
+
|
|
26
|
+
return message
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def handle_envd_api_exception(res: httpx.Response):
|
|
30
|
+
if res.is_success:
|
|
31
|
+
return
|
|
32
|
+
|
|
33
|
+
res.read()
|
|
34
|
+
|
|
35
|
+
return format_envd_api_exception(res.status_code, get_message(res))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
async def ahandle_envd_api_exception(res: httpx.Response):
|
|
39
|
+
if res.is_success:
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
await res.aread()
|
|
43
|
+
|
|
44
|
+
return format_envd_api_exception(res.status_code, get_message(res))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def format_envd_api_exception(status_code: int, message: str):
|
|
48
|
+
if status_code == 400:
|
|
49
|
+
return InvalidArgumentException(message)
|
|
50
|
+
elif status_code == 401:
|
|
51
|
+
return AuthenticationException(message)
|
|
52
|
+
elif status_code == 404:
|
|
53
|
+
return NotFoundException(message)
|
|
54
|
+
elif status_code == 429:
|
|
55
|
+
return SandboxException(f"{message}: The requests are being rate limited.")
|
|
56
|
+
elif status_code == 502:
|
|
57
|
+
return sandbox_timeout_exception(message)
|
|
58
|
+
elif status_code == 507:
|
|
59
|
+
return NotEnoughSpaceException(message)
|
|
60
|
+
else:
|
|
61
|
+
return SandboxException(f"{status_code}: {message}")
|