-
Notifications
You must be signed in to change notification settings - Fork 177
Upgrade Template to new SDK #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mishushakov
merged 31 commits into
main
from
convert-code-interpreter-template-to-new-sdk-eng-3178
Nov 6, 2025
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
1bb61b0
initial commit
mishushakov 3b9ce19
cursor suggestions
mishushakov 856b37f
updated
mishushakov 4a1a7bc
fix template
mishushakov 3bb1ac5
fmt
mishushakov 748968a
removed unused env vars
mishushakov ef6597a
updated ci
mishushakov be9b047
python build ci test
mishushakov cf7a995
dependencies
mishushakov af0c3c0
removed dotenv from ci
mishushakov a6446d0
add capture for template id, build id
mishushakov 66eb9fb
fixes java test, template name
mishushakov 8691060
lint
mishushakov aac4798
added changeset
mishushakov c2e9f10
readded cleanup
mishushakov 46e4027
updated release CI
mishushakov cc98720
updated dockerhub push tag
mishushakov 2935716
updated readme
mishushakov 80aed03
remove poetry from template build ci
mishushakov 7673c9f
generate template alias before test run
mishushakov 29d10b6
updated workflow
mishushakov 131da7c
updated generated template alias for clarity
mishushakov 9e78917
updated output
mishushakov 2bbcf88
removed unused build_id output
mishushakov 36529ce
corrected outputs
mishushakov 13de536
pin r, java, deno versions
mishushakov 33a5c22
install java from source, keep java 11
mishushakov 7e8d74a
make sure python & js kernels always installed
mishushakov 101ab77
fixes java home
mishushakov e97ad19
make kernels set
mishushakov ea46150
fixed typo
mishushakov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@e2b/code-interpreter-template': minor | ||
| --- | ||
|
|
||
| updated template to new SDK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| start-template-server: | ||
| docker run --rm -e E2B_LOCAL=true -p 49999:49999 -it $$(docker build . -q -f ./template/test.Dockerfile) | ||
| docker run --rm -e E2B_LOCAL=true -p 49999:49999 -it $$(python template/build_docker.py | docker build -q ./template -f -) | ||
|
|
||
| kill-template-server: | ||
| docker kill $(shell docker ps --filter expose=49999 --format {{.ID}}) |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,57 @@ | ||
| # Using custom sandbox with Code Interpreter SDK | ||
|
|
||
| If you want to customize the Code Interprerter sandbox (e.g.: add a preinstalled package) you can do that by using a [custom sandbox template](https://e2b.dev/docs/sandbox-template). | ||
|
|
||
| If you want to customize the Code Interpreter sandbox (e.g.: add a preinstalled package) you can do that by creating a [custom sandbox template](https://e2b.dev/docs/template/quickstart). | ||
|
|
||
| ## Step-by-step guide | ||
| 1. Create custom sandbox by following [this guide](https://e2b.dev/docs/sandbox-template) | ||
|
|
||
| 2. Use prebuilt [E2B Code Interpreter image](https://hub.docker.com/r/e2bdev/code-interpreter) by replacing the `FROM` command in your `e2b.Dockerfile` with following | ||
| 1. Install E2B SDK | ||
|
|
||
| ``` | ||
| pip install e2b dotenv | ||
| ``` | ||
|
|
||
| 2. Create a custom sandbox template: | ||
|
|
||
| **template.py** | ||
|
|
||
| ```python | ||
| from e2b import Template | ||
|
|
||
| template = Template().from_template("code-interpreter-v1") | ||
| ``` | ||
|
|
||
| 3. Create a build script: | ||
|
|
||
| ```Dockerfile | ||
| FROM e2bdev/code-interpreter:latest | ||
| ``` | ||
| **build.py** | ||
|
|
||
| 3. Copy [`start-up.sh`](./start-up.sh) to the same directory where's your `e2b.toml` | ||
| ```python | ||
| from dotenv import load_dotenv | ||
| from .template import template | ||
mishushakov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| from e2b import Template, default_build_logger | ||
|
|
||
| 4. Run the following in the same directory where's your `e2b.toml` | ||
| ```sh | ||
| e2b template build -c "/root/.jupyter/start-up.sh" | ||
| ``` | ||
| load_dotenv() | ||
|
|
||
| 5. Use your custom sandbox with Code Interpreter SDK | ||
| Template.build( | ||
| template, | ||
| alias="code-interpreter-custom", | ||
| cpu_count=2, | ||
| memory_mb=2048, | ||
| on_build_logs=default_build_logger(), | ||
| ) | ||
| ``` | ||
|
|
||
| **Python** | ||
| ```python | ||
| from e2b_code_interpreter import Sandbox | ||
| sandbox = Sandbox.create(template="your-custom-sandbox-name") | ||
| execution = sandbox.run_code("print('hello')") | ||
| sandbox.kill() | ||
| 3. Build the template: | ||
|
|
||
| # Or you can use `with` which handles closing the sandbox for you | ||
| with Sandbox.create(template="your-custom-sandbox-name") as sandbox: | ||
| execution = sandbox.run_code("print('hello')") | ||
| ``` | ||
|
|
||
| ``` | ||
| python build.py | ||
| ``` | ||
|
|
||
| **JavaScript/TypeScript** | ||
| 4. Use the custom template: | ||
|
|
||
| ```js | ||
| import {Sandbox} from '@e2b/code-interpreter' | ||
| ```python | ||
| from e2b import Sandbox | ||
|
|
||
| const sandbox = await Sandbox.create({template: 'your-custom-sandbox-name'}) | ||
| const execution = await sandbox.runCode('print("hello")') | ||
| await sandbox.kill() | ||
| ``` | ||
| sbx = Sandbox.create(template="code-interpreter-custom") | ||
| execution = sbx.run_code("print('Hello, World!')") | ||
| print(execution.logs.stdout) | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import os | ||
| from e2b import Template, default_build_logger | ||
| from template import make_template | ||
|
|
||
| Template.build( | ||
| make_template(set_user_workdir=True), | ||
| alias=os.environ["E2B_TESTS_TEMPLATE"], | ||
| cpu_count=2, | ||
| memory_mb=2048, | ||
| on_build_logs=default_build_logger(), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from template import make_template | ||
| from e2b import Template | ||
|
|
||
| tmp = make_template(kernels=["python", "javascript"]) | ||
| print(Template.to_dockerfile(tmp)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| from dotenv import load_dotenv | ||
| from e2b import Template, default_build_logger | ||
| from template import make_template | ||
|
|
||
| load_dotenv() | ||
|
|
||
| Template.build( | ||
| make_template(set_user_workdir=True), | ||
| alias="code-interpreter-v1", | ||
| cpu_count=2, | ||
| memory_mb=2048, | ||
| on_build_logs=default_build_logger(), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| from dotenv import load_dotenv | ||
| from e2b import Template, default_build_logger | ||
| from template import make_template | ||
|
|
||
| load_dotenv() | ||
|
|
||
| Template.build( | ||
| make_template(kernels=["python", "javascript"], set_user_workdir=True), | ||
| alias="code-interpreter-dev", | ||
| cpu_count=1, | ||
| memory_mb=1024, | ||
| on_build_logs=default_build_logger(min_level="debug"), | ||
| ) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| e2b==2.6.0 | ||
| python-dotenv==1.2.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.