isolate 0.12.15__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.

Files changed (31) hide show
  1. isolate/_isolate_version.py +2 -2
  2. isolate/backends/common.py +5 -2
  3. isolate/backends/conda.py +1 -1
  4. isolate/backends/pyenv.py +2 -2
  5. isolate/backends/virtualenv.py +1 -1
  6. isolate/connections/_local/_base.py +15 -6
  7. isolate/connections/grpc/_base.py +7 -3
  8. isolate/connections/grpc/agent.py +31 -36
  9. isolate/connections/grpc/definitions/agent_pb2.py +11 -12
  10. isolate/connections/grpc/definitions/agent_pb2.pyi +8 -32
  11. isolate/connections/grpc/definitions/agent_pb2_grpc.py +54 -28
  12. isolate/connections/grpc/definitions/common_pb2.py +18 -21
  13. isolate/connections/grpc/definitions/common_pb2.pyi +17 -84
  14. isolate/connections/grpc/definitions/common_pb2_grpc.py +26 -0
  15. isolate/connections/ipc/_base.py +4 -15
  16. isolate/connections/ipc/agent.py +29 -10
  17. isolate/server/definitions/server.proto +12 -0
  18. isolate/server/definitions/server_pb2.py +19 -17
  19. isolate/server/definitions/server_pb2.pyi +44 -52
  20. isolate/server/definitions/server_pb2_grpc.py +95 -28
  21. isolate/server/health/health_pb2.py +16 -16
  22. isolate/server/health/health_pb2.pyi +6 -14
  23. isolate/server/health/health_pb2_grpc.py +74 -53
  24. isolate/server/server.py +62 -26
  25. {isolate-0.12.15.dist-info → isolate-0.13.0.dist-info}/METADATA +3 -2
  26. isolate-0.13.0.dist-info/RECORD +60 -0
  27. isolate-0.12.15.dist-info/RECORD +0 -60
  28. {isolate-0.12.15.dist-info → isolate-0.13.0.dist-info}/LICENSE +0 -0
  29. {isolate-0.12.15.dist-info → isolate-0.13.0.dist-info}/WHEEL +0 -0
  30. {isolate-0.12.15.dist-info → isolate-0.13.0.dist-info}/entry_points.txt +0 -0
  31. {isolate-0.12.15.dist-info → isolate-0.13.0.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,35 @@
1
1
  # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2
2
  """Client and server classes corresponding to protobuf-defined services."""
3
3
  import grpc
4
+ import warnings
4
5
 
5
6
  from isolate.connections.grpc.definitions import common_pb2 as common__pb2
6
7
  from isolate.server.definitions import server_pb2 as server__pb2
7
8
 
9
+ GRPC_GENERATED_VERSION = '1.64.0'
10
+ GRPC_VERSION = grpc.__version__
11
+ EXPECTED_ERROR_RELEASE = '1.65.0'
12
+ SCHEDULED_RELEASE_DATE = 'June 25, 2024'
13
+ _version_not_supported = False
14
+
15
+ try:
16
+ from grpc._utilities import first_version_is_lower
17
+ _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
18
+ except ImportError:
19
+ _version_not_supported = True
20
+
21
+ if _version_not_supported:
22
+ warnings.warn(
23
+ f'The grpc package installed is at version {GRPC_VERSION},'
24
+ + f' but the generated code in server_pb2_grpc.py depends on'
25
+ + f' grpcio>={GRPC_GENERATED_VERSION}.'
26
+ + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
27
+ + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
28
+ + f' This warning will become an error in {EXPECTED_ERROR_RELEASE},'
29
+ + f' scheduled for release on {SCHEDULED_RELEASE_DATE}.',
30
+ RuntimeWarning
31
+ )
32
+
8
33
 
9
34
  class IsolateStub(object):
10
35
  """Missing associated documentation comment in .proto file."""
@@ -16,10 +41,15 @@ class IsolateStub(object):
16
41
  channel: A grpc.Channel.
17
42
  """
18
43
  self.Run = channel.unary_stream(
19
- "/Isolate/Run",
20
- request_serializer=server__pb2.BoundFunction.SerializeToString,
21
- response_deserializer=common__pb2.PartialRunResult.FromString,
22
- )
44
+ '/Isolate/Run',
45
+ request_serializer=server__pb2.BoundFunction.SerializeToString,
46
+ response_deserializer=common__pb2.PartialRunResult.FromString,
47
+ _registered_method=True)
48
+ self.Submit = channel.unary_unary(
49
+ '/Isolate/Submit',
50
+ request_serializer=server__pb2.SubmitRequest.SerializeToString,
51
+ response_deserializer=server__pb2.SubmitResponse.FromString,
52
+ _registered_method=True)
23
53
 
24
54
 
25
55
  class IsolateServicer(object):
@@ -30,45 +60,55 @@ class IsolateServicer(object):
30
60
  and the result originating from that function.
31
61
  """
32
62
  context.set_code(grpc.StatusCode.UNIMPLEMENTED)
33
- context.set_details("Method not implemented!")
34
- raise NotImplementedError("Method not implemented!")
63
+ context.set_details('Method not implemented!')
64
+ raise NotImplementedError('Method not implemented!')
65
+
66
+ def Submit(self, request, context):
67
+ """Submit a function to be run without waiting for results.
68
+ """
69
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
70
+ context.set_details('Method not implemented!')
71
+ raise NotImplementedError('Method not implemented!')
35
72
 
36
73
 
37
74
  def add_IsolateServicer_to_server(servicer, server):
38
75
  rpc_method_handlers = {
39
- "Run": grpc.unary_stream_rpc_method_handler(
40
- servicer.Run,
41
- request_deserializer=server__pb2.BoundFunction.FromString,
42
- response_serializer=common__pb2.PartialRunResult.SerializeToString,
43
- ),
76
+ 'Run': grpc.unary_stream_rpc_method_handler(
77
+ servicer.Run,
78
+ request_deserializer=server__pb2.BoundFunction.FromString,
79
+ response_serializer=common__pb2.PartialRunResult.SerializeToString,
80
+ ),
81
+ 'Submit': grpc.unary_unary_rpc_method_handler(
82
+ servicer.Submit,
83
+ request_deserializer=server__pb2.SubmitRequest.FromString,
84
+ response_serializer=server__pb2.SubmitResponse.SerializeToString,
85
+ ),
44
86
  }
45
87
  generic_handler = grpc.method_handlers_generic_handler(
46
- "Isolate", rpc_method_handlers
47
- )
88
+ 'Isolate', rpc_method_handlers)
48
89
  server.add_generic_rpc_handlers((generic_handler,))
