isolate 0.13.3__tar.gz → 0.13.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of isolate might be problematic. Click here for more details.

Files changed (85) hide show
  1. {isolate-0.13.3 → isolate-0.13.5}/PKG-INFO +1 -1
  2. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/_isolate_version.py +2 -2
  3. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/_base.py +0 -2
  4. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/agent.py +17 -6
  5. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/server.py +19 -10
  6. {isolate-0.13.3 → isolate-0.13.5}/src/isolate.egg-info/PKG-INFO +1 -1
  7. {isolate-0.13.3 → isolate-0.13.5}/tests/test_server.py +2 -2
  8. {isolate-0.13.3 → isolate-0.13.5}/.github/workflows/release.yml +0 -0
  9. {isolate-0.13.3 → isolate-0.13.5}/.github/workflows/test.yml +0 -0
  10. {isolate-0.13.3 → isolate-0.13.5}/.gitignore +0 -0
  11. {isolate-0.13.3 → isolate-0.13.5}/.pre-commit-config.yaml +0 -0
  12. {isolate-0.13.3 → isolate-0.13.5}/LICENSE +0 -0
  13. {isolate-0.13.3 → isolate-0.13.5}/README.md +0 -0
  14. {isolate-0.13.3 → isolate-0.13.5}/pyproject.toml +0 -0
  15. {isolate-0.13.3 → isolate-0.13.5}/setup.cfg +0 -0
  16. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/__init__.py +0 -0
  17. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/_version.py +0 -0
  18. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/backends/__init__.py +0 -0
  19. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/backends/_base.py +0 -0
  20. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/backends/common.py +0 -0
  21. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/backends/conda.py +0 -0
  22. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/backends/container.py +0 -0
  23. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/backends/local.py +0 -0
  24. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/backends/pyenv.py +0 -0
  25. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/backends/remote.py +0 -0
  26. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/backends/settings.py +0 -0
  27. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/backends/virtualenv.py +0 -0
  28. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/common/__init__.py +0 -0
  29. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/common/timestamp.py +0 -0
  30. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/__init__.py +0 -0
  31. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/_local/__init__.py +0 -0
  32. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/_local/_base.py +0 -0
  33. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/_local/agent_startup.py +0 -0
  34. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/common.py +0 -0
  35. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/__init__.py +0 -0
  36. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/configuration.py +0 -0
  37. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/definitions/__init__.py +0 -0
  38. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/definitions/agent.proto +0 -0
  39. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/definitions/agent_pb2.py +0 -0
  40. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/definitions/agent_pb2.pyi +0 -0
  41. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/definitions/agent_pb2_grpc.py +0 -0
  42. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/definitions/common.proto +0 -0
  43. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/definitions/common_pb2.py +0 -0
  44. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/definitions/common_pb2.pyi +0 -0
  45. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/definitions/common_pb2_grpc.py +0 -0
  46. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/grpc/interface.py +0 -0
  47. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/ipc/__init__.py +0 -0
  48. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/ipc/_base.py +0 -0
  49. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/connections/ipc/agent.py +0 -0
  50. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/logger.py +0 -0
  51. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/logs.py +0 -0
  52. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/py.typed +0 -0
  53. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/registry.py +0 -0
  54. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/__init__.py +0 -0
  55. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/definitions/__init__.py +0 -0
  56. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/definitions/server.proto +0 -0
  57. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/definitions/server_pb2.py +0 -0
  58. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/definitions/server_pb2.pyi +0 -0
  59. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/definitions/server_pb2_grpc.py +0 -0
  60. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/health/__init__.py +0 -0
  61. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/health/health.proto +0 -0
  62. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/health/health_pb2.py +0 -0
  63. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/health/health_pb2.pyi +0 -0
  64. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/health/health_pb2_grpc.py +0 -0
  65. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/health_server.py +0 -0
  66. {isolate-0.13.3 → isolate-0.13.5}/src/isolate/server/interface.py +0 -0
  67. {isolate-0.13.3 → isolate-0.13.5}/src/isolate.egg-info/SOURCES.txt +0 -0
  68. {isolate-0.13.3 → isolate-0.13.5}/src/isolate.egg-info/dependency_links.txt +0 -0
  69. {isolate-0.13.3 → isolate-0.13.5}/src/isolate.egg-info/entry_points.txt +0 -0
  70. {isolate-0.13.3 → isolate-0.13.5}/src/isolate.egg-info/requires.txt +0 -0
  71. {isolate-0.13.3 → isolate-0.13.5}/src/isolate.egg-info/top_level.txt +0 -0
  72. {isolate-0.13.3 → isolate-0.13.5}/tests/__init__.py +0 -0
  73. {isolate-0.13.3 → isolate-0.13.5}/tests/conftest.py +0 -0
  74. {isolate-0.13.3 → isolate-0.13.5}/tests/test_backends.py +0 -0
  75. {isolate-0.13.3 → isolate-0.13.5}/tests/test_concurrency.py +0 -0
  76. {isolate-0.13.3 → isolate-0.13.5}/tests/test_connections.py +0 -0
  77. {isolate-0.13.3 → isolate-0.13.5}/tests/test_isolate.py +0 -0
  78. {isolate-0.13.3 → isolate-0.13.5}/tests/test_log.py +0 -0
  79. {isolate-0.13.3 → isolate-0.13.5}/tests/test_serialization.py +0 -0
  80. {isolate-0.13.3 → isolate-0.13.5}/tools/Dockerfile +0 -0
  81. {isolate-0.13.3 → isolate-0.13.5}/tools/agent_requirements.txt +0 -0
  82. {isolate-0.13.3 → isolate-0.13.5}/tools/protobuf-requirements.txt +0 -0
  83. {isolate-0.13.3 → isolate-0.13.5}/tools/regen_grpc.py +0 -0
  84. {isolate-0.13.3 → isolate-0.13.5}/tools/requirements.txt +0 -0
  85. {isolate-0.13.3 → isolate-0.13.5}/tools/test_agent_requirements.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: isolate
