Berry
e83cf86454
feat: add getTags/get_tags to list all tags for a template ( #1132 )
...
## Summary
- Add `GET /templates/{templateID}/tags` endpoint to the OpenAPI spec
- Add `Template.getTags()` to JS/TS SDK
- Add `Template.get_tags()` (sync) and `AsyncTemplate.get_tags()`
(async) to Python SDK
- Returns a list of `TemplateTag` objects with `tag`, `buildId`, and
`createdAt` fields
## Test plan
- Added unit tests for JS SDK (`Template.getTags` happy path + 404
error)
- Added unit tests for Python SDK (sync + async, happy path + error)
2026-03-03 16:38:39 +01:00
Mish Ushakov
07ef17f1b0
Rename alias exists > name exists ( #1100 )
2026-01-27 21:53:37 +01:00
Jakub Dobry
10abab8e96
feat: add template versioning with tags support for JS and Python SDKs ( #1080 )
2026-01-27 13:41:24 +00:00
Mish Ushakov
31670f4068
Updated Template.aliasExists error type ( #1079 )
...
small follow-up to #1068
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Aligns alias existence error handling across SDKs to use
template-specific errors.
>
> - JS: `checkAliasExists` now passes `TemplateError` to
`handleApiError` and imports `TemplateError` in `buildApi.ts`
> - Python: `check_alias_exists` uses `TemplateException` in both async
and sync `build_api.py`
> - Adds changeset for patch releases of `@e2b/python-sdk` and `e2b`
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot ) for commit
0624c03207d0ee09b2fc838e204f6232cba5c748. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot ).</sup>
<!-- /CURSOR_SUMMARY -->
2026-01-12 14:00:01 +01:00
Jiri Sveceny
d8ef36d84f
Support Template.aliasExists for JavaScript and Python SDKs ( #1068 )
...
Integration tests will fail until the feature is deployed in E2B Cloud
production.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Enables checking template alias availability from both SDKs.
>
> - JS: Implements `checkAliasExists` in `template/buildApi.ts`, exposes
`Template.aliasExists` in `template/index.ts`, adds `AliasExistsOptions`
type and tests
> - Python: Adds `Template.alias_exists` and
`AsyncTemplate.alias_exists` wired to generated
`get_templates_aliases_{alias}` client; includes sync/async tests
> - API: Regenerates schemas/clients to include `GET
/templates/aliases/{alias}`, template build logs endpoint and
parameters, and supporting models (e.g., `TemplateAliasResponse`)
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot ) for commit
4e577fd77888478ac83b66db7537cd2355ea050b. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot ).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-12 10:05:48 +00:00
Jakub Dobry
4c612888d4
feat: implement network out allow/deny list support ( #1016 )
2025-11-15 22:35:09 +00:00
Joseph Lombrozo
98d2c8c0a8
Ensure that httpx transport is reused across calls by default ( #997 )
...
This takes some shortcuts in order to keep backwards compatibility.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Reuses a singleton httpx transport/client across the SDK, introduces a
generic retry decorator for connect calls, and refactors code/tests to
use the shared clients and fixtures.
>
> - **SDK (transport/client reuse)**
> - Add global `limits` (configurable via `E2B_*` env vars) and switch
`ApiClient` to accept `transport` instead of `limits`.
> - Introduce `e2b.api.client_async/client_sync` with `get_transport()`
(singleton) and `get_api_client()`; update `Sandbox`/`AsyncSandbox`,
paginators, and sandbox APIs to use them.
> - Remove per-class `_limits` from `SandboxBase`/`TemplateBase`; merge
extra headers correctly; pass `E2b-Sandbox-Port` as string.
> - Template build flows (sync/async) now reuse the API client's
underlying httpx client for file uploads.
> - **Connect client** (`e2b_connect/client.py`)
> - Add `_retry` decorator and apply to unary/server-stream methods;
simplify reconnection logic; minor typing/headers cleanups.
> - **Tests**
> - Add retry unit tests; introduce
`sandbox_factory`/`async_sandbox_factory` and a session `event_loop`;
refactor tests to use factories and shared transports; adjust tar
archive expectations.
> - **Misc**
> - Add `.editorconfig`, CLI `.envrc`, and changeset entries.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot ) for commit
1d359231b63dc21b6c8d797886f7d6a77c9ed6b7. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot ).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Tomas Valenta <valenta.and.thomas@gmail.com>
Co-authored-by: Mish <10400064+mishushakov@users.noreply.github.com>
2025-11-14 16:48:29 -08:00
Mish Ushakov
56d16a8762
Fix ignore files in file upload and added tests ( #1012 )
...
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Ensure file uploads honor ignore patterns (incl. .dockerignore),
refactor file discovery/tar streaming in JS/Python SDKs, and add
comprehensive tests.
>
> - **File upload behavior**:
> - JS/TS and Python uploads now pass `ignorePatterns` (merged from
`fileIgnorePatterns` and `.dockerignore`) to tar creation, ensuring
ignored files aren’t uploaded.
> - **Refactor/Utilities**:
> - Rename `getAllFilesForFilesHash` -> `getAllFilesInPath` with
optional directory inclusion in both SDKs.
> - Implement `tar_file_stream` (JS and Python) to build archives from
`getAllFilesInPath`, with `noDirRecurse` and symlink control.
> - Hashing functions updated to use `getAllFilesInPath`.
> - Type tweak: allow `None` in Python `stack_traces` during build wait.
> - **Integration**:
> - JS `uploadFile` and Python async/sync `upload_file` now use tar
streaming with ignore patterns; JS `Template` wires ignore patterns into
uploads.
> - **Tests**:
> - Add extensive tests for `getAllFilesInPath` and `tar_file_stream` in
JS and Python, covering ignore patterns, directories, sorting, and
symlinks.
> - Remove obsolete tests relying on old function names.
> - **Meta**:
> - Changeset entries for `@e2b/python-sdk` and `e2b` (patch).
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot ) for commit
2f83444f9006393f33e8c346bec1998b3a06044d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot ).</sup>
<!-- /CURSOR_SUMMARY -->
2025-11-10 02:59:29 -08:00
Jakub Dobry
6b74009972
feat: add template background build helpers ( #1011 )
...
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Add background template build APIs and build status retrieval to
JS/Python SDKs, change build methods to return BuildInfo, and add tests.
>
> - **JS SDK (templates)**:
> - Add `Template.buildInBackground` to start builds without waiting and
return `BuildInfo`.
> - Add `Template.getBuildStatus` with optional `logsOffset`; expose
`GetBuildStatusResponse`.
> - Change `Template.build` to return `BuildInfo` and then wait for
completion; refactor internal `build(...)` to accept `ApiClient` and
return identifiers.
> - Add types `AuthOptions`, `BuildInfo`, `GetBuildStatusOptions`; make
`logsOffset` optional in `getBuildStatus` input; update tests with
`backgroundBuild.test.ts`.
> - **Python SDK (templates)**:
> - Introduce `BuildInfo` dataclass;
`Template.build`/`AsyncTemplate.build` now return `BuildInfo`.
> - Add `Template.build_in_background` /
`AsyncTemplate.build_in_background` and `Template.get_build_status` /
`AsyncTemplate.get_build_status`; factor shared `_build`.
> - Export `BuildInfo` in `__init__.py`; add sync/async background build
tests.
> - **Meta**:
> - Add changeset for patch releases.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot ) for commit
a47f70ea339f6ea2964714a122cde5b7cb5a891b. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot ).</sup>
<!-- /CURSOR_SUMMARY -->
2025-11-06 16:26:27 +01:00
Jakub Novák
423d87cf91
Update spec and templates to use /v3/ endpoint ( #1002 )
...
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Switches SDKs to the /v3 template build API and updates spec with
sandbox connect, team max metrics, and related schema changes while
deprecating legacy endpoints.
>
> - **API Spec / Schema**:
> - **Templates v3**: Add `POST /v3/templates` with
`TemplateBuildRequestV3` → `TemplateRequestResponseV3`; deprecate `POST
/templates`, `POST /templates/{templateID}`, and `POST /v2/templates`
(now return `TemplateLegacy`).
> - **Sandbox Connect**: Add `POST /sandboxes/{sandboxID}/connect` with
`ConnectSandbox`; mark `POST /sandboxes/{sandboxID}/resume` as
deprecated.
> - **Team Metrics**: Add `GET /teams/{teamID}/metrics/max` returning
`MaxTeamMetric`.
> - **Schema updates**: `Template` now includes `buildStatus`
(`TemplateBuildStatus`); `BuildLogEntry.step`;
`BuildStatusReason.logEntries`; `NodeStatusChange.clusterID`; replace
`McpConfig` with nullable `Mcp`; add `timestampUnix` to metrics and
deprecate `timestamp`.
> - **JS SDK**:
> - Update template build request to `POST /v3/templates` in
`template/buildApi.ts`.
> - Regenerate `schema.gen.ts` reflecting new endpoints/types and
deprecations.
> - **Python SDK**:
> - Add client for `POST /v3/templates`; switch sync/async build APIs to
use `TemplateBuildRequestV3` and new response type.
> - Add client for `POST /sandboxes/{sandboxID}/connect`.
> - Introduce/adjust models: `TemplateBuildStatus`,
`TemplateRequestResponseV3`, `TemplateLegacy`, `ConnectSandbox`,
`MaxTeamMetric`, `McpType0`, and metric timestamp fields.
> - **Meta**:
> - Changesets: patch bumps for affected packages.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot ) for commit
4672fbf655ae3e508bf375dc58a89299e19f0664. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot ).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-31 01:53:02 -07:00
Mish Ushakov
1d0d404dc0
Move template exceptions to shared ( #953 )
...
Co-authored-by: Jakub Dobry <jakub.dobry8@gmail.com>
2025-10-16 03:57:00 -07:00
Mish Ushakov
73114272e0
Add docstrings to public-facing template methods ( #943 )
...
(Feel free to just suggest edits so it's faster)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds extensive docstrings across JS/Python template APIs, updates
default base image versions, and adjusts JS SDK exports and logger
internals.
>
> - **Docs/Comments**:
> - Add comprehensive docstrings and examples across `template` modules
(JS and Python): `consts`, `errors/exceptions`, `index/main`, `logger`,
`readycmd`, `types`, `utils`, and async/sync builders.
> - **JS SDK**:
> - Re-export `BuildOptions`, `CopyItem`, `TemplateBuilder`,
`TemplateClass` from `template/types` via `src/index.ts`.
> - Simplify `template` exports to `Template` and `type TemplateBase`.
> - Rename internal build logger to `DefaultBuildLogger` (used by
`defaultBuildLogger`).
> - **Defaults**:
> - Change `fromDebianImage()` default variant to `stable` and
`fromPythonImage()` default to `3` (JS and Python).
> - **Misc**:
> - Add internal documentation for stack tracing, hashing, ready checks;
minor wording/consistency tweaks.
> - Add changeset for patch releases of `@e2b/python-sdk` and `e2b`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot ) for commit
37d21d8543e1e9c6b61c0b7ad7cd254774767524. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot ).</sup>
<!-- /CURSOR_SUMMARY -->
2025-10-14 09:04:07 -07:00
Jakub Dobry
a01c2374a9
feat: pretty default logs for build helper ( #925 )
2025-10-09 05:44:03 -07:00
Mish Ushakov
b1e2701931
Correct file hashing logic in the SDK ( #916 )
...
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Co-authored-by: Jakub Dobry <jakub.dobry8@gmail.com>
2025-10-01 05:37:58 -07:00
Jakub Dobry
b9c4b16baa
feat: add template migration to CLI ( #880 )
...
## 🔄 Add Template Migration to CLI
### Summary
This PR introduces a new `migrate` command to the E2B CLI that helps
users transition from the legacy Dockerfile + TOML configuration format
to the new Template SDK format. The migration tool automatically
converts existing `e2b.Dockerfile` and `e2b.toml` configurations into
SDK-compatible template files using Handlebars templates.
### What's Changed
#### ✨ New Features
- **Template Migration Command**: Added `e2b template migrate` command
for converting legacy configurations to SDK format
- **Multi-Language Support**: Supports migration to TypeScript, Python
(sync), and Python (async) formats
- **Interactive Language Selection**: CLI prompts for target language
when not specified
- **Multi-stage Dockerfile Support**: Added fallback handling for
complex multi-stage Dockerfiles
#### 🔧 Technical Improvements
- **Enhanced ENV Handling**: Improved parsing of multiple environment
variables from single ENV instructions
- **File Name Conflict Resolution**: Automatic unique filename
generation to prevent overwriting existing files
- **Comprehensive Template Generation**: Creates both development and
production build files
#### 📁 New Template Files
- `typescript-template.hbs` - TypeScript template generation
- `typescript-build.hbs` - TypeScript build script template
- `python-template.hbs` - Python template generation (supports both
sync/async)
- `python-build-async.hbs` - Python async build script template
- `python-build-sync.hbs` - Python sync build script template
### Usage
```bash
# Migrate with interactive language selection
e2b template migrate
# Migrate to specific language
e2b template migrate --language typescript
e2b template migrate --language python-sync
e2b template migrate --language python-async
# Custom paths
e2b template migrate --dockerfile custom.dockerfile --config custom.toml
```
### Generated Output
The migration command generates three files per target:
- `template.{ts|py}` - Template definition using SDK
- `build{.|_}dev.{ts|py}` - Development build script
- `build{.|_}prod.{ts|py}` - Production build script
### Migration Process
1. **Parse Configuration**: Reads `e2b.toml` for template settings
2. **Dockerfile Analysis**: Uses E2B SDK to parse Dockerfile
instructions
3. **Transformation**: Converts Docker instructions to SDK method calls
4. **Code Generation**: Uses Handlebars templates to generate target
language files
5. **File Creation**: Writes template and build files with conflict
resolution
### Error Handling
- **Graceful Dockerfile Parsing**: Falls back to custom image reference
for unparseable Dockerfiles
- **Clear User Guidance**: Provides manual build instructions when
automatic conversion fails
- **Validation**: Ensures required configuration files exist before
migration
2025-09-19 17:41:28 +02:00
Mish Ushakov
9f9e2a8f20
Render failed layer stack traces on build error ( #901 )
...
### Changelog
- Added traces for Python and JavaScript SDK.
- Added methods for stack trace collection, stack trace context
- Updated file upload mechanism for tracing
- Changed API handling to support throwing API errors with traces
> **Note**
> For functions like `aptInstall`, `fromRegistry` which call `.run` and
`.fromImage`, the stack trace has to be replaced so it throws correctly
from parent.
> **Note**
> There are no build logs in the trace, we can add this at later point.
### Examples
Keep in mind that the way the traces are rendered entirely depends on
environment (Bun, Node, Deno, Vitest, Pytest)
**Standard Python**
```
Traceback (most recent call last):
File "/Users/mish/Documents/Projects/E2B/E2B/packages/python-sdk/tests/sync/template_sync/test_stacktrace.py", line 17, in <module>
Template.build(
~~~~~~~~~~~~~~^
template,
^^^^^^^^^
...<2 lines>...
memory_mb=1024,
^^^^^^^^^^^^^^^
)
^
File "/Users/mish/Documents/Projects/E2B/E2B/packages/python-sdk/e2b/template_sync/main.py", line 157, in build
wait_for_build_finish(
~~~~~~~~~~~~~~~~~~~~~^
api_client,
^^^^^^^^^^^
...<4 lines>...
stack_traces=template._template._stack_traces,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/mish/Documents/Projects/E2B/E2B/packages/python-sdk/e2b/template_sync/build_api.py", line 199, in wait_for_build_finish
raise BuildException(error_message).with_traceback(stack_trace)
File "/Users/mish/Documents/Projects/E2B/E2B/packages/python-sdk/tests/sync/template_sync/test_stacktrace.py", line 12, in <module>
.run_cmd("cat non_existing_file.txt")
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
e2b.template.exceptions.BuildException: failed to run command: exit status 1
```
**Pytest**
```
[gw0] darwin -- Python 3.13.3 /Users/mish/Library/Caches/pypoetry/virtualenvs/e2b-e6GdLxLZ-py3.13/bin/python
@pytest.mark.skip_debug()
def test_build():
template = (
Template()
.from_image("ubuntu:22.04")
.run_cmd("cat non_existing_file.txt")
.set_workdir("/app")
.set_start_cmd("echo 'Hello, world!'", wait_for_timeout(10_000))
)
# try:
> Template.build(
template,
alias=str(uuid4()),
cpu_count=1,
memory_mb=1024,
)
tests/sync/template_sync/test_stacktrace.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
e2b/template_sync/main.py:157: in build
wait_for_build_finish(
e2b/template_sync/build_api.py:199: in wait_for_build_finish
raise BuildException(error_message).with_traceback(stack_trace)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@pytest.mark.skip_debug()
def test_build():
template = (
Template()
.from_image("ubuntu:22.04")
> .run_cmd("cat non_existing_file.txt")
.set_workdir("/app")
.set_start_cmd("echo 'Hello, world!'", wait_for_timeout(10_000))
)
E e2b.template.exceptions.BuildException: failed to run command: exit status 1
tests/sync/template_sync/test_stacktrace.py:12: BuildException
========================================================== short test summary info ==========================================================
FAILED tests/sync/template_sync/test_stacktrace.py::test_build - e2b.template.exceptions.BuildException: failed to run command: exit status 1
```
**Node**
```
node:internal/modules/run_main:104
triggerUncaughtException(
^
at file:///Users/mish/Documents/Projects/E2B/E2B/packages/js-sdk/tests/template/trace.test.mts:8:4
at ModuleJob.run (node:internal/modules/esm/module_job:274:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:98:5) {
name: 'BuildError'
}
Node.js v23.11.0
```
**Bun**
```
1 | export class BuildError extends Error {
2 | constructor(message: string, stackTrace?: string) {
3 | super(message)
^
BuildError: failed to run command: exit status 1
at /Users/mish/Documents/Projects/E2B/E2B/packages/js-sdk/src/template/errors.ts:3:5
Bun v1.2.4 (macOS arm64)
```
**Vitest**
```
BuildError: failed to run command: exit status 1
❯ tests/template/trace.test.ts:8:6
6| const template = Template()
7| .fromImage('ubuntu:22.04')
8| .runCmd('cat folder/test.txt')
| ^
9| .setWorkdir('/app')
10| .setStartCmd('echo "Hello, world!"', waitForTimeout(10_000))
```
---------
Co-authored-by: Jakub Dobry <jakub.dobry8@gmail.com>
2025-09-19 12:34:08 +02:00
Mish Ushakov
3d6418184f
Add custom registries support for pulling base images ( #897 )
...
### Changelog
- added support for pulling base images from AWS, Docker, GCP
registries.
- removed unnecessary conversion in build_api.py.
- synced serialize implementation in TypeScript and Python.
- added Cursor Pylance config (side-effect, can delete if unwanted).
### Examples
**TypeScript**
```ts
import { Template } from 'e2b'
// Generic Docker registry
Template().fromRegistry('ubuntu:22.04', {
username: 'jirka',
password: 'password',
})
// AWS ECR registry
Template().fromAWSRegistry('ubuntu:22.04', {
accessKeyId: '123',
secretAccessKey: '456',
region: 'eu-west-1',
})
// GCP GCR registry from file path
Template().fromGCPRegistry('ubuntu:22.04', {
serviceAccountJSON: './service_account.json',
})
// GCP GCR registry from object
Template().fromGCPRegistry('ubuntu:22.04', {
serviceAccountJSON: { project_id: '123', private_key_id: '456' },
})
```
**Python**
```py
from e2b import Template
# Generic Docker registry
Template().from_registry(
image="ubuntu:22.04",
username="jirka",
password="password",
)
# AWS ECR registry
Template().from_aws_registry(
image="ubuntu:22.04",
access_key_id="123",
secret_access_key="456",
region="eu-west-1",
)
# GCP GCR registry from file path
Template().from_gcp_registry(
image="ubuntu:22.04",
service_account_json="./service_account.json",
)
# GCP GCR registry from object
Template().from_gcp_registry(
image="ubuntu:22.04",
service_account_json={"project_id": "123", "private_key_id": "456"},
)
```
2025-09-09 19:51:40 +00:00
Mish Ushakov
79d4ce34e2
Templates SDK: simplify exports ( #898 )
...
- Removed unnecessary deep export chains
2025-09-08 08:38:16 -07:00
Mish Ushakov
4a2a6c7051
Add Templates SDK ( #871 )
...
### Merge Templates SDK into E2B SDK.
This PR merges code from Templates SDK to E2B SDK.
**Changelog**
- Added new error classes: BuildError, FileUploadError.
- Added template API endpoints to API Client generation (Python).
- Updated API Clients error handling to throw BuildError in addition to
SandboxError.
- Exported Template and TemplateAsync classes.
- Moved `getRuntime` utility method from api to utils.
- Browser is supported except file operations (COPY). Incompatible
modules are not bundled, using dynamic imports (tar, glob) in supported
environments (Node, Deno, Bun) instead.
- Basic tests were added, subject to expansion in a follow-up PR.
- Breaking: Before, 401 error was raising `SandboxError`, which was
incorrect, now it will raise `AuthenticationError`. I have also changed
the `AuthenticationError` to extend Error class, not `SandboxError`
anymore as it's now thrown by both Sandbox and Template.
**Usage**
JavaScript
```js
import { Template } from 'e2b';
const template = Template()
.fromImage('ubuntu:22.04')
.copy('folder/*.txt', 'folder', { forceUpload: true })
.setEnvs({
ENV_1: 'value1',
ENV_2: 'value2',
})
.runCmd('cat folder/test.txt')
.setWorkdir('/app')
.setStartCmd('echo "Hello, world!"', Template.waitForTimeout('10s'))
await Template.build(template, {
alias: 'test-template',
cpuCount: 1,
memoryMB: 1024,
onBuildLogs: (logEntry) => console.log(logEntry.toString()),
})
```
Python
```py
from e2b import Template
template = (
Template()
.from_image("ubuntu:22.04")
.copy("folder/*.txt", "folder", force_upload=True)
.set_envs(
{
"ENV_1": "value1",
"ENV_2": "value2",
}
)
.run_cmd("cat folder/test.txt")
.set_workdir("/app")
.set_start_cmd("echo 'Hello, world!'", Template.wait_for_timeout("10s"))
)
Template.build(
template,
alias="test-template",
cpu_count=1,
memory_mb=1024,
on_build_logs=lambda log_entry: print(log_entry),
)
```
Python Async
```py
from e2b import AsyncTemplate
template = (
AsyncTemplate()
.from_image("ubuntu:22.04")
.copy("folder/*.txt", "folder", force_upload=True)
.set_envs(
{
"ENV_1": "value1",
"ENV_2": "value2",
}
)
.run_cmd("cat folder/test.txt")
.set_workdir("/app")
.set_start_cmd("echo 'Hello, world!'", Template.wait_for_timeout("10s"))
)
await AsyncTemplate.build(
template,
alias="test-template",
cpu_count=1,
memory_mb=1024,
on_build_logs=lambda log_entry: print(log_entry),
)
```
---
Merge progress
- [x] JavaScript SDK
- [x] Python SDK
- [x] Tests
- [x] Split files for review
2025-09-05 22:00:22 +02:00