90
+ server.add_registered_method_handlers('Isolate', rpc_method_handlers)
49
91
 
50
92
 
51
- # This class is part of an EXPERIMENTAL API.
93
+ # This class is part of an EXPERIMENTAL API.
52
94
  class Isolate(object):
53
95
  """Missing associated documentation comment in .proto file."""
54
96
 
55
97
  @staticmethod
56
- def Run(
57
- request,
58
- target,
59
- options=(),
60
- channel_credentials=None,
61
- call_credentials=None,
62
- insecure=False,
63
- compression=None,
64
- wait_for_ready=None,
65
- timeout=None,
66
- metadata=None,
67
- ):
98
+ def Run(request,
99
+ target,
100
+ options=(),
101
+ channel_credentials=None,
102
+ call_credentials=None,
103
+ insecure=False,
104
+ compression=None,
105
+ wait_for_ready=None,
106
+ timeout=None,
107
+ metadata=None):
68
108
  return grpc.experimental.unary_stream(
69
109
  request,
70
110
  target,
71
- "/Isolate/Run",
111
+ '/Isolate/Run',
72
112
  server__pb2.BoundFunction.SerializeToString,
73
113
  common__pb2.PartialRunResult.FromString,
74
114
  options,
@@ -79,4 +119,31 @@ class Isolate(object):
79
119
  wait_for_ready,
80
120
  timeout,
81
121
  metadata,
82
- )
122
+ _registered_method=True)
123
+
124
+ @staticmethod
125
+ def Submit(request,
126
+ target,
127
+ options=(),
128
+ channel_credentials=None,
129
+ call_credentials=None,
130
+ insecure=False,
131
+ compression=None,
132
+ wait_for_ready=None,
133
+ timeout=None,
134
+ metadata=None):
135
+ return grpc.experimental.unary_unary(
136
+ request,
137
+ target,
138
+ '/Isolate/Submit',
139
+ server__pb2.SubmitRequest.SerializeToString,
140
+ server__pb2.SubmitResponse.FromString,
141
+ options,
142
+ channel_credentials,
143
+ insecure,
144
+ call_credentials,
145
+ compression,
146
+ wait_for_ready,
147
+ timeout,
148
+ metadata,
149
+ _registered_method=True)
@@ -1,32 +1,32 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
3
3
  # source: health.proto