3
- Version: 0.13.3
3
+ Version: 0.13.5
4
4
  Summary: Managed isolated environments for Python
5
5
  Author-email: Features & Labels <hello@fal.ai>
6
6
  Project-URL: Issues, https://github.com/fal-ai/isolate/issues
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.13.3'
16
- __version_tuple__ = version_tuple = (0, 13, 3)
15
+ __version__ = version = '0.13.5'
16
+ __version_tuple__ = version_tuple = (0, 13, 5)
@@ -16,7 +16,6 @@ from isolate.connections.common import serialize_object
16
16
  from isolate.connections.grpc import agent, definitions
17
17
  from isolate.connections.grpc.configuration import get_default_options
18
18
  from isolate.connections.grpc.interface import from_grpc
19
- from isolate.logger import logger
20
19
  from isolate.logs import LogLevel, LogSource
21
20
 
22
21
 
@@ -149,5 +148,4 @@ class LocalPythonGRPC(PythonExecutionBase[str], GRPCExecutionBase):
149
148
  ]
150
149
 
151
150
  def handle_agent_log(self, line: str, level: LogLevel, source: LogSource) -> None:
152
- logger.log(level, line, source)
153
151
  self.log(line, level=level, source=source)
@@ -1,4 +1,12 @@
1
1
  # agent-requires: isolate[server]
2
+ """
3
+ This file contains the implementation of the gRPC agent. The agent is a
4
+ separate process that is responsible for running the user code in a
5
+ sandboxed environment.
6
+
7
+ This file is referenced by the latest version of the `isolate` package
8
+ but then runs it in the context of the frozen agent built environment.
9
+ """
2
10
 
3
11
  from __future__ import annotations
4
12
 
