isolate 0.13.3__py3-none-any.whl → 0.13.5__py3-none-any.whl

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.

@@ -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(
isolate/server/server.py CHANGED
@@ -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
@@ -1,5 +1,5 @@
1
1
  isolate/__init__.py,sha256=uXOKnONs7sXgARNgElwr4_A1sKoA6ACHVEvs3IDiX1M,127
2
- isolate/_isolate_version.py,sha256=VXQPyzbmOGe0nuuEEus9EQY40THABR5BB9WWse8Z8LI,413
2
+ isolate/_isolate_version.py,sha256=nyWjzUs9M1XFc5MLonkyorh4rhe5dHRCj707gnafzf4,413
3
3
  isolate/_version.py,sha256=05pXvy-yr5t3I1m9JMn42Ilzpg7fa8IB2J8a3G7t1cU,274
4
4
  isolate/logger.py,sha256=SehnK6rPx-HDqQHJ3sKWqhDGmD3fTDGBIkjnNQYnFJU,453
5
5
  isolate/logs.py,sha256=R_AHUVYD18z_PhtK_mDWi9Gch79CxmwHY09hUDShtwg,2079
@@ -23,8 +23,8 @@ isolate/connections/_local/__init__.py,sha256=6FtCKRSFBvTvjm5LNlNA-mieKEq3J7DZZR
23
23
  isolate/connections/_local/_base.py,sha256=YGf141VgXErrXYNyRN7sXcts2SemlFEEocZsKmLQfVM,6659
24
24
  isolate/connections/_local/agent_startup.py,sha256=swCs6Q0yVkDw7w-RftizHSMyJDM7DQwuP3TB0qI1ucg,1552
25
25
  isolate/connections/grpc/__init__.py,sha256=tcesLxlC36P6wSg2lBcO2egsJWMbSKwc8zFXhWac3YU,85
26
- isolate/connections/grpc/_base.py,sha256=qyagLVl4BOmkJvbFDLyA2-IZNkXeTRGOgRGGcvcyQwM,5713
27
- isolate/connections/grpc/agent.py,sha256=eXEVHqwqT1p-8V8UEVC5qD5jsTcYaZicaRFLxxmJLec,7757
26
+ isolate/connections/grpc/_base.py,sha256=6cBlJRoKDoJFQudLgkEeUcGVxcIyaAzkB-Zec14hm8k,5639
27
+ isolate/connections/grpc/agent.py,sha256=fZF4-v8WN1qPzFp17UxOX_A3Jq8bXD8Wss-7eNgNoYg,8071
28
28
  isolate/connections/grpc/configuration.py,sha256=50YvGGHA9uyKg74xU_gc73j7bsFk973uIpMhmw2HhxY,788
29
29
  isolate/connections/grpc/interface.py,sha256=yt63kytgXRXrTnjePGJVdXz4LJJVSSrNkJCF1yz6FIE,2270
30
30
  isolate/connections/grpc/definitions/__init__.py,sha256=Z0453Bbjoq-Oxm2Wfi9fae-BFf8YsZwmuh88strmvxo,459
@@ -42,7 +42,7 @@ isolate/connections/ipc/agent.py,sha256=hGlL4x78FhRvMZ4DkVh3dk-EmWQqxHW4LIipgyOk
42
42
  isolate/server/__init__.py,sha256=7R3GuWmxuqe0q28rVqETJN9OCrP_-Svjv9h0NR1GFL0,79
43
43
  isolate/server/health_server.py,sha256=yN7F1Q28DdX8-Zk3gef7XcQEE25XwlHwzV5GBM75aQM,1249
44
44
  isolate/server/interface.py,sha256=nGbjdxrN0p9m1LNdeds8NIoJOwPYW2NM6ktmbhfG4_s,687
45
- isolate/server/server.py,sha256=RIB9wsG_IzR7qZN-7KMTxuZ8iupjufQJxMcLfe-M_QI,14639
45
+ isolate/server/server.py,sha256=rDTiZCGPTgJ5cdrgl6l6xaoV-0twBNm8PzZRsAdii5U,14883
46
46
  isolate/server/definitions/__init__.py,sha256=f_Q3pdjMuZrjgNlbM60btFKiB1Vg8cnVyKEbp0RmU0A,572
47
47
  isolate/server/definitions/server.proto,sha256=-Wv0LAexj2GXfR3TSyGEcd3qkKgpvvQHQBEp7y3f-9Y,1002
48
48
  isolate/server/definitions/server_pb2.py,sha256=tOYlfoh2C5j1PGxAVBuKEtT5s-qeAK7iDaP9sIvOyqw,2293
@@ -53,9 +53,9 @@ isolate/server/health/health.proto,sha256=wE2_QD0OQAblKkEBG7sALLXEOj1mOLKG-FbC4t
53
53
  isolate/server/health/health_pb2.py,sha256=onOdP3M4Tpqhqs2PlGcyfoKe2VVKUEDx5ALeRcObb9A,1899
54
54
  isolate/server/health/health_pb2.pyi,sha256=CPyvxvDzra-1d-mBsukaJnscMUDBaqSACvo9LiXlFzo,2416
55
55
  isolate/server/health/health_pb2_grpc.py,sha256=XgsULrnRBmYIqvKr8eI7bqs6NIea5A0kkqdOOc2JHBY,5303
56
- isolate-0.13.3.dist-info/LICENSE,sha256=427vuyirL5scgBLqA9UWcdnxKrtSGc0u_JfUupk6lAA,11359
57
- isolate-0.13.3.dist-info/METADATA,sha256=o-iPomzdzL4NPtUhM1hze-RI6UJbLl0xyibSks4oOdg,3209
58
- isolate-0.13.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
59
- isolate-0.13.3.dist-info/entry_points.txt,sha256=s3prh2EERaVCbL8R45tfY5WFPZ1TsYOsz305YR7s-Pc,360
60
- isolate-0.13.3.dist-info/top_level.txt,sha256=W9QJBHcq5WXRkbOXf25bvftzFsOZZN4n1DAatdroZrs,8
61
- isolate-0.13.3.dist-info/RECORD,,
56
+ isolate-0.13.5.dist-info/LICENSE,sha256=427vuyirL5scgBLqA9UWcdnxKrtSGc0u_JfUupk6lAA,11359
57
+ isolate-0.13.5.dist-info/METADATA,sha256=4HUFRzvXN8INQYJHZbOk8Ry8xrrIyOmcrfiWhoW4itE,3209
58
+ isolate-0.13.5.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
59
+ isolate-0.13.5.dist-info/entry_points.txt,sha256=s3prh2EERaVCbL8R45tfY5WFPZ1TsYOsz305YR7s-Pc,360
60
+ isolate-0.13.5.dist-info/top_level.txt,sha256=W9QJBHcq5WXRkbOXf25bvftzFsOZZN4n1DAatdroZrs,8
61
+ isolate-0.13.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (70.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5