isolate 0.12.16__py3-none-any.whl → 0.13.0__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.
- isolate/_isolate_version.py +2 -2
- isolate/connections/grpc/_base.py +1 -1
- isolate/connections/grpc/definitions/agent_pb2.py +11 -12
- isolate/connections/grpc/definitions/agent_pb2.pyi +8 -32
- isolate/connections/grpc/definitions/agent_pb2_grpc.py +54 -28
- isolate/connections/grpc/definitions/common_pb2.py +18 -21
- isolate/connections/grpc/definitions/common_pb2.pyi +17 -84
- isolate/connections/grpc/definitions/common_pb2_grpc.py +26 -0
- isolate/server/definitions/server.proto +12 -0
- isolate/server/definitions/server_pb2.py +19 -17
- isolate/server/definitions/server_pb2.pyi +44 -52
- isolate/server/definitions/server_pb2_grpc.py +95 -28
- isolate/server/health/health_pb2.py +16 -16
- isolate/server/health/health_pb2.pyi +6 -14
- isolate/server/health/health_pb2_grpc.py +74 -53
- isolate/server/server.py +62 -26
- {isolate-0.12.16.dist-info → isolate-0.13.0.dist-info}/METADATA +3 -2
- {isolate-0.12.16.dist-info → isolate-0.13.0.dist-info}/RECORD +22 -22
- {isolate-0.12.16.dist-info → isolate-0.13.0.dist-info}/LICENSE +0 -0
- {isolate-0.12.16.dist-info → isolate-0.13.0.dist-info}/WHEEL +0 -0
- {isolate-0.12.16.dist-info → isolate-0.13.0.dist-info}/entry_points.txt +0 -0
- {isolate-0.12.16.dist-info → isolate-0.13.0.dist-info}/top_level.txt +0 -0
isolate/server/server.py
CHANGED
|
@@ -51,6 +51,17 @@ else:
|
|
|
51
51
|
# Number of seconds to observe the queue before checking the termination
|
|
52
52
|
# event.
|
|
53
53
|
_Q_WAIT_DELAY = 0.1
|
|
54
|
+
RUNNER_THREAD_POOL = futures.ThreadPoolExecutor(max_workers=MAX_THREADS)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class GRPCException(Exception):
|
|
58
|
+
def __init__(self, message: str, code: StatusCode = StatusCode.INVALID_ARGUMENT):
|
|
59
|
+
super().__init__(message)
|
|
60
|
+
self.message = message
|
|
61
|
+
self.code = code
|
|
62
|
+
|
|
63
|
+
def __str__(self) -> str:
|
|
64
|
+
return f"{self.code.name}: {self.message}"
|
|
54
65
|
|
|
55
66
|
|
|
56
67
|
@dataclass
|
|
@@ -158,11 +169,11 @@ class BridgeManager:
|
|
|
158
169
|
class IsolateServicer(definitions.IsolateServicer):
|
|
159
170
|
bridge_manager: BridgeManager
|
|
160
171
|
default_settings: IsolateSettings = field(default_factory=IsolateSettings)
|
|
172
|
+
background_tasks: set[futures.Future] = field(default_factory=set)
|
|
161
173
|
|
|
162
|
-
def
|
|
174
|
+
def _run_function(
|
|
163
175
|
self,
|
|
164
176
|
request: definitions.BoundFunction,
|
|
165
|
-
context: ServicerContext,
|
|
166
177
|
) -> Iterator[definitions.PartialRunResult]:
|
|
167
178
|
messages: Queue[definitions.PartialRunResult] = Queue()
|
|
168
179
|
environments = []
|
|
@@ -170,20 +181,14 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
170
181
|
try:
|
|
171
182
|
environments.append((env.force, from_grpc(env)))
|
|
172
183
|
except ValueError:
|
|
173
|
-
|
|
174
|
-
f"Unknown environment kind: {env.kind}",
|
|
175
|
-
context,
|
|
176
|
-
)
|
|
184
|
+
raise GRPCException(f"Unknown environment kind: {env.kind}")
|
|
177
185
|
except TypeError as exc:
|
|
178
|
-
|
|
179
|
-
f"Invalid environment parameter: {str(exc)}.",
|
|
180
|
-
context,
|
|
181
|
-
)
|
|
186
|
+
raise GRPCException(f"Invalid environment: {str(exc)}")
|
|
182
187
|
|
|
183
188
|
if not environments:
|
|
184
|
-
|
|
189
|
+
raise GRPCException(
|
|
185
190
|
"At least one environment must be specified for a run!",
|
|
186
|
-
|
|
191
|
+
StatusCode.INVALID_ARGUMENT,
|
|
187
192
|
)
|
|
188
193
|
|
|
189
194
|
run_settings = replace(
|
|
@@ -226,7 +231,7 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
226
231
|
# but it is just in case.
|
|
227
232
|
environment_paths.append(future.result(timeout=0.1))
|
|
228
233
|
except EnvironmentCreationError as e:
|
|
229
|
-
|
|
234
|
+
raise GRPCException(f"{e}", StatusCode.INVALID_ARGUMENT)
|
|
230
235
|
|
|
231
236
|
primary_path, *inheritance_paths = environment_paths
|
|
232
237
|
inheritance_paths.extend(extra_inheritance_paths)
|
|
@@ -268,10 +273,9 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
268
273
|
# If this is an RPC error, propagate it as is without any
|
|
269
274
|
# further processing.
|
|
270
275
|
if isinstance(exception, grpc.RpcError):
|
|
271
|
-
|
|
272
|
-
exception
|
|
273
|
-
|
|
274
|
-
code=exception.code(),
|
|
276
|
+
raise GRPCException(
|
|
277
|
+
str(exception),
|
|
278
|
+
exception.code(),
|
|
275
279
|
)
|
|
276
280
|
|
|
277
281
|
# Otherwise this is a bug in the agent itself, so needs
|
|
@@ -281,18 +285,50 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
281
285
|
):
|
|
282
286
|
yield from self.log(line, level=LogLevel.ERROR)
|
|
283
287
|
if isinstance(exception, AgentError):
|
|
284
|
-
|
|
285
|
-
str(exception),
|
|
286
|
-
context,
|
|
287
|
-
code=StatusCode.ABORTED,
|
|
288
|
-
)
|
|
288
|
+
raise GRPCException(str(exception), StatusCode.ABORTED)
|
|
289
289
|
else:
|
|
290
|
-
|
|
290
|
+
raise GRPCException(
|
|
291
291
|
f"An unexpected error occurred: {exception}.",
|
|
292
|
-
|
|
293
|
-
code=StatusCode.UNKNOWN,
|
|
292
|
+
StatusCode.UNKNOWN,
|
|
294
293
|
)
|
|
295
294
|
|
|
295
|
+
def _run_function_in_background(
|
|
296
|
+
self,
|
|
297
|
+
bound_function: definitions.BoundFunction,
|
|
298
|
+
) -> None:
|
|
299
|
+
try:
|
|
300
|
+
for _ in self._run_function(bound_function):
|
|
301
|
+
pass
|
|
302
|
+
except GRPCException:
|
|
303
|
+
pass
|
|
304
|
+
|
|
305
|
+
def Submit(
|
|
306
|
+
self,
|
|
307
|
+
request: definitions.SubmitRequest,
|
|
308
|
+
context: ServicerContext,
|
|
309
|
+
) -> definitions.SubmitResponse:
|
|
310
|
+
run_future = RUNNER_THREAD_POOL.submit(
|
|
311
|
+
self._run_function_in_background,
|
|
312
|
+
request.function,
|
|
313
|
+
)
|
|
314
|
+
self.background_tasks.add(run_future)
|
|
315
|
+
|
|
316
|
+
return definitions.SubmitResponse()
|
|
317
|
+
|
|
318
|
+
def Run(
|
|
319
|
+
self,
|
|
320
|
+
request: definitions.BoundFunction,
|
|
321
|
+
context: ServicerContext,
|
|
322
|
+
) -> Iterator[definitions.PartialRunResult]:
|
|
323
|
+
try:
|
|
324
|
+
yield from self._run_function(request)
|
|
325
|
+
except GRPCException as exc:
|
|
326
|
+
return self.abort_with_msg(
|
|
327
|
+
exc.message,
|
|
328
|
+
context,
|
|
329
|
+
code=exc.code,
|
|
330
|
+
)
|
|
331
|
+
|
|
296
332
|
def watch_queue_until_completed(
|
|
297
333
|
self, queue: Queue, is_completed: Callable[[], bool]
|
|
298
334
|
) -> Iterator[definitions.PartialRunResult]:
|
|
@@ -366,7 +402,7 @@ def _add_log_to_queue(messages: Queue, log: Log) -> None:
|
|
|
366
402
|
|
|
367
403
|
def main() -> None:
|
|
368
404
|
server = grpc.server(
|
|
369
|
-
|
|
405
|
+
RUNNER_THREAD_POOL,
|
|
370
406
|
options=get_default_options(),
|
|
371
407
|
)
|
|
372
408
|
with BridgeManager() as bridge_manager:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: isolate
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
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
|
|
@@ -8,7 +8,7 @@ Project-URL: Source, https://github.com/fal-ai/isolate
|
|
|
8
8
|
Requires-Python: >=3.8
|
|
9
9
|
Description-Content-Type: text/markdown
|
|
10
10
|
License-File: LICENSE
|
|
11
|
-
Requires-Dist: grpcio
|
|
11
|
+
Requires-Dist: grpcio ==1.64.0
|
|
12
12
|
Requires-Dist: protobuf
|
|
13
13
|
Requires-Dist: tblib >=1.7.0
|
|
14
14
|
Requires-Dist: platformdirs
|
|
@@ -18,6 +18,7 @@ Requires-Dist: virtualenv >=20.4 ; extra == 'build'
|
|
|
18
18
|
Requires-Dist: PyYAML >=6.0 ; extra == 'build'
|
|
19
19
|
Provides-Extra: dev
|
|
20
20
|
Requires-Dist: isolate[test] ; extra == 'dev'
|
|
21
|
+
Requires-Dist: grpcio-tools ==1.64.0 ; extra == 'dev'
|
|
21
22
|
Provides-Extra: test
|
|
22
23
|
Requires-Dist: isolate[build] ; extra == 'test'
|
|
23
24
|
Requires-Dist: pytest ; extra == 'test'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
isolate/__init__.py,sha256=uXOKnONs7sXgARNgElwr4_A1sKoA6ACHVEvs3IDiX1M,127
|
|
2
|
-
isolate/_isolate_version.py,sha256=
|
|
2
|
+
isolate/_isolate_version.py,sha256=Y4u7iBqF7QJAbpBNSFA2tk5t2mrMGrI-nonxUAhVkPU,413
|
|
3
3
|
isolate/_version.py,sha256=05pXvy-yr5t3I1m9JMn42Ilzpg7fa8IB2J8a3G7t1cU,274
|
|
4
4
|
isolate/logs.py,sha256=R_AHUVYD18z_PhtK_mDWi9Gch79CxmwHY09hUDShtwg,2079
|
|
5
5
|
isolate/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -22,39 +22,39 @@ isolate/connections/_local/__init__.py,sha256=6FtCKRSFBvTvjm5LNlNA-mieKEq3J7DZZR
|
|
|
22
22
|
isolate/connections/_local/_base.py,sha256=nbeIH25wAZn1WDTGXv2HvAfFggzjJAF8GgGS4_iqNoY,6544
|
|
23
23
|
isolate/connections/_local/agent_startup.py,sha256=swCs6Q0yVkDw7w-RftizHSMyJDM7DQwuP3TB0qI1ucg,1552
|
|
24
24
|
isolate/connections/grpc/__init__.py,sha256=tcesLxlC36P6wSg2lBcO2egsJWMbSKwc8zFXhWac3YU,85
|
|
25
|
-
isolate/connections/grpc/_base.py,sha256=
|
|
25
|
+
isolate/connections/grpc/_base.py,sha256=ZCRpmuCTxn3fccooVdAlp4m8346uZm3Ev2sguWn5NWI,5685
|
|
26
26
|
isolate/connections/grpc/agent.py,sha256=LfmLs6B_lLftU-BQ_lm-p3RR-69Ls9hwLz0FpQDts3c,7451
|
|
27
27
|
isolate/connections/grpc/configuration.py,sha256=50YvGGHA9uyKg74xU_gc73j7bsFk973uIpMhmw2HhxY,788
|
|
28
28
|
isolate/connections/grpc/interface.py,sha256=yt63kytgXRXrTnjePGJVdXz4LJJVSSrNkJCF1yz6FIE,2270
|
|
29
29
|
isolate/connections/grpc/definitions/__init__.py,sha256=Z0453Bbjoq-Oxm2Wfi9fae-BFf8YsZwmuh88strmvxo,459
|
|
30
30
|
isolate/connections/grpc/definitions/agent.proto,sha256=Hx11hHc8PKwhWzyasViLeq7JL33KsRex2-iibfWruTw,568
|
|
31
|
-
isolate/connections/grpc/definitions/agent_pb2.py,sha256=
|
|
32
|
-
isolate/connections/grpc/definitions/agent_pb2.pyi,sha256=
|
|
33
|
-
isolate/connections/grpc/definitions/agent_pb2_grpc.py,sha256=
|
|
31
|
+
isolate/connections/grpc/definitions/agent_pb2.py,sha256=F8KVIE1CK542c7_EJKJ40LY8mPZwEqvdmgBPntAMqE0,1424
|
|
32
|
+
isolate/connections/grpc/definitions/agent_pb2.pyi,sha256=kZsyy2PJX21J6n-hPN_bZPMl8UKNXGTNErdqKkmenes,1589
|
|
33
|
+
isolate/connections/grpc/definitions/agent_pb2_grpc.py,sha256=7tm-RB4CTu_YmqvI7QGRll1Z1NmkMWY2Vm-4AHr57X8,3632
|
|
34
34
|
isolate/connections/grpc/definitions/common.proto,sha256=4W1upvDIPezNj-Ab6FVNa-7cA9_N-2xJMJpwytRhpCw,1260
|
|
35
|
-
isolate/connections/grpc/definitions/common_pb2.py,sha256=
|
|
36
|
-
isolate/connections/grpc/definitions/common_pb2.pyi,sha256=
|
|
37
|
-
isolate/connections/grpc/definitions/common_pb2_grpc.py,sha256=
|
|
35
|
+
isolate/connections/grpc/definitions/common_pb2.py,sha256=lkpvpARZbPDrzrVkKJ-4WZWISN2kzrzJPNBUczmvkHU,2464
|
|
36
|
+
isolate/connections/grpc/definitions/common_pb2.pyi,sha256=R-den8f1m7Lv2EnMXb3do3UjpO0Ncp3zSLtnKdW895c,6082
|
|
37
|
+
isolate/connections/grpc/definitions/common_pb2_grpc.py,sha256=EvGJ0LYaWTflBesxg0P1nh_EeWKYKqUVRf0_plMISTs,1123
|
|
38
38
|
isolate/connections/ipc/__init__.py,sha256=j2Mbsph2mRhAWmkMyrtPOz0VG-e75h1OOZLwzs6pXUo,131
|
|
39
39
|
isolate/connections/ipc/_base.py,sha256=Jk715XK2ei3yBpFcwUnFZ0owQMMf5jekZFNh2WlKRT4,8009
|
|
40
40
|
isolate/connections/ipc/agent.py,sha256=hGlL4x78FhRvMZ4DkVh3dk-EmWQqxHW4LIipgyOkw08,7069
|
|
41
41
|
isolate/server/__init__.py,sha256=7R3GuWmxuqe0q28rVqETJN9OCrP_-Svjv9h0NR1GFL0,79
|
|
42
42
|
isolate/server/health_server.py,sha256=yN7F1Q28DdX8-Zk3gef7XcQEE25XwlHwzV5GBM75aQM,1249
|
|
43
43
|
isolate/server/interface.py,sha256=nGbjdxrN0p9m1LNdeds8NIoJOwPYW2NM6ktmbhfG4_s,687
|
|
44
|
-
isolate/server/server.py,sha256=
|
|
44
|
+
isolate/server/server.py,sha256=RIB9wsG_IzR7qZN-7KMTxuZ8iupjufQJxMcLfe-M_QI,14639
|
|
45
45
|
isolate/server/definitions/__init__.py,sha256=f_Q3pdjMuZrjgNlbM60btFKiB1Vg8cnVyKEbp0RmU0A,572
|
|
46
|
-
isolate/server/definitions/server.proto,sha256
|
|
47
|
-
isolate/server/definitions/server_pb2.py,sha256=
|
|
48
|
-
isolate/server/definitions/server_pb2.pyi,sha256=
|
|
49
|
-
isolate/server/definitions/server_pb2_grpc.py,sha256=
|
|
46
|
+
isolate/server/definitions/server.proto,sha256=-Wv0LAexj2GXfR3TSyGEcd3qkKgpvvQHQBEp7y3f-9Y,1002
|
|
47
|
+
isolate/server/definitions/server_pb2.py,sha256=tOYlfoh2C5j1PGxAVBuKEtT5s-qeAK7iDaP9sIvOyqw,2293
|
|
48
|
+
isolate/server/definitions/server_pb2.pyi,sha256=4XpTO6N7Y2oZJYJISUiOgImD6rbaV2zPbGILvQFlbOs,3635
|
|
49
|
+
isolate/server/definitions/server_pb2_grpc.py,sha256=TKqGRLjAOHlW73GxbLGku1sVYcrv9nm9_QgyNtgiBPs,5324
|
|
50
50
|
isolate/server/health/__init__.py,sha256=sy349GRK2YGX9KFKqDxM-jdYtBpMXjZu1QwBkjn0SsM,337
|
|
51
51
|
isolate/server/health/health.proto,sha256=wE2_QD0OQAblKkEBG7sALLXEOj1mOLKG-FbC4tFopWE,455
|
|
52
|
-
isolate/server/health/health_pb2.py,sha256=
|
|
53
|
-
isolate/server/health/health_pb2.pyi,sha256=
|
|
54
|
-
isolate/server/health/health_pb2_grpc.py,sha256=
|
|
55
|
-
isolate-0.
|
|
56
|
-
isolate-0.
|
|
57
|
-
isolate-0.
|
|
58
|
-
isolate-0.
|
|
59
|
-
isolate-0.
|
|
60
|
-
isolate-0.
|
|
52
|
+
isolate/server/health/health_pb2.py,sha256=onOdP3M4Tpqhqs2PlGcyfoKe2VVKUEDx5ALeRcObb9A,1899
|
|
53
|
+
isolate/server/health/health_pb2.pyi,sha256=CPyvxvDzra-1d-mBsukaJnscMUDBaqSACvo9LiXlFzo,2416
|
|
54
|
+
isolate/server/health/health_pb2_grpc.py,sha256=XgsULrnRBmYIqvKr8eI7bqs6NIea5A0kkqdOOc2JHBY,5303
|
|
55
|
+
isolate-0.13.0.dist-info/LICENSE,sha256=427vuyirL5scgBLqA9UWcdnxKrtSGc0u_JfUupk6lAA,11359
|
|
56
|
+
isolate-0.13.0.dist-info/METADATA,sha256=25NDyJJFojeicVDgrRns_gWAertk-gMgQkBAKnNdVgo,3209
|
|
57
|
+
isolate-0.13.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
58
|
+
isolate-0.13.0.dist-info/entry_points.txt,sha256=s3prh2EERaVCbL8R45tfY5WFPZ1TsYOsz305YR7s-Pc,360
|
|
59
|
+
isolate-0.13.0.dist-info/top_level.txt,sha256=W9QJBHcq5WXRkbOXf25bvftzFsOZZN4n1DAatdroZrs,8
|
|
60
|
+
isolate-0.13.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|