4
+ # Protobuf Python Version: 5.26.1
4
5
  """Generated protocol buffer code."""
5
6
  from google.protobuf import descriptor as _descriptor
6
7
  from google.protobuf import descriptor_pool as _descriptor_pool
7
8
  from google.protobuf import symbol_database as _symbol_database
8
9
  from google.protobuf.internal import builder as _builder
9
-
10
10
  # @@protoc_insertion_point(imports)
11
11
 
12
12
  _sym_db = _symbol_database.Default()
13
13
 
14
14
 
15
- DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
16
- b'\n\x0chealth.proto\x12\x0egrpc.health.v1"%\n\x12HealthCheckRequest\x12\x0f\n\x07service\x18\x01 \x01(\t"\xa9\x01\n\x13HealthCheckResponse\x12\x41\n\x06status\x18\x01 \x01(\x0e\x32\x31.grpc.health.v1.HealthCheckResponse.ServingStatus"O\n\rServingStatus\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x0b\n\x07SERVING\x10\x01\x12\x0f\n\x0bNOT_SERVING\x10\x02\x12\x13\n\x0fSERVICE_UNKNOWN\x10\x03\x32\xae\x01\n\x06Health\x12P\n\x05\x43heck\x12".grpc.health.v1.HealthCheckRequest\x1a#.grpc.health.v1.HealthCheckResponse\x12R\n\x05Watch\x12".grpc.health.v1.HealthCheckRequest\x1a#.grpc.health.v1.HealthCheckResponse0\x01\x62\x06proto3'
17
- )
18
15
 
19
- _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
20
- _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "health_pb2", globals())
21
- if _descriptor._USE_C_DESCRIPTORS == False:
22
16
 
23
- DESCRIPTOR._options = None
24
- _HEALTHCHECKREQUEST._serialized_start = 32
25
- _HEALTHCHECKREQUEST._serialized_end = 69
26
- _HEALTHCHECKRESPONSE._serialized_start = 72
27
- _HEALTHCHECKRESPONSE._serialized_end = 241
28
- _HEALTHCHECKRESPONSE_SERVINGSTATUS._serialized_start = 162
29
- _HEALTHCHECKRESPONSE_SERVINGSTATUS._serialized_end = 241
30
- _HEALTH._serialized_start = 244
31
- _HEALTH._serialized_end = 418
17
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0chealth.proto\x12\x0egrpc.health.v1\"%\n\x12HealthCheckRequest\x12\x0f\n\x07service\x18\x01 \x01(\t\"\xa9\x01\n\x13HealthCheckResponse\x12\x41\n\x06status\x18\x01 \x01(\x0e\x32\x31.grpc.health.v1.HealthCheckResponse.ServingStatus\"O\n\rServingStatus\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x0b\n\x07SERVING\x10\x01\x12\x0f\n\x0bNOT_SERVING\x10\x02\x12\x13\n\x0fSERVICE_UNKNOWN\x10\x03\x32\xae\x01\n\x06Health\x12P\n\x05\x43heck\x12\".grpc.health.v1.HealthCheckRequest\x1a#.grpc.health.v1.HealthCheckResponse\x12R\n\x05Watch\x12\".grpc.health.v1.HealthCheckRequest\x1a#.grpc.health.v1.HealthCheckResponse0\x01\x62\x06proto3')
18
+
19
+ _globals = globals()
20
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
21
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'health_pb2', _globals)
22
+ if not _descriptor._USE_C_DESCRIPTORS:
23
+ DESCRIPTOR._loaded_options = None
24
+ _globals['_HEALTHCHECKREQUEST']._serialized_start=32
25
+ _globals['_HEALTHCHECKREQUEST']._serialized_end=69
26
+ _globals['_HEALTHCHECKRESPONSE']._serialized_start=72
27
+ _globals['_HEALTHCHECKRESPONSE']._serialized_end=241
28
+ _globals['_HEALTHCHECKRESPONSE_SERVINGSTATUS']._serialized_start=162
29
+ _globals['_HEALTHCHECKRESPONSE_SERVINGSTATUS']._serialized_end=241
30
+ _globals['_HEALTH']._serialized_start=244
31
+ _globals['_HEALTH']._serialized_end=418
32
32
  # @@protoc_insertion_point(module_scope)
