chalk-remote-call-python 1.11.0__tar.gz → 1.11.1__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.
- {chalk_remote_call_python-1.11.0/chalk_remote_call_python.egg-info → chalk_remote_call_python-1.11.1}/PKG-INFO +72 -1
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/README.md +71 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-server/src/async_service.rs +20 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-server/src/coalesce.rs +6 -1
- chalk_remote_call_python-1.11.1/chalk-remote-call-rs/chalk-remote-call-server/src/lib.rs +510 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-server/src/metrics.rs +1 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-server/src/python_bridge.rs +116 -5
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-server/src/self_consumer.rs +57 -5
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-server/src/server.rs +67 -5
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-server/src/service.rs +22 -1
- chalk_remote_call_python-1.11.1/chalk_remote_call/__init__.py +17 -0
- chalk_remote_call_python-1.11.1/chalk_remote_call/_native.pyi +26 -0
- chalk_remote_call_python-1.11.1/chalk_remote_call/_version.py +1 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/cli.py +32 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/server.py +20 -1
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1/chalk_remote_call_python.egg-info}/PKG-INFO +72 -1
- chalk_remote_call_python-1.11.0/chalk-remote-call-rs/chalk-remote-call-server/src/lib.rs +0 -120
- chalk_remote_call_python-1.11.0/chalk_remote_call/__init__.py +0 -4
- chalk_remote_call_python-1.11.0/chalk_remote_call/_native.pyi +0 -13
- chalk_remote_call_python-1.11.0/chalk_remote_call/_version.py +0 -1
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/MANIFEST.in +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/Cargo.lock +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/Cargo.toml +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-proto/Cargo.toml +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-proto/src/gen/chalk.auth.v1.rs +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-proto/src/gen/chalk.common.v1.rs +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-proto/src/gen/chalk.runtime.v1.rs +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-proto/src/gen/chalk.runtime.v1.tonic.rs +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-proto/src/gen/chalk.utils.v1.rs +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-proto/src/gen/descriptor.bin +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-proto/src/lib.rs +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-server/Cargo.toml +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-server/build.rs +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/chalk-remote-call-server/src/fnq_client.rs +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk-remote-call-rs/rust-toolchain.toml +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/__main__.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/__init__.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/__init__.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/auth/__init__.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/auth/v1/__init__.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/auth/v1/permissions_pb2.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/auth/v1/permissions_pb2_grpc.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/common/__init__.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/common/v1/__init__.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/common/v1/chalk_error_pb2.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/common/v1/chalk_error_pb2_grpc.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/runtime/__init__.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/runtime/v1/__init__.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/runtime/v1/fnq_consumer_pb2.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/runtime/v1/fnq_consumer_pb2_grpc.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/runtime/v1/remote_python_call_pb2.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/runtime/v1/remote_python_call_pb2_grpc.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/utils/__init__.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/utils/v1/__init__.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/utils/v1/encoding_pb2.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/utils/v1/encoding_pb2_grpc.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/utils/v1/field_change_pb2.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/utils/v1/field_change_pb2_grpc.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/utils/v1/large_pb2.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/utils/v1/large_pb2_grpc.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/utils/v1/sensitive_pb2.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/_gen/chalk/utils/v1/sensitive_pb2_grpc.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/arrow_utils.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/errors.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/handler_loader.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/input_transform.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/logging.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/servicer.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call/tracing.py +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call_python.egg-info/SOURCES.txt +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call_python.egg-info/dependency_links.txt +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call_python.egg-info/entry_points.txt +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call_python.egg-info/requires.txt +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/chalk_remote_call_python.egg-info/top_level.txt +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/pyproject.toml +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/setup.cfg +0 -0
- {chalk_remote_call_python-1.11.0 → chalk_remote_call_python-1.11.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chalk-remote-call-python
|
|
3
|
-
Version: 1.11.
|
|
3
|
+
Version: 1.11.1
|
|
4
4
|
Summary: Chalk remote call Python runtime interface client
|
|
5
5
|
Author: Chalk AI, Inc.
|
|
6
6
|
Project-URL: Homepage, https://chalk.ai
|
|
@@ -186,6 +186,47 @@ def handler(event, context):
|
|
|
186
186
|
serve(handler=handler, port=8080)
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
+
#### Opt-in model-serving readiness
|
|
190
|
+
|
|
191
|
+
Model-serving integrations can pass a native `ServingHandle` to control gRPC
|
|
192
|
+
health and admission of new synchronous or async enqueue requests:
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
import time
|
|
196
|
+
import threading
|
|
197
|
+
|
|
198
|
+
from chalk_remote_call import ServingHandle, serve
|
|
199
|
+
|
|
200
|
+
serving = ServingHandle() # starts NOT_SERVING
|
|
201
|
+
|
|
202
|
+
def model_controller():
|
|
203
|
+
# After loading and verifying the selected model target:
|
|
204
|
+
serving.set_serving(True, lease_expires_at=time.time() + 30)
|
|
205
|
+
|
|
206
|
+
# Before applying another target, stop new admissions and drain requests:
|
|
207
|
+
serving.set_serving(False)
|
|
208
|
+
# After applying and verifying the new target, supply its later expiry.
|
|
209
|
+
serving.set_serving(True, lease_expires_at=time.time() + 30)
|
|
210
|
+
|
|
211
|
+
threading.Thread(target=model_controller, daemon=True).start()
|
|
212
|
+
serve(handler=handler, port=8080, serving_handle=serving)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
The absolute Unix expiry is required when enabling serving and must be no more
|
|
216
|
+
than 300 seconds in the future. Repeating the same expiry cannot renew the
|
|
217
|
+
lease; the target provider must deliver a later expiry first. Rust converts the
|
|
218
|
+
absolute timestamp to a monotonic deadline, expires health and admission without
|
|
219
|
+
further Python calls, and rejects stale or expired timestamps. A new later
|
|
220
|
+
expiry can reopen serving after an update, provided it remains within the
|
|
221
|
+
five-minute bound.
|
|
222
|
+
|
|
223
|
+
This handle only controls gRPC health and admission of new calls. It does not
|
|
224
|
+
cancel or drain calls that passed admission before the state changed. An
|
|
225
|
+
integration must stop new calls and wait for its own admitted requests to drain
|
|
226
|
+
before modifying model state. Omitting `serving_handle` preserves the existing
|
|
227
|
+
always-serving health behavior. The handle is a local control surface; it does
|
|
228
|
+
not authenticate a target descriptor or provide trusted controller delivery.
|
|
229
|
+
|
|
189
230
|
### Invocation context
|
|
190
231
|
|
|
191
232
|
Each Python bridge invocation runs in a fresh `contextvars.Context`. Handler
|
|
@@ -298,3 +339,33 @@ the production JWT layer and Fnq service, then exercise real native-shim executi
|
|
|
298
339
|
lease renewal, result writes, token rotation, and environment isolation. These tests
|
|
299
340
|
skip unless `FNQ_TEST_SERVER` and `REDIS_URL` are set. Deploy the service before
|
|
300
341
|
setting `CHALK_FNQ_CONSUMER_ENDPOINT` on a workload.
|
|
342
|
+
|
|
343
|
+
### Managed model target admission
|
|
344
|
+
|
|
345
|
+
The model deployment API records a typed serving configuration. Its launcher
|
|
346
|
+
passes one private `--model-serving-bootstrap JSON` argument containing the static
|
|
347
|
+
configuration and platform-generated deployment binding. The entire UTF-8
|
|
348
|
+
payload is bounded to 64 KiB. This creates a strict `ServingHandle` before
|
|
349
|
+
importing the user handler and starts the optional
|
|
350
|
+
`chalkcompute.weights.serving.model_runtime.ManagedModelRuntime`. Environment
|
|
351
|
+
feature switches alone cannot activate this path. Managed images
|
|
352
|
+
must install the compatible ChalkCompute serving extra and native runtime.
|
|
353
|
+
Ordinary remote-call handlers do not load this integration.
|
|
354
|
+
|
|
355
|
+
Managed calls carry `x-chalk-model-weight-target`, the exact immutable target
|
|
356
|
+
fingerprint selected by the backend. The native server checks this constraint
|
|
357
|
+
at ingress and again when actual Python execution starts. An expired lease,
|
|
358
|
+
missing target, stale target, or paused update rejects execution. The header is
|
|
359
|
+
an admission constraint and does not replace authentication.
|
|
360
|
+
|
|
361
|
+
Before changing weights the SDK closes admission and waits for native execution
|
|
362
|
+
to finish, including generators and blocking Python tasks after a client
|
|
363
|
+
disconnect. An uncertain managed execution permanently closes the native gate
|
|
364
|
+
until the replica restarts.
|
|
365
|
+
|
|
366
|
+
Managed durable async work requires the dataplane function queue. If its pinned
|
|
367
|
+
target becomes unavailable after delivery, the consumer persists an explicit
|
|
368
|
+
`ModelWeightTargetUnavailable` failed-call result before acknowledging delivery.
|
|
369
|
+
The caller can submit a fresh request against the new target. This avoids
|
|
370
|
+
executing old work against new weights or silently acknowledging it. The
|
|
371
|
+
legacy Redis-list consumer remains available to ordinary handlers.
|
|
@@ -147,6 +147,47 @@ def handler(event, context):
|
|
|
147
147
|
serve(handler=handler, port=8080)
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
+
#### Opt-in model-serving readiness
|
|
151
|
+
|
|
152
|
+
Model-serving integrations can pass a native `ServingHandle` to control gRPC
|
|
153
|
+
health and admission of new synchronous or async enqueue requests:
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
import time
|
|
157
|
+
import threading
|
|
158
|
+
|
|
159
|
+
from chalk_remote_call import ServingHandle, serve
|
|
160
|
+
|
|
161
|
+
serving = ServingHandle() # starts NOT_SERVING
|
|
162
|
+
|
|
163
|
+
def model_controller():
|
|
164
|
+
# After loading and verifying the selected model target:
|
|
165
|
+
serving.set_serving(True, lease_expires_at=time.time() + 30)
|
|
166
|
+
|
|
167
|
+
# Before applying another target, stop new admissions and drain requests:
|
|
168
|
+
serving.set_serving(False)
|
|
169
|
+
# After applying and verifying the new target, supply its later expiry.
|
|
170
|
+
serving.set_serving(True, lease_expires_at=time.time() + 30)
|
|
171
|
+
|
|
172
|
+
threading.Thread(target=model_controller, daemon=True).start()
|
|
173
|
+
serve(handler=handler, port=8080, serving_handle=serving)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The absolute Unix expiry is required when enabling serving and must be no more
|
|
177
|
+
than 300 seconds in the future. Repeating the same expiry cannot renew the
|
|
178
|
+
lease; the target provider must deliver a later expiry first. Rust converts the
|
|
179
|
+
absolute timestamp to a monotonic deadline, expires health and admission without
|
|
180
|
+
further Python calls, and rejects stale or expired timestamps. A new later
|
|
181
|
+
expiry can reopen serving after an update, provided it remains within the
|
|
182
|
+
five-minute bound.
|
|
183
|
+
|
|
184
|
+
This handle only controls gRPC health and admission of new calls. It does not
|
|
185
|
+
cancel or drain calls that passed admission before the state changed. An
|
|
186
|
+
integration must stop new calls and wait for its own admitted requests to drain
|
|
187
|
+
before modifying model state. Omitting `serving_handle` preserves the existing
|
|
188
|
+
always-serving health behavior. The handle is a local control surface; it does
|
|
189
|
+
not authenticate a target descriptor or provide trusted controller delivery.
|
|
190
|
+
|
|
150
191
|
### Invocation context
|
|
151
192
|
|
|
152
193
|
Each Python bridge invocation runs in a fresh `contextvars.Context`. Handler
|
|
@@ -259,3 +300,33 @@ the production JWT layer and Fnq service, then exercise real native-shim executi
|
|
|
259
300
|
lease renewal, result writes, token rotation, and environment isolation. These tests
|
|
260
301
|
skip unless `FNQ_TEST_SERVER` and `REDIS_URL` are set. Deploy the service before
|
|
261
302
|
setting `CHALK_FNQ_CONSUMER_ENDPOINT` on a workload.
|
|
303
|
+
|
|
304
|
+
### Managed model target admission
|
|
305
|
+
|
|
306
|
+
The model deployment API records a typed serving configuration. Its launcher
|
|
307
|
+
passes one private `--model-serving-bootstrap JSON` argument containing the static
|
|
308
|
+
configuration and platform-generated deployment binding. The entire UTF-8
|
|
309
|
+
payload is bounded to 64 KiB. This creates a strict `ServingHandle` before
|
|
310
|
+
importing the user handler and starts the optional
|
|
311
|
+
`chalkcompute.weights.serving.model_runtime.ManagedModelRuntime`. Environment
|
|
312
|
+
feature switches alone cannot activate this path. Managed images
|
|
313
|
+
must install the compatible ChalkCompute serving extra and native runtime.
|
|
314
|
+
Ordinary remote-call handlers do not load this integration.
|
|
315
|
+
|
|
316
|
+
Managed calls carry `x-chalk-model-weight-target`, the exact immutable target
|
|
317
|
+
fingerprint selected by the backend. The native server checks this constraint
|
|
318
|
+
at ingress and again when actual Python execution starts. An expired lease,
|
|
319
|
+
missing target, stale target, or paused update rejects execution. The header is
|
|
320
|
+
an admission constraint and does not replace authentication.
|
|
321
|
+
|
|
322
|
+
Before changing weights the SDK closes admission and waits for native execution
|
|
323
|
+
to finish, including generators and blocking Python tasks after a client
|
|
324
|
+
disconnect. An uncertain managed execution permanently closes the native gate
|
|
325
|
+
until the replica restarts.
|
|
326
|
+
|
|
327
|
+
Managed durable async work requires the dataplane function queue. If its pinned
|
|
328
|
+
target becomes unavailable after delivery, the consumer persists an explicit
|
|
329
|
+
`ModelWeightTargetUnavailable` failed-call result before acknowledging delivery.
|
|
330
|
+
The caller can submit a fresh request against the new target. This avoids
|
|
331
|
+
executing old work against new weights or silently acknowledging it. The
|
|
332
|
+
legacy Redis-list consumer remains available to ordinary handlers.
|
|
@@ -14,6 +14,7 @@ use tracing::{debug, error, instrument, warn};
|
|
|
14
14
|
|
|
15
15
|
use crate::python_bridge::{ChunkBuffer, PythonHandler};
|
|
16
16
|
use crate::service::extract_metadata;
|
|
17
|
+
use crate::ServingState;
|
|
17
18
|
|
|
18
19
|
/// How often the orphan sweeper runs.
|
|
19
20
|
const SWEEP_INTERVAL: Duration = Duration::from_secs(30);
|
|
@@ -88,6 +89,7 @@ pub struct AsyncRemoteCallServiceImpl {
|
|
|
88
89
|
/// rather than silently calling the handler with the wrong shape.
|
|
89
90
|
batching_enabled: bool,
|
|
90
91
|
is_remote_function: bool,
|
|
92
|
+
serving_state: Option<Arc<ServingState>>,
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
impl AsyncRemoteCallServiceImpl {
|
|
@@ -95,6 +97,7 @@ impl AsyncRemoteCallServiceImpl {
|
|
|
95
97
|
python_handler: Arc<PythonHandler>,
|
|
96
98
|
batching_enabled: bool,
|
|
97
99
|
is_remote_function: bool,
|
|
100
|
+
serving_state: Option<Arc<ServingState>>,
|
|
98
101
|
) -> Self {
|
|
99
102
|
let registry: Registry = Arc::new(Mutex::new(HashMap::new()));
|
|
100
103
|
// Runs inside the server's tokio runtime (the service is constructed
|
|
@@ -106,6 +109,7 @@ impl AsyncRemoteCallServiceImpl {
|
|
|
106
109
|
next_id: AtomicU64::new(1),
|
|
107
110
|
batching_enabled,
|
|
108
111
|
is_remote_function,
|
|
112
|
+
serving_state,
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
115
|
}
|
|
@@ -134,6 +138,13 @@ impl AsyncRemoteCallService for AsyncRemoteCallServiceImpl {
|
|
|
134
138
|
&self,
|
|
135
139
|
request: Request<EnqueueRemoteCallRequest>,
|
|
136
140
|
) -> Result<Response<EnqueueRemoteCallResponse>, Status> {
|
|
141
|
+
if self
|
|
142
|
+
.serving_state
|
|
143
|
+
.as_ref()
|
|
144
|
+
.is_some_and(|state| !state.is_serving())
|
|
145
|
+
{
|
|
146
|
+
return Err(Status::unavailable("model is not ready"));
|
|
147
|
+
}
|
|
137
148
|
if self.batching_enabled {
|
|
138
149
|
return Err(Status::unimplemented(
|
|
139
150
|
"async enqueue/poll is not supported when request coalescing is enabled",
|
|
@@ -141,6 +152,7 @@ impl AsyncRemoteCallService for AsyncRemoteCallServiceImpl {
|
|
|
141
152
|
}
|
|
142
153
|
|
|
143
154
|
let metadata = extract_metadata(request.metadata());
|
|
155
|
+
self.python_handler.check_admission(&metadata)?;
|
|
144
156
|
let peer = request
|
|
145
157
|
.remote_addr()
|
|
146
158
|
.map(|a| a.to_string())
|
|
@@ -167,6 +179,14 @@ impl AsyncRemoteCallService for AsyncRemoteCallServiceImpl {
|
|
|
167
179
|
None => Vec::new(),
|
|
168
180
|
};
|
|
169
181
|
|
|
182
|
+
if self
|
|
183
|
+
.serving_state
|
|
184
|
+
.as_ref()
|
|
185
|
+
.is_some_and(|state| !state.is_serving())
|
|
186
|
+
{
|
|
187
|
+
return Err(Status::unavailable("model is not ready"));
|
|
188
|
+
}
|
|
189
|
+
|
|
170
190
|
// Pod-scoped id: the registry only knows about calls accepted by this
|
|
171
191
|
// pod, so a monotonic per-process counter is sufficient for uniqueness.
|
|
172
192
|
let call_id = format!("sg-{}", self.next_id.fetch_add(1, Ordering::Relaxed));
|
|
@@ -61,6 +61,11 @@ impl CoalescingQueue {
|
|
|
61
61
|
})
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
#[cfg(target_os = "linux")]
|
|
65
|
+
pub(crate) fn requires_target(&self) -> bool {
|
|
66
|
+
self.handler.requires_target()
|
|
67
|
+
}
|
|
68
|
+
|
|
64
69
|
/// Enqueue a call. Flushes immediately if the queue hits `max_size`.
|
|
65
70
|
pub async fn submit(self: Arc<Self>, call: BufferedCall) {
|
|
66
71
|
let should_flush = {
|
|
@@ -193,7 +198,7 @@ impl CoalescingQueue {
|
|
|
193
198
|
crate::metrics::Mode::Sync,
|
|
194
199
|
);
|
|
195
200
|
}
|
|
196
|
-
let status =
|
|
201
|
+
let status = e.status();
|
|
197
202
|
for tx in response_txs {
|
|
198
203
|
let _ = tx.send(Err(status.clone())).await;
|
|
199
204
|
}
|