Skip to content

Commit

Permalink
fix: try except around new isolate version import (#147)
Browse files Browse the repository at this point in the history
* fix: try except around new isolate version import

* chore: fix tests with newer pip error

---------

Co-authored-by: Ruslan Kuprieiev <[email protected]>
  • Loading branch information
chamini2 and efiop authored Jun 24, 2024
1 parent 5a585fe commit 1b4687b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/isolate/connections/grpc/agent.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# agent-requires: isolate[server]
"""
This file contains the implementation of the gRPC agent. The agent is a
separate process that is responsible for running the user code in a
sandboxed environment.
This file is referenced by the latest version of the `isolate` package
but then runs it in the context of the frozen agent built environment.
"""

from __future__ import annotations

Expand All @@ -17,7 +25,11 @@
import grpc
from grpc import ServicerContext, StatusCode

from isolate import __version__ as agent_version
try:
from isolate import __version__ as agent_version
except ImportError:
agent_version = "UNKNOWN"

from isolate.backends.common import sha256_digest_of
from isolate.connections.common import SerializationError, serialize_object
from isolate.connections.grpc import definitions
Expand Down
4 changes: 2 additions & 2 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def test_server_builder_error(stub: definitions.IsolateStub, monkeypatch: Any) -
assert "Failure during 'pip install': Command" in exc.value.details()

raw_logs = [log.message for log in build_logs]
assert "ERROR: Invalid requirement: '$$$$'" in raw_logs
assert any("ERROR: Invalid requirement: '$$$$'" in raw_log for raw_log in raw_logs)


def test_user_logs_immediate(stub: definitions.IsolateStub, monkeypatch: Any) -> None:
Expand Down Expand Up @@ -402,7 +402,7 @@ def test_agent_show_logs_from_agent_requirements(
assert "Failure during 'pip install': Command" in exc.value.details()

raw_logs = [log.message for log in build_logs]
assert "ERROR: Invalid requirement: '$$$$'" in raw_logs
assert any("ERROR: Invalid requirement: '$$$$'" in raw_log for raw_log in raw_logs)


def test_bridge_connection_reuse(
Expand Down

0 comments on commit 1b4687b

Please sign in to comment.