Spaces:
Running
Running
terryyz
commited on
Commit
·
7bd5726
1
Parent(s):
d0e3d51
fix
Browse files- sandbox/code_runner.py +1 -3
- sandbox/sandbox_manager.py +2 -4
sandbox/code_runner.py
CHANGED
|
@@ -376,9 +376,7 @@ def run_code_interpreter(code: str, code_language: str | None, code_dependencies
|
|
| 376 |
Args:
|
| 377 |
code (str): The code to be executed.
|
| 378 |
"""
|
| 379 |
-
sandbox = CodeSandbox(
|
| 380 |
-
api_key=E2B_API_KEY,
|
| 381 |
-
)
|
| 382 |
|
| 383 |
sandbox.commands.run("pip install uv",
|
| 384 |
timeout=60 * 3,
|
|
|
|
| 376 |
Args:
|
| 377 |
code (str): The code to be executed.
|
| 378 |
"""
|
| 379 |
+
sandbox = CodeSandbox()
|
|
|
|
|
|
|
| 380 |
|
| 381 |
sandbox.commands.run("pip install uv",
|
| 382 |
timeout=60 * 3,
|
sandbox/sandbox_manager.py
CHANGED
|
@@ -12,7 +12,7 @@ import threading
|
|
| 12 |
from httpcore import ReadTimeout
|
| 13 |
import queue
|
| 14 |
|
| 15 |
-
from .constants import
|
| 16 |
|
| 17 |
|
| 18 |
def create_sandbox(template: str = SANDBOX_TEMPLATE_ID) -> Sandbox:
|
|
@@ -24,7 +24,6 @@ def create_sandbox(template: str = SANDBOX_TEMPLATE_ID) -> Sandbox:
|
|
| 24 |
for attempt in range(1, SANDBOX_RETRY_COUNT + 1):
|
| 25 |
try:
|
| 26 |
return Sandbox(
|
| 27 |
-
api_key=E2B_API_KEY,
|
| 28 |
domain="e2b-foxtrot.dev",
|
| 29 |
template=template,
|
| 30 |
timeout=SANDBOX_TIMEOUT_SECONDS,
|
|
@@ -47,8 +46,7 @@ def reuse_or_create_sandbox(sandbox_id: str | None, template: str = SANDBOX_TEMP
|
|
| 47 |
try:
|
| 48 |
sandbox = Sandbox.connect(
|
| 49 |
sandbox_id=sandbox_id,
|
| 50 |
-
|
| 51 |
-
)
|
| 52 |
if not sandbox.is_running(request_timeout=5):
|
| 53 |
sandbox = None
|
| 54 |
except Exception as e:
|
|
|
|
| 12 |
from httpcore import ReadTimeout
|
| 13 |
import queue
|
| 14 |
|
| 15 |
+
from .constants import SANDBOX_TEMPLATE_ID, SANDBOX_NGINX_PORT, SANDBOX_RETRY_COUNT, SANDBOX_TIMEOUT_SECONDS, INSTALLED_PYPI_PACKAGES
|
| 16 |
|
| 17 |
|
| 18 |
def create_sandbox(template: str = SANDBOX_TEMPLATE_ID) -> Sandbox:
|
|
|
|
| 24 |
for attempt in range(1, SANDBOX_RETRY_COUNT + 1):
|
| 25 |
try:
|
| 26 |
return Sandbox(
|
|
|
|
| 27 |
domain="e2b-foxtrot.dev",
|
| 28 |
template=template,
|
| 29 |
timeout=SANDBOX_TIMEOUT_SECONDS,
|
|
|
|
| 46 |
try:
|
| 47 |
sandbox = Sandbox.connect(
|
| 48 |
sandbox_id=sandbox_id,
|
| 49 |
+
)
|
|
|
|
| 50 |
if not sandbox.is_running(request_timeout=5):
|
| 51 |
sandbox = None
|
| 52 |
except Exception as e:
|