Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix Python 3.8 compatibility; Change Python and Node versions in CI/CD

Tomas Valentad78153ed3854
diff --git a/.github/workflows/python_sdk_tests.yml b/.github/workflows/python_sdk_tests.yml
index ea85bb868..0157190a6 100644
--- a/.github/workflows/python_sdk_tests.yml
+++ b/.github/workflows/python_sdk_tests.yml
@@ -40,6 +40,6 @@ jobs:
run: poetry build
- name: Run tests
- run: poetry run pytest -n 1 --verbose -x
+ run: poetry run pytest -n 4 --verbose -x
env:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 5a593e28e..56309742f 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -126,7 +126,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
- python-version: "3.10"
+ python-version: "3.8"
- name: Install and configure Poetry
uses: snok/install-poetry@v1
@@ -141,7 +141,7 @@ jobs:
- name: Setup Node.js 18
uses: actions/setup-node@v3
with:
- node-version: 18
+ node-version: '18.x'
cache: pnpm
- name: Configure pnpm
diff --git a/.github/workflows/release_candidates.yml b/.github/workflows/release_candidates.yml
index 2e76ef5bd..5e1fb4553 100644
--- a/.github/workflows/release_candidates.yml
+++ b/.github/workflows/release_candidates.yml
@@ -20,11 +20,11 @@ jobs:
- uses: pnpm/action-setup@v3
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
- - name: Setup Node.js 20
+ - name: Setup Node.js 18
uses: actions/setup-node@v4
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') || contains( github.event.pull_request.labels.*.name, 'python-rc') }}
with:
- node-version: 20
+ node-version: '18.x'
registry-url: https://registry.npmjs.org
cache: pnpm
@@ -60,7 +60,7 @@ jobs:
uses: actions/setup-python@v4
if: ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
with:
- python-version: "3.10"
+ python-version: "3.8"
- name: Install and configure Poetry
uses: snok/install-poetry@v1
diff --git a/packages/js-sdk/tests/sandbox/timeout.test.ts b/packages/js-sdk/tests/sandbox/timeout.test.ts
index c02e84286..8b50a8897 100644
--- a/packages/js-sdk/tests/sandbox/timeout.test.ts
+++ b/packages/js-sdk/tests/sandbox/timeout.test.ts
@@ -7,7 +7,7 @@ sandboxTest.skipIf(isDebug)('shorten timeout', async ({ sandbox }) => {
await wait(6000)
- await expect(sandbox.isRunning()).rejects.toThrowError()
+ await expect(sandbox.isRunning({ requestTimeoutMs: 1000 })).rejects.toThrowError()
})
sandboxTest.skipIf(isDebug)('shorten then lenghten timeout', async ({ sandbox }) => {
diff --git a/packages/python-sdk/e2b_connect/client.py b/packages/python-sdk/e2b_connect/client.py
index d1ca6691a..103a3ebdf 100644
--- a/packages/python-sdk/e2b_connect/client.py
+++ b/packages/python-sdk/e2b_connect/client.py
@@ -4,7 +4,7 @@ import struct
from httpcore import ConnectionPool, AsyncConnectionPool, Response
from enum import Flag, Enum
-from typing import Optional, Dict, List, Any, Generator, Tuple
+from typing import Callable, Optional, Dict, List, Any, Generator, Tuple
from google.protobuf import json_format
@@ -314,8 +314,7 @@ class Client:
raise error_for_response(http_resp)
parser = ServerStreamParser(
- codec=self._codec,
- compressor=self._compressor,
+ decode=self._codec.decode,
response_type=self._response_type,
)
@@ -347,8 +346,7 @@ class Client:
raise error_for_response(http_resp)
parser = ServerStreamParser(
- codec=self._codec,
- compressor=self._compressor,
+ decode=self._codec.decode,
response_type=self._response_type,
)
@@ -372,12 +370,10 @@ class ServerStreamParser:
def __init__(
self,
- codec: type[JSONCodec] | type[ProtobufCodec],
- compressor: type[GzipCompressor] | None,
+ decode: Callable,
response_type: Any,
):
- self.codec = codec
- self.compressor = compressor
+ self.decode = decode
self.response_type = response_type
self.buffer: bytes = b""
@@ -389,7 +385,7 @@ class ServerStreamParser:
return buffer
@property
- def header(self) -> tuple[EnvelopeFlags, DataLen]:
+ def header(self) -> Tuple[EnvelopeFlags, DataLen]:
if self._header:
return self._header
@@ -421,5 +417,5 @@ class ServerStreamParser:
return
- yield self.codec.decode(data, msg_type=self.response_type)
+ yield self.decode(data, msg_type=self.response_type)
del self.header
diff --git a/packages/python-sdk/tests/async/sandbox_async/test_timeout.py b/packages/python-sdk/tests/async/sandbox_async/test_timeout.py
index 452f2a40c..0cda4590a 100644
--- a/packages/python-sdk/tests/async/sandbox_async/test_timeout.py
+++ b/packages/python-sdk/tests/async/sandbox_async/test_timeout.py
@@ -12,7 +12,7 @@ async def test_shorten_timeout(async_sandbox: AsyncSandbox):
await async_sandbox.set_timeout(5)
sleep(6)
with pytest.raises(TimeoutException):
- await async_sandbox.is_running()
+ await async_sandbox.is_running(request_timeout=1)
@pytest.mark.skip_debug()
diff --git a/packages/python-sdk/tests/sync/sandbox_sync/test_timeout.py b/packages/python-sdk/tests/sync/sandbox_sync/test_timeout.py
index 306f11334..aac9c57fd 100644
--- a/packages/python-sdk/tests/sync/sandbox_sync/test_timeout.py
+++ b/packages/python-sdk/tests/sync/sandbox_sync/test_timeout.py
@@ -9,7 +9,7 @@ def test_shorten_timeout(sandbox):
sandbox.set_timeout(5)
sleep(6)
with pytest.raises(TimeoutException):
- sandbox.is_running()
+ sandbox.is_running(request_timeout=1)
@pytest.mark.skip_debug()