seldon-runtime 0.1.1.dev0__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.
- seldon_runtime/__init__.py +3 -0
- seldon_runtime/attempt_bound.py +35 -0
- seldon_runtime/components.py +316 -0
- seldon_runtime/conditional.py +277 -0
- seldon_runtime/contract_versions.py +15 -0
- seldon_runtime/contracts.py +859 -0
- seldon_runtime/deadline.py +51 -0
- seldon_runtime/executor.py +852 -0
- seldon_runtime/gliner_normalize.py +274 -0
- seldon_runtime/instruction_envelope.py +57 -0
- seldon_runtime/json_pointer.py +26 -0
- seldon_runtime/local.py +173 -0
- seldon_runtime/local_models.py +27 -0
- seldon_runtime/local_telemetry.py +108 -0
- seldon_runtime/native_schema.py +33 -0
- seldon_runtime/output_budget.py +166 -0
- seldon_runtime/program_validation.py +137 -0
- seldon_runtime/provider_error.py +42 -0
- seldon_runtime/research_kernels.py +77 -0
- seldon_runtime/runner.py +544 -0
- seldon_runtime/semantic.py +684 -0
- seldon_runtime/telemetry.py +197 -0
- seldon_runtime/templates.py +109 -0
- seldon_runtime/tool_wire.py +116 -0
- seldon_runtime-0.1.1.dev0.dist-info/METADATA +178 -0
- seldon_runtime-0.1.1.dev0.dist-info/RECORD +30 -0
- seldon_runtime-0.1.1.dev0.dist-info/WHEEL +5 -0
- seldon_runtime-0.1.1.dev0.dist-info/licenses/LICENSE +202 -0
- seldon_runtime-0.1.1.dev0.dist-info/licenses/NOTICE +9 -0
- seldon_runtime-0.1.1.dev0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Request-deadline context and the serving/compiler admission failure types."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
from contextlib import contextmanager
|
|
5
|
+
from contextvars import ContextVar
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ServingCapacity(ValueError):
|
|
9
|
+
"""Serving admission refused before any provider dispatch: nothing was sent.
|
|
10
|
+
|
|
11
|
+
Message stays ``provider_capacity`` for existing error surfaces. The distinct
|
|
12
|
+
type lets the serving executor fall back; compiler code never raises it.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(self):
|
|
16
|
+
super().__init__("provider_capacity")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Context-local so forks, judges and nested candidate/fallback calls inherit the
|
|
20
|
+
# enclosing deadline without changing the public executor/provider interface.
|
|
21
|
+
_deadline = ContextVar("compiler_admission_deadline", default=None)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@contextmanager
|
|
25
|
+
def admission_deadline(deadline):
|
|
26
|
+
enclosing = _deadline.get()
|
|
27
|
+
value = min(deadline, enclosing) if enclosing is not None else deadline
|
|
28
|
+
token = _deadline.set(value)
|
|
29
|
+
try:
|
|
30
|
+
yield value
|
|
31
|
+
except TimeoutError as exc:
|
|
32
|
+
# Admission proves nothing was dispatched. If the executor deadline
|
|
33
|
+
# interrupts its asynchronous cleanup, asyncio wraps the cancellation
|
|
34
|
+
# and otherwise hides that retryable outcome behind a generic timeout.
|
|
35
|
+
# Restore only this direct chain; provider timeouts and caller-driven
|
|
36
|
+
# cancellation retain their original meaning.
|
|
37
|
+
cancellation = exc.__cause__
|
|
38
|
+
capacity = getattr(cancellation, "__context__", None)
|
|
39
|
+
if isinstance(cancellation, asyncio.CancelledError) and isinstance(
|
|
40
|
+
capacity, AdmissionFailure
|
|
41
|
+
):
|
|
42
|
+
raise type(capacity)(capacity.admission) from None
|
|
43
|
+
raise
|
|
44
|
+
finally:
|
|
45
|
+
_deadline.reset(token)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class AdmissionFailure(ValueError):
|
|
49
|
+
def __init__(self, diagnostics):
|
|
50
|
+
super().__init__("provider_capacity")
|
|
51
|
+
self.admission = diagnostics
|