@@ -2,6 +2,7 @@
2
2
  @generated by mypy-protobuf. Do not edit manually!
3
3
  isort:skip_file
4
4
  """
5
+
5
6
  import builtins
6
7
  import google.protobuf.descriptor
7
8
  import google.protobuf.internal.enum_type_wrapper
@@ -16,7 +17,7 @@ else:
16
17
 
17
18
  DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
18
19
 
19
- @typing_extensions.final
20
+ @typing.final
20
21
  class HealthCheckRequest(google.protobuf.message.Message):
21
22
  DESCRIPTOR: google.protobuf.descriptor.Descriptor
22
23
 
@@ -27,13 +28,11 @@ class HealthCheckRequest(google.protobuf.message.Message):
27
28
  *,
28
29
  service: builtins.str = ...,
29
30
  ) -> None: ...
30
- def ClearField(
31
- self, field_name: typing_extensions.Literal["service", b"service"]
32
- ) -> None: ...
31
+ def ClearField(self, field_name: typing.Literal["service", b"service"]) -> None: ...
33
32
 
34
33
  global___HealthCheckRequest = HealthCheckRequest
35
34
 
36
- @typing_extensions.final
35
+ @typing.final
37
36
  class HealthCheckResponse(google.protobuf.message.Message):
38
37
  DESCRIPTOR: google.protobuf.descriptor.Descriptor
39
38
 
@@ -41,12 +40,7 @@ class HealthCheckResponse(google.protobuf.message.Message):
41
40
  ValueType = typing.NewType("ValueType", builtins.int)
42
41
  V: typing_extensions.TypeAlias = ValueType
43
42
 
44
- class _ServingStatusEnumTypeWrapper(
45
- google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[
46
- HealthCheckResponse._ServingStatus.ValueType
47
- ],
48
- builtins.type,
49
- ): # noqa: F821
43
+ class _ServingStatusEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[HealthCheckResponse._ServingStatus.ValueType], builtins.type):
50
44
  DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
51
45
  UNKNOWN: HealthCheckResponse._ServingStatus.ValueType # 0
52
46
  SERVING: HealthCheckResponse._ServingStatus.ValueType # 1
@@ -68,8 +62,6 @@ class HealthCheckResponse(google.protobuf.message.Message):
68
62
  *,
69
63
  status: global___HealthCheckResponse.ServingStatus.ValueType = ...,
70
64
  ) -> None: ...
71
- def ClearField(
72
- self, field_name: typing_extensions.Literal["status", b"status"]
73
- ) -> None: ...
65
+ def ClearField(self, field_name: typing.Literal["status", b"status"]) -> None: ...
74
66
 
75
67
  global___HealthCheckResponse = HealthCheckResponse
@@ -1,9 +1,34 @@
1
1
  # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2
2
  """Client and server classes corresponding to protobuf-defined services."""
3
3
  import grpc
4
+ import warnings
4
5
 
5
6
  from isolate.server.health import health_pb2 as health__pb2
6
7
 
8
+ GRPC_GENERATED_VERSION = '1.64.0'
9
+ GRPC_VERSION = grpc.__version__
10
+ EXPECTED_ERROR_RELEASE = '1.65.0'
11
+ SCHEDULED_RELEASE_DATE = 'June 25, 2024'
12
+ _version_not_supported = False
13
+
14
+ try:
15
+ from grpc._utilities import first_version_is_lower
16
+ _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
17
+ except ImportError:
18
+ _version_not_supported = True
19
+
20
+ if _version_not_supported:
21
+ warnings.warn(
22
+ f'The grpc package installed is at version {GRPC_VERSION},'
23
+ + f' but the generated code in health_pb2_grpc.py depends on'
24
+ + f' grpcio>={GRPC_GENERATED_VERSION}.'
25
+ + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
26
+ + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
27
+ + f' This warning will become an error in {EXPECTED_ERROR_RELEASE},'
28
+ + f' scheduled for release on {SCHEDULED_RELEASE_DATE}.',
29
+ RuntimeWarning
30
+ )
31
+
7
32
 
8
33
  class HealthStub(object):
9
34
  """Missing associated documentation comment in .proto file."""
@@ -15,15 +40,15 @@ class HealthStub(object):
15
40
  channel: A grpc.Channel.
16
41
  """
