scalebox-sdk 0.1.24__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 +130 -128
- scalebox/api/client/__init__.py +8 -8
- 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/api/sandboxes/post_sandboxes_sandbox_id_connect.py +193 -0
- scalebox/api/client/client.py +288 -288
- 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 +138 -125
- scalebox/api/client/models/sandbox_detail.py +24 -0
- scalebox/api/client/types.py +46 -46
- 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/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 +228 -46
- scalebox/sandbox_async/sandbox_api.py +124 -3
- 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 +3 -3
- scalebox/sandbox_sync/filesystem/watch_handle.py +66 -66
- scalebox/sandbox_sync/main.py +208 -133
- 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 +13 -0
- 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.24.dist-info → scalebox_sdk-1.0.1.dist-info}/METADATA +1 -1
- {scalebox_sdk-0.1.24.dist-info → scalebox_sdk-1.0.1.dist-info}/RECORD +87 -69
- {scalebox_sdk-0.1.24.dist-info → scalebox_sdk-1.0.1.dist-info}/WHEEL +1 -1
- {scalebox_sdk-0.1.24.dist-info → scalebox_sdk-1.0.1.dist-info}/entry_points.txt +0 -0
- {scalebox_sdk-0.1.24.dist-info → scalebox_sdk-1.0.1.dist-info}/licenses/LICENSE +0 -0
- {scalebox_sdk-0.1.24.dist-info → scalebox_sdk-1.0.1.dist-info}/top_level.txt +0 -0
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
import urllib.parse
|
|
3
|
-
from typing import Dict, List, Optional
|
|
3
|
+
from typing import Dict, List, Optional, TYPE_CHECKING
|
|
4
4
|
|
|
5
5
|
from packaging.version import Version
|
|
6
|
+
from typing_extensions import Unpack
|
|
6
7
|
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from . import Sandbox
|
|
10
|
+
|
|
11
|
+
from ..api.client.api.sandboxes import post_sandboxes_sandbox_id_connect, post_sandboxes_sandbox_id_pause
|
|
12
|
+
from ..api.client.models.connect_sandbox import ConnectSandbox
|
|
7
13
|
from ..api import ApiClient, SandboxCreateResponse, handle_api_exception
|
|
8
14
|
from ..api.client.api.sandboxes import (
|
|
9
15
|
delete_sandboxes_sandbox_id,
|
|
@@ -14,8 +20,8 @@ from ..api.client.api.sandboxes import (
|
|
|
14
20
|
post_sandboxes_sandbox_id_timeout,
|
|
15
21
|
)
|
|
16
22
|
from ..api.client.models import Error, NewSandbox, PostSandboxesSandboxIDTimeoutBody
|
|
17
|
-
from ..connection_config import ConnectionConfig, ProxyTypes
|
|
18
|
-
from ..exceptions import SandboxException, TemplateException
|
|
23
|
+
from ..connection_config import ConnectionConfig, ProxyTypes, ApiParams
|
|
24
|
+
from ..exceptions import SandboxException, TemplateException, NotFoundException
|
|
19
25
|
from ..sandbox.sandbox_api import (
|
|
20
26
|
ListedSandbox,
|
|
21
27
|
SandboxApiBase,
|
|
@@ -94,6 +100,9 @@ class SandboxApi(SandboxApiBase):
|
|
|
94
100
|
memory_mb=sandbox.memory_mb,
|
|
95
101
|
started_at=sandbox.started_at,
|
|
96
102
|
end_at=sandbox.end_at,
|
|
103
|
+
object_storage=sandbox.object_storage,
|
|
104
|
+
uptime=sandbox.uptime,
|
|
105
|
+
timeout=sandbox.timeout,
|
|
97
106
|
)
|
|
98
107
|
for sandbox in res.parsed
|
|
99
108
|
]
|
|
@@ -156,6 +165,9 @@ class SandboxApi(SandboxApiBase):
|
|
|
156
165
|
end_at=res.parsed.end_at,
|
|
157
166
|
envd_version=res.parsed.envd_version,
|
|
158
167
|
_envd_access_token=res.parsed.envd_access_token,
|
|
168
|
+
object_storage=res.parsed.object_storage,
|
|
169
|
+
uptime=res.parsed.uptime,
|
|
170
|
+
timeout=res.parsed.timeout,
|
|
159
171
|
)
|
|
160
172
|
|
|
161
173
|
@classmethod
|
|
@@ -252,6 +264,8 @@ class SandboxApi(SandboxApiBase):
|
|
|
252
264
|
headers: Optional[Dict[str, str]] = None,
|
|
253
265
|
proxy: Optional[ProxyTypes] = None,
|
|
254
266
|
allow_internet_access: Optional[bool] = True,
|
|
267
|
+
object_storage:Optional[Dict[str, str]]=None,
|
|
268
|
+
net_proxy_country:Optional[str]=None,
|
|
255
269
|
) -> SandboxCreateResponse:
|
|
256
270
|
config = ConnectionConfig(
|
|
257
271
|
api_key=api_key,
|
|
@@ -271,6 +285,8 @@ class SandboxApi(SandboxApiBase):
|
|
|
271
285
|
env_vars=env_vars or {},
|
|
272
286
|
secure=secure or False,
|
|
273
287
|
allow_internet_access=allow_internet_access,
|
|
288
|
+
object_storage=object_storage,
|
|
289
|
+
net_proxy_country=net_proxy_country,
|
|
274
290
|
),
|
|
275
291
|
client=api_client,
|
|
276
292
|
)
|
|
@@ -293,6 +309,8 @@ class SandboxApi(SandboxApiBase):
|
|
|
293
309
|
sandbox_domain=res.parsed.domain,
|
|
294
310
|
envd_version=res.parsed.envd_version,
|
|
295
311
|
envd_access_token=res.parsed.envd_access_token,
|
|
312
|
+
object_storage=res.parsed.object_storage,
|
|
313
|
+
network_proxy=res.parsed.network_proxy,
|
|
296
314
|
)
|
|
297
315
|
|
|
298
316
|
@classmethod
|
|
@@ -354,3 +372,101 @@ class SandboxApi(SandboxApiBase):
|
|
|
354
372
|
)
|
|
355
373
|
for metric in res.parsed
|
|
356
374
|
]
|
|
375
|
+
|
|
376
|
+
@classmethod
|
|
377
|
+
def _cls_connect(
|
|
378
|
+
cls,
|
|
379
|
+
sandbox_id: str,
|
|
380
|
+
timeout: Optional[int] = None,
|
|
381
|
+
**opts: Unpack[ApiParams],
|
|
382
|
+
) -> "Sandbox":
|
|
383
|
+
timeout = timeout or SandboxApiBase.default_sandbox_timeout
|
|
384
|
+
|
|
385
|
+
config = ConnectionConfig(**opts)
|
|
386
|
+
|
|
387
|
+
with ApiClient(
|
|
388
|
+
config,
|
|
389
|
+
limits=SandboxApiBase._limits,
|
|
390
|
+
) as api_client:
|
|
391
|
+
res = post_sandboxes_sandbox_id_connect.sync_detailed(
|
|
392
|
+
sandbox_id,
|
|
393
|
+
client=api_client,
|
|
394
|
+
body=ConnectSandbox(timeout=timeout),
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
if res.status_code == 404:
|
|
398
|
+
raise NotFoundException(f"Paused sandbox {sandbox_id} not found")
|
|
399
|
+
|
|
400
|
+
if res.status_code >= 300:
|
|
401
|
+
raise handle_api_exception(res)
|
|
402
|
+
|
|
403
|
+
# if isinstance(res.parsed, Error):
|
|
404
|
+
# raise SandboxException(f"{res.parsed.message}: Request failed")
|
|
405
|
+
|
|
406
|
+
# Extract information from API response and create a full Sandbox instance
|
|
407
|
+
# Use delayed import to avoid circular dependency
|
|
408
|
+
from . import Sandbox
|
|
409
|
+
|
|
410
|
+
response = res.parsed
|
|
411
|
+
if response is None:
|
|
412
|
+
raise SandboxException("Connect response is None")
|
|
413
|
+
|
|
414
|
+
connection_headers = {"Authorization": "Bearer root"}
|
|
415
|
+
|
|
416
|
+
# Extract fields from API response
|
|
417
|
+
sandbox_domain = response.domain if hasattr(response, 'domain') and response.domain is not None else None
|
|
418
|
+
envd_version = response.envd_version if hasattr(response, 'envd_version') else None
|
|
419
|
+
envd_access_token = None
|
|
420
|
+
if hasattr(response, 'envd_access_token'):
|
|
421
|
+
from ..api.client.types import Unset
|
|
422
|
+
if response.envd_access_token is not None and not isinstance(response.envd_access_token, Unset):
|
|
423
|
+
envd_access_token = response.envd_access_token
|
|
424
|
+
connection_headers["X-Access-Token"] = envd_access_token
|
|
425
|
+
|
|
426
|
+
connection_config = ConnectionConfig(
|
|
427
|
+
api_key=config.api_key,
|
|
428
|
+
domain=config.domain,
|
|
429
|
+
debug=config.debug,
|
|
430
|
+
request_timeout=config.request_timeout,
|
|
431
|
+
headers=connection_headers,
|
|
432
|
+
proxy=config.proxy,
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
# Create and return a full Sandbox instance
|
|
436
|
+
sandbox = Sandbox(
|
|
437
|
+
sandbox_id=sandbox_id,
|
|
438
|
+
sandbox_domain=sandbox_domain,
|
|
439
|
+
envd_version=envd_version,
|
|
440
|
+
envd_access_token=envd_access_token,
|
|
441
|
+
connection_config=connection_config,
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
return sandbox
|
|
445
|
+
|
|
446
|
+
@classmethod
|
|
447
|
+
def _cls_pause(
|
|
448
|
+
cls,
|
|
449
|
+
sandbox_id: str,
|
|
450
|
+
**opts: Unpack[ApiParams],
|
|
451
|
+
) -> str:
|
|
452
|
+
config = ConnectionConfig(**opts)
|
|
453
|
+
|
|
454
|
+
with ApiClient(
|
|
455
|
+
config,
|
|
456
|
+
limits=SandboxApiBase._limits,
|
|
457
|
+
) as api_client:
|
|
458
|
+
res = post_sandboxes_sandbox_id_pause.sync_detailed(
|
|
459
|
+
sandbox_id,
|
|
460
|
+
client=api_client,
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
if res.status_code == 404:
|
|
464
|
+
raise NotFoundException(f"Sandbox {sandbox_id} not found")
|
|
465
|
+
|
|
466
|
+
if res.status_code == 409:
|
|
467
|
+
return sandbox_id
|
|
468
|
+
|
|
469
|
+
if res.status_code >= 300:
|
|
470
|
+
raise handle_api_exception(res)
|
|
471
|
+
|
|
472
|
+
return sandbox_id
|