Skip to content

Commit 0a56677

Browse files
authored
Codeinterpreter start command (#79)
* Add details about sandbox continuous runtime limits * Update port-not-open troubleshooting page * Update from-image to from-template in example * fixing typo * fixing more typos * fix typo * persistance fixes * changed js to ts in example * remove note
1 parent 7489c84 commit 0a56677

4 files changed

Lines changed: 58 additions & 14 deletions

File tree

docs/sandbox.mdx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ sidebarTitle: Lifecycle
55

66
When you start the sandbox, it stays alive for 5 minutes by default but you can change it by passing the `timeout` parameter.
77
After the time passes, the sandbox will be automatically shutdown.
8+
9+
<Warning>
10+
The maximum time sandbox can be kept running without being paused is
11+
- 24 hours on the Pro Tier
12+
- 1 hour on the Base Tier
13+
14+
For more details, please refer to [sandbox persistance page](/docs/sandbox/persistence#limitations-while-in-beta).
15+
</Warning>
16+
817
<CodeGroup>
918
```js JavaScript & TypeScript highlight={6}
1019
import { Sandbox } from '@e2b/code-interpreter'
@@ -29,12 +38,12 @@ sandbox = Sandbox.create(
2938

3039
## Change sandbox timeout during runtime
3140

32-
You can change the sandbox timeout when it's running by calling the the `setTimeout` method in JavaScript or `set_timeout` method in Python.
41+
You can change the sandbox timeout when it's running by calling the `setTimeout` method in JavaScript or `set_timeout` method in Python.
3342

3443
When you call the set timeout method, the sandbox timeout will be reset to the new value that you specified.
3544

3645
This can be useful if you want to extend the sandbox lifetime when it's already running.
37-
You can for example start with a sandbox with 1 minute timeout and then periodically call set timout every time user interacts with it in your app.
46+
You can for example start with a sandbox with 1 minute timeout and then periodically call set timeout every time user interacts with it in your app.
3847

3948
<CodeGroup>
4049
```js JavaScript & TypeScript

docs/sandbox/connect-bucket.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To use the Google Cloud Storage we need to install the `gcsfuse` package. There'
2424

2525
```ts JavaScript & TypeScript
2626
const template = Template()
27-
.fromImage("e2bdev/code-interpreter:latest")
27+
.fromTemplate("code-interpreter-v1")
2828
.aptInstall(["gnupg", "lsb-release"])
2929
.runCmd("lsb_release -c -s > /tmp/lsb_release")
3030
.runCmd(
@@ -34,14 +34,13 @@ const template = Template()
3434
"curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo tee /usr/share/keyrings/cloud.google.asc",
3535
)
3636
.aptInstall(["gcsfuse"])
37-
.setStartCmd("sudo /root/.jupyter/start-up.sh", waitForPort(49999));
3837
```
3938

4039

4140
```python Python
4241
template = (
4342
Template()
44-
.from_image("e2bdev/code-interpreter:latest")
43+
.from_template("code-interpreter-v1")
4544
.apt_install(["gnupg", "lsb-release"])
4645
.run_cmd("lsb_release -c -s > /tmp/lsb_release")
4746
.run_cmd(
@@ -51,7 +50,6 @@ template = (
5150
"curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo tee /usr/share/keyrings/cloud.google.asc"
5251
)
5352
.apt_install(["gcsfuse"])
54-
.set_start_cmd("sudo /root/.jupyter/start-up.sh", wait_for_port(49999))
5553
)
5654
```
5755

docs/sandbox/persistence.mdx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,21 @@ If you resume the sandbox, the service will be accessible again but you need to
275275

276276

277277
## Limitations while in beta
278-
- Pausing a sandbox takes about 4 seconds per 1 GiB of RAM
279-
- Resuming a sandbox takes about 1 second
280-
- Sandbox can be used up to 30 days
281-
- After 30 days from the initial sandbox create call, the data may be deleted and you will not be able to resume it. Attempting to resume a sandbox that was deleted or does not exist will result in the `NotFoundError` in the JavaScript SDK or the `NotFoundException` in the Python SDK
278+
279+
### Lifecycle duration
280+
- A sandbox can exist for **up to 30 days** from the initial `create` call.
281+
- After 30 days, sandbox data **may be deleted** and the sandbox can no longer be resumed.
282+
- Attempting to resume a deleted or non-existent sandbox will result in:
283+
- `NotFoundError` in the JavaScript SDK
284+
- `NotFoundException` in the Python SDK
285+
286+
### Pause and resume performance
287+
- Pausing a sandbox takes approximately **4 seconds per 1 GiB of RAM**
288+
- Resuming a sandbox takes approximately **1 second**
289+
290+
### Continuous runtime limits
291+
- A sandbox can remain running (without being paused) for:
292+
- **24 hours** on the **Pro tier**
293+
- **1 hour** on the **Base tier**
294+
- After a sandbox is paused and resumed, the continuous runtime limit is **reset**
295+
- The **30-day total lifetime limit** still applies regardless of how many times the sandbox is paused or resumed

docs/troubleshooting/templates/49999-port-not-open.mdx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ The reason for this is that either the default start command is not specified on
1919

2020
With the current build system, you need to use the `code-interpreter` as a base template in your template definition.
2121

22-
<Note>
23-
The default start command for the `code-interpreter` template is `/root/.jupyter/start-up.sh`.
24-
</Note>
25-
2622
<CodeGroup>
2723
```js JavaScript & TypeScript
2824
import { Template } from '@e2b/code-interpreter'
@@ -36,6 +32,33 @@ template = Template().from_template("code-interpreter-v1")
3632
```
3733
</CodeGroup>
3834

35+
<Note>
36+
We strongly recommend building custom template via the previous example. However, if you choose to build from docker image, do as follows.
37+
</Note>
38+
39+
<CodeGroup>
40+
```ts JavaScript & TypeScript
41+
import { Template, waitForURL } from '@e2b/code-interpreter'
42+
43+
const template = Template()
44+
.fromImage("e2bdev/code-interpreter:latest")
45+
.setStartCmd(
46+
"sudo /root/.jupyter/start-up.sh", waitForURL("http://localhost:49999/health")
47+
)
48+
```
49+
```python Python
50+
from e2b_code_interpreter import Template, wait_for_url
51+
52+
template = (
53+
Template()
54+
.from_image("e2bdev/code-interpreter:latest")
55+
.set_start_cmd(
56+
"sudo /root/.jupyter/start-up.sh", wait_for_url("http://localhost:49999/health")
57+
)
58+
)
59+
```
60+
</CodeGroup>
61+
3962
### Legacy Build System
4063

4164
If you are using the legacy build system, you need to use Code Interpreter image as a base image:

0 commit comments

Comments
 (0)