17
42
  self.Check = channel.unary_unary(
18
- "/grpc.health.v1.Health/Check",
19
- request_serializer=health__pb2.HealthCheckRequest.SerializeToString,
20
- response_deserializer=health__pb2.HealthCheckResponse.FromString,
21
- )
43
+ '/grpc.health.v1.Health/Check',
44
+ request_serializer=health__pb2.HealthCheckRequest.SerializeToString,
45
+ response_deserializer=health__pb2.HealthCheckResponse.FromString,
46
+ _registered_method=True)
22
47
  self.Watch = channel.unary_stream(
23
- "/grpc.health.v1.Health/Watch",
24
- request_serializer=health__pb2.HealthCheckRequest.SerializeToString,
25
- response_deserializer=health__pb2.HealthCheckResponse.FromString,
26
- )
48
+ '/grpc.health.v1.Health/Watch',
49
+ request_serializer=health__pb2.HealthCheckRequest.SerializeToString,
50
+ response_deserializer=health__pb2.HealthCheckResponse.FromString,
51
+ _registered_method=True)
27
52
 
28
53
 
29
54
  class HealthServicer(object):
@@ -32,56 +57,54 @@ class HealthServicer(object):
32
57
  def Check(self, request, context):
33
58
  """Missing associated documentation comment in .proto file."""
34
59
  context.set_code(grpc.StatusCode.UNIMPLEMENTED)
35
- context.set_details("Method not implemented!")
36
- raise NotImplementedError("Method not implemented!")
60
+ context.set_details('Method not implemented!')
61
+ raise NotImplementedError('Method not implemented!')
37
62
 
38
63
  def Watch(self, request, context):
39
64
  """Missing associated documentation comment in .proto file."""
40
65
  context.set_code(grpc.StatusCode.UNIMPLEMENTED)
41
- context.set_details("Method not implemented!")
42
- raise NotImplementedError("Method not implemented!")
66
+ context.set_details('Method not implemented!')
67
+ raise NotImplementedError('Method not implemented!')
43
68
 
44
69
 
45
70
  def add_HealthServicer_to_server(servicer, server):
46
71
  rpc_method_handlers = {
47
- "Check": grpc.unary_unary_rpc_method_handler(
48
- servicer.Check,
49
- request_deserializer=health__pb2.HealthCheckRequest.FromString,
50
- response_serializer=health__pb2.HealthCheckResponse.SerializeToString,
51
- ),
52
- "Watch": grpc.unary_stream_rpc_method_handler(
53
- servicer.Watch,
54
- request_deserializer=health__pb2.HealthCheckRequest.FromString,
55
- response_serializer=health__pb2.HealthCheckResponse.SerializeToString,
56
- ),
72
+ 'Check': grpc.unary_unary_rpc_method_handler(
73
+ servicer.Check,
74
+ request_deserializer=health__pb2.HealthCheckRequest.FromString,
75
+ response_serializer=health__pb2.HealthCheckResponse.SerializeToString,
76
+ ),
77
+ 'Watch': grpc.unary_stream_rpc_method_handler(
78
+ servicer.Watch,
79
+ request_deserializer=health__pb2.HealthCheckRequest.FromString,
80
+ response_serializer=health__pb2.HealthCheckResponse.SerializeToString,
81
+ ),
57
82
  }