@@ -17,14 +25,16 @@ from typing import (
17
25
  import grpc
18
26
  from grpc import ServicerContext, StatusCode
19
27
 
20
- from isolate import __version__ as agent_version
28
+ try:
29
+ from isolate import __version__ as agent_version
30
+ except ImportError:
31
+ agent_version = "UNKNOWN"
32
+
21
33
  from isolate.backends.common import sha256_digest_of
22
34
  from isolate.connections.common import SerializationError, serialize_object
23
35
  from isolate.connections.grpc import definitions
24
36
  from isolate.connections.grpc.configuration import get_default_options
25
37
  from isolate.connections.grpc.interface import from_grpc
26
- from isolate.logger import logger
27
- from isolate.logs import LogLevel, LogSource
28
38
 
29
39
 
30
40
  @dataclass
@@ -117,7 +127,7 @@ class AgentServicer(definitions.AgentServicer):
117
127
  # depickling is basically involves code execution from the *user*.
118
128
  function = from_grpc(function)
119
129
  except SerializationError:
120
- self.log(traceback.format_exc())
130
+ traceback.print_exc()
121
131
  raise AbortException(
122
132
  f"The {function_kind} function could not be deserialized."
123
133
  )
@@ -154,7 +164,8 @@ class AgentServicer(definitions.AgentServicer):
154
164
  definition = serialize_object(serialization_method, result)
155
165
  except SerializationError:
156
166
  if stringized_tb:
157
- logger.log(LogLevel.ERROR, stringized_tb, LogSource.BRIDGE)
167
+ print(stringized_tb, file=sys.stderr)
168
+ self.log(traceback.format_exc())
158
169
  raise AbortException(
159
170
  "Error while serializing the execution result "
160
171
  f"(object of type {type(result)})."
@@ -179,7 +190,7 @@ class AgentServicer(definitions.AgentServicer):
179
190
  )
180
191
 
181
192
  def log(self, message: str) -> None:
182
- self._log.write(message)
193
+ self._log.write(message + "\n")
183
194
  self._log.flush()
184
195
 
185
196
  def abort_with_msg(
@@ -9,7 +9,6 @@ from concurrent import futures
9
9
  from concurrent.futures import ThreadPoolExecutor
10
10
  from contextlib import ExitStack, contextmanager
11
11
  from dataclasses import dataclass, field, replace
12
- from functools import partial
13
12
  from queue import Empty as QueueEmpty
14
13
  from queue import Queue
15
14
  from typing import Any, Callable, Iterator, cast
@@ -26,6 +25,7 @@ from isolate.backends.local import LocalPythonEnvironment
26
25
  from isolate.backends.virtualenv import VirtualPythonEnvironment
27
26
  from isolate.connections.grpc import AgentError, LocalPythonGRPC
28
27
  from isolate.connections.grpc.configuration import get_default_options
28
+ from isolate.logger import logger
29
29
  from isolate.logs import Log, LogLevel, LogSource
30
30
  from isolate.server import definitions, health
31
31
  from isolate.server.health_server import HealthServicer
@@ -191,9 +191,10 @@ class IsolateServicer(definitions.IsolateServicer):
191
191
  StatusCode.INVALID_ARGUMENT,
192
192
  )
193
193
 
194
+ log_handler = LogHandler(messages)
194
195
  run_settings = replace(
195
196
  self.default_settings,
196
- log_hook=partial(_add_log_to_queue, messages),
197
+ log_hook=log_handler.handle,
197
198
  serialization_method=request.function.method,
198
199
  )
199
200
 
@@ -390,14 +391,22 @@ def _proxy_to_queue(
390
391
  queue.put_nowait(message)
391
392
 
392
393
 
393
- def _add_log_to_queue(messages: Queue, log: Log) -> None:
394
- grpc_log = cast(definitions.Log, to_grpc(log))
395
- grpc_result = definitions.PartialRunResult(
396
- is_complete=False,
397
- logs=[grpc_log],
398
- result=None,
399
- )
400
- messages.put_nowait(grpc_result)
394
+ @dataclass
395
+ class LogHandler:
396
+ messages: Queue
397
+
398
+ def handle(self, log: Log) -> None:
399
+ logger.log(log.level, log.message, source=log.source)
400
+ self._add_log_to_queue(log)
401
+
402
+ def _add_log_to_queue(self, log: Log) -> None:
403
+ grpc_log = cast(definitions.Log, to_grpc(log))
404
+ grpc_result = definitions.PartialRunResult(
405
+ is_complete=False,
406
+ logs=[grpc_log],
407
+ result=None,
408
+ )
409
+ self.messages.put_nowait(grpc_result)
401
410
 
402
411
 
403
412
  def main() -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: isolate
3
- Version: 0.13.3
3
+ Version: 0.13.5
4
4
  Summary: Managed isolated environments for Python
5
5
  Author-email: Features & Labels <hello@fal.ai>
6
6
  Project-URL: Issues, https://github.com/fal-ai/isolate/issues
@@ -217,7 +217,7 @@ def test_server_builder_error(stub: definitions.IsolateStub, monkeypatch: Any) -
217
217
  assert "Failure during 'pip install': Command" in exc.value.details()
218
218
 
219
219
  raw_logs = [log.message for log in build_logs]
220
- assert "ERROR: Invalid requirement: '$$$$'" in raw_logs
220
+ assert any("ERROR: Invalid requirement: '$$$$'" in raw_log for raw_log in raw_logs)
221
221
 
222
222
 
223
223
  def test_user_logs_immediate(stub: definitions.IsolateStub, monkeypatch: Any) -> None:
@@ -402,7 +402,7 @@ def test_agent_show_logs_from_agent_requirements(
402
402
  assert "Failure during 'pip install': Command" in exc.value.details()
403
403
 
404
404
  raw_logs = [log.message for log in build_logs]
405
- assert "ERROR: Invalid requirement: '$$$$'" in raw_logs
405
+ assert any("ERROR: Invalid requirement: '$$$$'" in raw_log for raw_log in raw_logs)
406
406
 
407
407
 
408
408
  def test_bridge_connection_reuse(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes