solari-e2b-compat 0.2.1__tar.gz → 0.2.2__tar.gz
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.
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/COMPAT.md +3 -2
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/PKG-INFO +2 -2
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/README.md +1 -1
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/pyproject.toml +1 -1
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/__init__.py +1 -1
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/_vendor_user.py +11 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/code_interpreter.py +3 -3
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/.gitignore +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/LICENSE +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/LICENSE-E2B +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/NOTICE +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/_box.py +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/_commands.py +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/_config.py +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/_filesystem.py +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/_loop.py +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/_redact.py +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/_sandbox.py +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/_sync.py +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/_template.py +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/exceptions.py +0 -0
- {solari_e2b_compat-0.2.1 → solari_e2b_compat-0.2.2}/solari_e2b/models.py +0 -0
|
@@ -29,7 +29,7 @@ and the differences that are specific to Python.
|
|
|
29
29
|
## Sandbox
|
|
30
30
|
| Call | Status | Notes |
|
|
31
31
|
|---|---|---|
|
|
32
|
-
| `Sandbox.create(template, timeout, metadata, envs, lifecycle, volume_mounts, ...)` | OK, live | `template`: `base`, a name from `Template.build`, or a `tpl_…` id. Default `base` (`code-interpreter-
|
|
32
|
+
| `Sandbox.create(template, timeout, metadata, envs, lifecycle, volume_mounts, ...)` | OK, live | `template`: `base`, a name from `Template.build`, or a `tpl_…` id. Default `base` (`code-interpreter-v2` in `solari_e2b.code_interpreter`). |
|
|
33
33
|
| `timeout` | DIFF | E2B's is a lifetime; Solari's is a rolling idle window that resets on use. Default 300 s as in E2B. The per-plan deadline still bounds total life. |
|
|
34
34
|
| `lifecycle={'on_timeout': ..., 'auto_resume': ...}` | OK | `{'action': 'pause', 'mode': 'filesystem'}` pauses with RAM too (a superset). |
|
|
35
35
|
| `volume_mounts={path: 'vol_…' or name}` | DIFF | Solari persistent volumes by id or name. `Volume` objects: NO. |
|
|
@@ -78,7 +78,7 @@ and the differences that are specific to Python.
|
|
|
78
78
|
| `timeout=` | DIFF | Stops waiting and raises `TimeoutException`; the kernel keeps running the code. No default timeout. |
|
|
79
79
|
| `create_code_context(cwd, language)` | OK, live | Python only. |
|
|
80
80
|
| `list_code_contexts`, `remove_code_context`, `restart_code_context` | DIFF, live | Solari cannot list or destroy kernels. `list` returns contexts created by this process; `remove` forgets the context (the kernel stays until the sandbox ends); `restart` clears the context's variables and working directory without restarting the process. |
|
|
81
|
-
| Default template | DIFF | `code-interpreter-
|
|
81
|
+
| Default template | DIFF | `code-interpreter-v2` is built into your org on first `Sandbox.create()` without a template: about 80 seconds, billed as a template build, and two processes that both find it missing each start a build. `build_code_interpreter_template()` (async) / `build_code_interpreter_template_sync()` prebuild it. |
|
|
82
82
|
|
|
83
83
|
## Templates
|
|
84
84
|
| Call | Status | Notes |
|
|
@@ -105,6 +105,7 @@ asks the gateway for exactly that at create time (`user: "user"`, `cwd: "/home/u
|
|
|
105
105
|
sudo). Restores from a snapshot keep the snapshot's own user.
|
|
106
106
|
- **Gateway that predates `user` / `cwd`** (it answers 400 naming them, or ignores them): the plain create is used and the sandbox runs as **root in
|
|
107
107
|
`/home/root`**, which is what this package did before. Check `whoami` if code depends on it.
|
|
108
|
+
- **Template or snapshot made before user support** (the server answers 400 naming `user` with "the guest predates user support"): the plain create is used, the sandbox runs as **root**, and one warning says so. Rebuild the template to get the vendor user. The default code-interpreter template is named `code-interpreter-v2`, so upgrading this package builds a fresh one on first `Sandbox.create()`; an older `code-interpreter-v1` in your org is left alone and no longer used.
|
|
108
109
|
- Shared isolation is commands and code only and takes no `user` / `cwd`; the compat packages never create shared sandboxes. `commands.run(..., user=)` is passed to the guest per call; `user=` on filesystem calls stays NO.
|
|
109
110
|
|
|
110
111
|
## Snapshots, results and listing (0.2.1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: solari-e2b-compat
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: E2B-compatible Python interface (sandboxes and code interpreter) over Solari Sandboxes. Not affiliated with E2B.
|
|
5
5
|
Project-URL: Homepage, https://getsolari.com
|
|
6
6
|
Author: Solari
|
|
@@ -65,7 +65,7 @@ An E2B key does not work here: use a Solari API key.
|
|
|
65
65
|
## The code-interpreter template
|
|
66
66
|
|
|
67
67
|
`e2b_code_interpreter` runs in a template with a data-analysis stack (pandas, numpy, scipy, scikit-learn, seaborn,
|
|
68
|
-
plotly, ...). Solari builds the equivalent, `code-interpreter-
|
|
68
|
+
plotly, ...). Solari builds the equivalent, `code-interpreter-v2`, into your org the first time `Sandbox.create()` is
|
|
69
69
|
called without a template (about 80 seconds, once). To do it ahead of time:
|
|
70
70
|
|
|
71
71
|
```python
|
|
@@ -46,7 +46,7 @@ An E2B key does not work here: use a Solari API key.
|
|
|
46
46
|
## The code-interpreter template
|
|
47
47
|
|
|
48
48
|
`e2b_code_interpreter` runs in a template with a data-analysis stack (pandas, numpy, scipy, scikit-learn, seaborn,
|
|
49
|
-
plotly, ...). Solari builds the equivalent, `code-interpreter-
|
|
49
|
+
plotly, ...). Solari builds the equivalent, `code-interpreter-v2`, into your org the first time `Sandbox.create()` is
|
|
50
50
|
called without a template (about 80 seconds, once). To do it ahead of time:
|
|
51
51
|
|
|
52
52
|
```python
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "solari-e2b-compat"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.2"
|
|
8
8
|
description = "E2B-compatible Python interface (sandboxes and code interpreter) over Solari Sandboxes. Not affiliated with E2B."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import re
|
|
6
|
+
import warnings
|
|
6
7
|
from typing import Any
|
|
7
8
|
|
|
8
9
|
from solari_core.errors import GatewayError
|
|
@@ -15,6 +16,15 @@ def _refuses_user_fields(e: BaseException) -> bool:
|
|
|
15
16
|
return isinstance(e, GatewayError) and e.status == 400 and re.search(r"\b(user|cwd)\b", repr(getattr(e, "body", None)), re.I) is not None
|
|
16
17
|
|
|
17
18
|
|
|
19
|
+
def _warn_root() -> None:
|
|
20
|
+
warnings.warn(
|
|
21
|
+
"solari-e2b-compat: the server or this template's image predates user support, so the sandbox runs as root instead of 'user'. "
|
|
22
|
+
"Rebuild templates and snapshots made before user support shipped to get the vendor user.",
|
|
23
|
+
RuntimeWarning,
|
|
24
|
+
stacklevel=4,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
18
28
|
async def create_as_vendor_user(solari: Any, **opts: Any) -> Any:
|
|
19
29
|
"""``solari.create(**opts)`` with ``user`` / ``cwd`` set to E2b's defaults. A gateway that predates them (it answers 400
|
|
20
30
|
naming them) gets the plain create, and the sandbox runs as root there (COMPAT.md). Restores from a snapshot keep the
|
|
@@ -26,4 +36,5 @@ async def create_as_vendor_user(solari: Any, **opts: Any) -> Any:
|
|
|
26
36
|
except GatewayError as e:
|
|
27
37
|
if not _refuses_user_fields(e):
|
|
28
38
|
raise
|
|
39
|
+
_warn_root()
|
|
29
40
|
return await solari.create(**opts)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""``e2b_code_interpreter`` on Solari: ``Sandbox`` / ``AsyncSandbox`` with ``run_code`` and code contexts. Python runs in
|
|
2
2
|
Solari's persistent kernel (rich results, structured charts). ``bash`` runs as a one-shot command. Other languages raise
|
|
3
|
-
(the guest ships a Python kernel only). The default template, ``code-interpreter-
|
|
3
|
+
(the guest ships a Python kernel only). The default template, ``code-interpreter-v2``, is built into your org on first use."""
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
@@ -25,7 +25,7 @@ from .exceptions import CommandExitException, InvalidArgumentException, SandboxE
|
|
|
25
25
|
|
|
26
26
|
log = logging.getLogger("solari_e2b")
|
|
27
27
|
|
|
28
|
-
CODE_INTERPRETER_TEMPLATE = "code-interpreter-
|
|
28
|
+
CODE_INTERPRETER_TEMPLATE = "code-interpreter-v2"
|
|
29
29
|
|
|
30
30
|
#: The data-analysis stack of E2B's default code-interpreter image, minus the very large audio/NLP/vision wheels.
|
|
31
31
|
CODE_INTERPRETER_PACKAGES = [
|
|
@@ -305,7 +305,7 @@ _building: Dict[Any, "asyncio.Future[str]"] = {}
|
|
|
305
305
|
|
|
306
306
|
|
|
307
307
|
async def build_code_interpreter_template(on_log: Optional[Callable[[str], None]] = None, **opts: Any) -> str:
|
|
308
|
-
"""Build ``code-interpreter-
|
|
308
|
+
"""Build ``code-interpreter-v2`` into your org (about 80 seconds, once). ``Sandbox.create()`` calls this when it is missing."""
|
|
309
309
|
conn = resolve_conn(**split_opts(opts)[0])
|
|
310
310
|
key = (conn.api_key, conn.base_url)
|
|
311
311
|
fut = _building.get(key)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|