-
Notifications
You must be signed in to change notification settings - Fork 887
sdk: allow envs when connecting to a sandbox #1297
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
base: main
Are you sure you want to change the base?
Changes from all commits
9fc9271
abb593c
d9a5736
50d8641
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| 'e2b': minor | ||
| '@e2b/python-sdk': minor | ||
| --- | ||
|
|
||
| Add support for passing environment variables when reconnecting to a sandbox via `Sandbox.connect()`. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,6 +247,7 @@ def create( | |
| def connect( | ||
| self, | ||
| timeout: Optional[int] = None, | ||
| envs: Optional[Dict[str, str]] = None, | ||
| **opts: Unpack[ApiParams], | ||
| ) -> Self: | ||
| """ | ||
|
|
@@ -257,6 +258,8 @@ def connect( | |
|
|
||
| :param timeout: Timeout for the sandbox in **seconds** | ||
| For running sandboxes, the timeout will update only if the new timeout is longer than the existing one. | ||
| :param envs: Custom environment variables to set in the sandbox on reconnect. | ||
| Merged into the sandbox environment and applied to processes started after resume. | ||
| :return: A running sandbox instance | ||
|
|
||
| @example | ||
|
|
@@ -276,6 +279,7 @@ def connect( | |
| def connect( | ||
| sandbox_id: str, | ||
| timeout: Optional[int] = None, | ||
| envs: Optional[Dict[str, str]] = None, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Adding Useful? React with 👍 / 👎. |
||
| **opts: Unpack[ApiParams], | ||
| ) -> "Sandbox": | ||
| """ | ||
|
|
@@ -287,6 +291,8 @@ def connect( | |
| :param sandbox_id: Sandbox ID | ||
| :param timeout: Timeout for the sandbox in **seconds**. | ||
| For running sandboxes, the timeout will update only if the new timeout is longer than the existing one. | ||
| :param envs: Custom environment variables to set in the sandbox on reconnect. | ||
| Merged into the sandbox environment and applied to processes started after resume. | ||
| :return: A running sandbox instance | ||
|
|
||
| @example | ||
|
|
@@ -304,6 +310,7 @@ def connect( | |
| def connect( | ||
| self, | ||
| timeout: Optional[int] = None, | ||
| envs: Optional[Dict[str, str]] = None, | ||
| **opts: Unpack[ApiParams], | ||
| ) -> Self: | ||
| """ | ||
|
|
@@ -314,6 +321,8 @@ def connect( | |
|
|
||
| :param timeout: Timeout for the sandbox in **seconds**. | ||
| For running sandboxes, the timeout will update only if the new timeout is longer than the existing one. | ||
| :param envs: Custom environment variables to set in the sandbox on reconnect. | ||
| Merged into the sandbox environment and applied to processes started after resume. | ||
| :return: A running sandbox instance | ||
|
|
||
| @example | ||
|
|
@@ -328,6 +337,7 @@ def connect( | |
| SandboxApi._cls_connect( | ||
| sandbox_id=self.sandbox_id, | ||
| timeout=timeout, | ||
| envs=envs, | ||
| **self.connection_config.get_api_params(**opts), | ||
| ) | ||
|
|
||
|
|
@@ -848,11 +858,13 @@ def _cls_connect_sandbox( | |
| cls, | ||
| sandbox_id: str, | ||
| timeout: Optional[int] = None, | ||
| envs: Optional[Dict[str, str]] = None, | ||
| **opts: Unpack[ApiParams], | ||
| ) -> Self: | ||
| sandbox = SandboxApi._cls_connect( | ||
| sandbox_id=sandbox_id, | ||
| timeout=timeout, | ||
| envs=envs, | ||
| **opts, | ||
| ) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The async class-style API has the same regression:
AsyncSandbox.connect("...", envs={...})routes through_cls_connect_sandbox, which doesn't acceptenvs, soenvsremains inoptsand is passed toConnectionConfig(..., **opts), causingTypeError: unexpected keyword argument 'envs'. As a result, the newly added async classmethodenvsparameter fails at runtime.Useful? React with 👍 / 👎.