58
83
  generic_handler = grpc.method_handlers_generic_handler(
59
- "grpc.health.v1.Health", rpc_method_handlers
60
- )
84
+ 'grpc.health.v1.Health', rpc_method_handlers)
61
85
  server.add_generic_rpc_handlers((generic_handler,))
86
+ server.add_registered_method_handlers('grpc.health.v1.Health', rpc_method_handlers)
62
87
 
63
88
 
64
- # This class is part of an EXPERIMENTAL API.
89
+ # This class is part of an EXPERIMENTAL API.
65
90
  class Health(object):
66
91
  """Missing associated documentation comment in .proto file."""
67
92
 
68
93
  @staticmethod
69
- def Check(
70
- request,
71
- target,
72
- options=(),
73
- channel_credentials=None,
74
- call_credentials=None,
75
- insecure=False,
76
- compression=None,
77
- wait_for_ready=None,
78
- timeout=None,
79
- metadata=None,
80
- ):
94
+ def Check(request,
95
+ target,
96
+ options=(),
97
+ channel_credentials=None,
98
+ call_credentials=None,
99
+ insecure=False,
100
+ compression=None,
101
+ wait_for_ready=None,
102
+ timeout=None,
103
+ metadata=None):
81
104
  return grpc.experimental.unary_unary(
82
105
  request,
83
106
  target,
84
- "/grpc.health.v1.Health/Check",
107
+ '/grpc.health.v1.Health/Check',
85
108
  health__pb2.HealthCheckRequest.SerializeToString,
86
109
  health__pb2.HealthCheckResponse.FromString,
87
110
  options,
@@ -92,25 +115,23 @@ class Health(object):
92
115
  wait_for_ready,
93
116
  timeout,
94
117
  metadata,
95
- )
118
+ _registered_method=True)
96
119
 
97
120
  @staticmethod
98
- def Watch(
99
- request,
100
- target,
101
- options=(),
102
- channel_credentials=None,
103
- call_credentials=None,
104
- insecure=False,
105
- compression=None,
106
- wait_for_ready=None,
107
- timeout=None,
108
- metadata=None,
109
- ):
121
+ def Watch(request,
122
+ target,
123
+ options=(),
124
+ channel_credentials=None,
125
+ call_credentials=None,
126
+ insecure=False,
127
+ compression=None,
128
+ wait_for_ready=None,
129
+ timeout=None,
130
+ metadata=None):
110
131
  return grpc.experimental.unary_stream(
111
132
  request,
112
133
  target,
113
- "/grpc.health.v1.Health/Watch",
134
+ '/grpc.health.v1.Health/Watch',
114
135
  health__pb2.HealthCheckRequest.SerializeToString,
115
136
  health__pb2.HealthCheckResponse.FromString,
116
137
  options,
@@ -121,4 +142,4 @@ class Health(object):
121
142
  wait_for_ready,
122
143
  timeout,
123
144
  metadata,
124
- )
145
+ _registered_method=True)
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 Run(
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
- return self.abort_with_msg(
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
- return self.abort_with_msg(
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
- return self.abort_with_msg(
189
+ raise GRPCException(
185
190
  "At least one environment must be specified for a run!",
186
- context,
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
- return self.abort_with_msg(f"{e}", context)
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
- return self.abort_with_msg(
272
- exception.details(),
273
- context,
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
- return self.abort_with_msg(
285
- str(exception),
286
- context,
287
- code=StatusCode.ABORTED,
288
- )
288
+ raise GRPCException(str(exception), StatusCode.ABORTED)
289
289
  else:
290
- return self.abort_with_msg(
290
+ raise GRPCException(
291
291
  f"An unexpected error occurred: {exception}.",
292
- context,
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
- futures.ThreadPoolExecutor(max_workers=MAX_THREADS),
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.12.15
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 >=1.49
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'