tigrbl-runtime 0.4.4.dev1__py3-none-any.whl → 0.4.4.dev7__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.
- tigrbl_runtime/channel/_asgi_webtransport.py +18 -2
- tigrbl_runtime/executors/__init__.py +1 -3
- tigrbl_runtime/executors/_invoke_support.py +0 -54
- tigrbl_runtime/executors/kernel_executor.py +63 -1
- tigrbl_runtime/executors/packed.py +29 -0
- tigrbl_runtime/executors/phase.py +1 -1
- tigrbl_runtime/executors/{invoke.py → phase_runner.py} +17 -111
- tigrbl_runtime/runtime/runtime.py +15 -56
- {tigrbl_runtime-0.4.4.dev1.dist-info → tigrbl_runtime-0.4.4.dev7.dist-info}/METADATA +2 -4
- {tigrbl_runtime-0.4.4.dev1.dist-info → tigrbl_runtime-0.4.4.dev7.dist-info}/RECORD +13 -27
- tigrbl_runtime/handle.py +0 -19
- tigrbl_runtime/rust/__init__.py +0 -67
- tigrbl_runtime/rust/_fallback.py +0 -73
- tigrbl_runtime/rust/_load_rust.py +0 -22
- tigrbl_runtime/rust/availability.py +0 -5
- tigrbl_runtime/rust/backend.py +0 -62
- tigrbl_runtime/rust/callbacks.py +0 -43
- tigrbl_runtime/rust/codec.py +0 -27
- tigrbl_runtime/rust/compile.py +0 -15
- tigrbl_runtime/rust/errors.py +0 -27
- tigrbl_runtime/rust/request.py +0 -27
- tigrbl_runtime/rust/response.py +0 -22
- tigrbl_runtime/rust/runtime.py +0 -62
- tigrbl_runtime/rust/trace.py +0 -29
- {tigrbl_runtime-0.4.4.dev1.dist-info → tigrbl_runtime-0.4.4.dev7.dist-info}/WHEEL +0 -0
- {tigrbl_runtime-0.4.4.dev1.dist-info → tigrbl_runtime-0.4.4.dev7.dist-info}/licenses/LICENSE +0 -0
- {tigrbl_runtime-0.4.4.dev1.dist-info → tigrbl_runtime-0.4.4.dev7.dist-info}/licenses/NOTICE +0 -0
|
@@ -114,8 +114,11 @@ def _iter_webtransport_hooks(ctx: Any) -> tuple[HookSpec, ...]:
|
|
|
114
114
|
hooks: list[HookSpec] = []
|
|
115
115
|
seen: set[int] = set()
|
|
116
116
|
for owner_key in ("app", "router"):
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
getter = getattr(ctx, "get", None)
|
|
118
|
+
owner = getter(owner_key) if callable(getter) else None
|
|
119
|
+
if owner is None:
|
|
120
|
+
owner = getattr(ctx, owner_key, None)
|
|
121
|
+
for item in _iter_hook_candidates(getattr(owner, "hooks", ())):
|
|
119
122
|
if id(item) in seen:
|
|
120
123
|
continue
|
|
121
124
|
if isinstance(item, HookSpec):
|
|
@@ -128,6 +131,19 @@ def _iter_webtransport_hooks(ctx: Any) -> tuple[HookSpec, ...]:
|
|
|
128
131
|
return tuple(sorted(hooks, key=lambda hook: int(getattr(hook, "order", 0))))
|
|
129
132
|
|
|
130
133
|
|
|
134
|
+
def _iter_hook_candidates(value: Any) -> tuple[Any, ...]:
|
|
135
|
+
if value is None:
|
|
136
|
+
return ()
|
|
137
|
+
if isinstance(value, Mapping):
|
|
138
|
+
return tuple(value.values())
|
|
139
|
+
if isinstance(value, (list, tuple, set, frozenset)):
|
|
140
|
+
return tuple(value)
|
|
141
|
+
data = getattr(value, "__dict__", None)
|
|
142
|
+
if isinstance(data, Mapping):
|
|
143
|
+
return tuple(data.values())
|
|
144
|
+
return ()
|
|
145
|
+
|
|
146
|
+
|
|
131
147
|
async def _call_webtransport_hook(hook: HookSpec, ctx: Any) -> None:
|
|
132
148
|
fn = hook.fn
|
|
133
149
|
try:
|
|
@@ -11,9 +11,7 @@ _EXPORTS = {
|
|
|
11
11
|
"PackedPlanExecutor": "packed",
|
|
12
12
|
"NumbaPackedPlanExecutor": "numba_packed",
|
|
13
13
|
"_Ctx": "types",
|
|
14
|
-
"_invoke": "
|
|
15
|
-
"resolve_phase_chains": "invoke",
|
|
16
|
-
"invoke_op": "invoke",
|
|
14
|
+
"_invoke": "phase_runner",
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
__all__ = list(_EXPORTS)
|
|
@@ -4,17 +4,13 @@ import logging
|
|
|
4
4
|
from typing import Any, Mapping, Optional, Union
|
|
5
5
|
|
|
6
6
|
from tigrbl_kernel.helpers import _g, _run_chain
|
|
7
|
-
from tigrbl_ops_oltp.crud import ops as _crud_ops
|
|
8
|
-
from tigrbl_ops_oltp.crud.helpers.model import _coerce_pk_value, _single_pk_name
|
|
9
7
|
|
|
10
8
|
from .types import AsyncSession, PhaseChains, Session, _Ctx
|
|
11
9
|
|
|
12
10
|
logger = logging.getLogger(__name__)
|
|
13
11
|
|
|
14
|
-
_OPVIEW_CACHE_ATTR = "__tigrbl_cached_opviews__"
|
|
15
12
|
_LOG_NOISE_REDUCED = False
|
|
16
13
|
_NOISY_TIGRBL_LOGGERS = (
|
|
17
|
-
"tigrbl_ops_oltp.crud.helpers.model",
|
|
18
14
|
"tigrbl_core._spec.column_spec",
|
|
19
15
|
)
|
|
20
16
|
|
|
@@ -112,54 +108,6 @@ async def _maybe_await(value: Any) -> Any:
|
|
|
112
108
|
return value
|
|
113
109
|
|
|
114
110
|
|
|
115
|
-
async def _crud_result_fallback(ctx: _Ctx, current_result: Any) -> Any:
|
|
116
|
-
alias = str(ctx.get("op") or "").lower()
|
|
117
|
-
if alias not in {"read", "update", "replace"}:
|
|
118
|
-
return current_result
|
|
119
|
-
|
|
120
|
-
model = ctx.get("model")
|
|
121
|
-
db = ctx.get("db")
|
|
122
|
-
if not isinstance(model, type) or db is None:
|
|
123
|
-
return current_result
|
|
124
|
-
|
|
125
|
-
try:
|
|
126
|
-
pk_name = _single_pk_name(model)
|
|
127
|
-
except Exception:
|
|
128
|
-
return current_result
|
|
129
|
-
|
|
130
|
-
payload = ctx.get("payload")
|
|
131
|
-
path_params = ctx.get("path_params")
|
|
132
|
-
ident = None
|
|
133
|
-
if isinstance(path_params, Mapping) and pk_name in path_params:
|
|
134
|
-
ident = path_params.get(pk_name)
|
|
135
|
-
elif isinstance(payload, Mapping) and pk_name in payload:
|
|
136
|
-
ident = payload.get(pk_name)
|
|
137
|
-
if ident is None:
|
|
138
|
-
return current_result
|
|
139
|
-
|
|
140
|
-
ident = _coerce_pk_value(model, ident)
|
|
141
|
-
|
|
142
|
-
if alias == "read":
|
|
143
|
-
needs_fallback = current_result is None
|
|
144
|
-
if isinstance(current_result, Mapping):
|
|
145
|
-
if pk_name not in current_result:
|
|
146
|
-
needs_fallback = True
|
|
147
|
-
else:
|
|
148
|
-
data_keys = [k for k in current_result.keys() if k != pk_name]
|
|
149
|
-
if data_keys and all(current_result.get(k) is None for k in data_keys):
|
|
150
|
-
needs_fallback = True
|
|
151
|
-
if not needs_fallback:
|
|
152
|
-
return current_result
|
|
153
|
-
return await _crud_ops.read(model, ident, db)
|
|
154
|
-
|
|
155
|
-
if current_result is None and isinstance(payload, Mapping):
|
|
156
|
-
if alias == "update":
|
|
157
|
-
return await _crud_ops.update(model, ident, dict(payload), db)
|
|
158
|
-
return await _crud_ops.replace(model, ident, dict(payload), db)
|
|
159
|
-
|
|
160
|
-
return current_result
|
|
161
|
-
|
|
162
|
-
|
|
163
111
|
async def _rollback_if_owned(
|
|
164
112
|
db: Union[Session, AsyncSession, None],
|
|
165
113
|
owns_tx: bool,
|
|
@@ -181,8 +129,6 @@ async def _rollback_if_owned(
|
|
|
181
129
|
|
|
182
130
|
|
|
183
131
|
__all__ = [
|
|
184
|
-
"_OPVIEW_CACHE_ATTR",
|
|
185
|
-
"_crud_result_fallback",
|
|
186
132
|
"_default_status_for_alias",
|
|
187
133
|
"_maybe_await",
|
|
188
134
|
"_normalize_result_payload",
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from collections.abc import Mapping, MutableMapping
|
|
4
|
+
from types import SimpleNamespace
|
|
3
5
|
from typing import Any
|
|
4
6
|
|
|
5
|
-
from .
|
|
7
|
+
from .phase_runner import _invoke
|
|
6
8
|
from .types import _Ctx
|
|
7
9
|
from tigrbl_typing.phases import canonicalize_phase_input as normalize_phase
|
|
8
10
|
|
|
@@ -28,3 +30,63 @@ async def _run_phase_chain(self, ctx: _Ctx, phases: Any) -> None:
|
|
|
28
30
|
rv = step(ctx)
|
|
29
31
|
if hasattr(rv, "__await__"):
|
|
30
32
|
await rv
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def resolve_phase_chains(model: type, alias: str) -> Mapping[str, list[Any]]:
|
|
36
|
+
"""Resolve executable phase chains for a model operation."""
|
|
37
|
+
from tigrbl_kernel import build_phase_chains
|
|
38
|
+
|
|
39
|
+
return build_phase_chains(model, alias) or {}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
async def invoke_op(
|
|
43
|
+
*,
|
|
44
|
+
request: Any = None,
|
|
45
|
+
db: Any = None,
|
|
46
|
+
model: type,
|
|
47
|
+
alias: str,
|
|
48
|
+
ctx: MutableMapping[str, Any] | None = None,
|
|
49
|
+
) -> Any:
|
|
50
|
+
"""Resolve operation metadata and execute its phase lifecycle."""
|
|
51
|
+
from tigrbl_kernel import _default_kernel, get_cached_specs
|
|
52
|
+
|
|
53
|
+
seed_ctx: MutableMapping[str, Any] = dict(ctx or {})
|
|
54
|
+
seed_ctx.setdefault("model", model)
|
|
55
|
+
seed_ctx.setdefault("op", alias)
|
|
56
|
+
seed_ctx.setdefault("method", alias)
|
|
57
|
+
if request is not None:
|
|
58
|
+
seed_ctx.setdefault("request", request)
|
|
59
|
+
if db is not None:
|
|
60
|
+
seed_ctx.setdefault("db", db)
|
|
61
|
+
if seed_ctx.get("env") is None:
|
|
62
|
+
seed_ctx["env"] = SimpleNamespace(method=alias)
|
|
63
|
+
seed_ctx.setdefault("skip_egress", True)
|
|
64
|
+
|
|
65
|
+
app_ref = (
|
|
66
|
+
getattr(request, "app", None)
|
|
67
|
+
or seed_ctx.get("app")
|
|
68
|
+
or seed_ctx.get("router")
|
|
69
|
+
or model
|
|
70
|
+
)
|
|
71
|
+
seed_ctx.setdefault("app", app_ref)
|
|
72
|
+
seed_ctx.setdefault("router", seed_ctx.get("router") or app_ref)
|
|
73
|
+
|
|
74
|
+
if seed_ctx.get("specs") is None:
|
|
75
|
+
specs = get_cached_specs(model)
|
|
76
|
+
if specs is not None:
|
|
77
|
+
seed_ctx["specs"] = specs
|
|
78
|
+
|
|
79
|
+
if seed_ctx.get("opview") is None:
|
|
80
|
+
try:
|
|
81
|
+
seed_ctx["opview"] = _default_kernel.get_opview(app_ref, model, alias)
|
|
82
|
+
except Exception:
|
|
83
|
+
# Some call paths rely only on specs/schemas and can proceed without
|
|
84
|
+
# a compiled opview.
|
|
85
|
+
pass
|
|
86
|
+
|
|
87
|
+
return await _invoke(
|
|
88
|
+
request=request,
|
|
89
|
+
db=db,
|
|
90
|
+
phases=resolve_phase_chains(model, alias),
|
|
91
|
+
ctx=seed_ctx,
|
|
92
|
+
)
|
|
@@ -1431,6 +1431,33 @@ class PackedPlanExecutor(ExecutorBase):
|
|
|
1431
1431
|
hot.absent_fields = tuple(absent)
|
|
1432
1432
|
hot.used_default_factory = tuple(used_default)
|
|
1433
1433
|
|
|
1434
|
+
@staticmethod
|
|
1435
|
+
def _publish_compiled_payload(ctx: _Ctx, hot: HotCtx) -> None:
|
|
1436
|
+
field_names = tuple(getattr(hot, "slot_field_names", ()) or ())
|
|
1437
|
+
values = getattr(hot, "assembled_slot_values", None)
|
|
1438
|
+
present = getattr(hot, "assembled_slot_present", None)
|
|
1439
|
+
if not field_names or values is None or present is None:
|
|
1440
|
+
return
|
|
1441
|
+
payload = {
|
|
1442
|
+
field_names[idx]: values[idx]
|
|
1443
|
+
for idx in range(min(len(field_names), len(values), len(present)))
|
|
1444
|
+
if present[idx]
|
|
1445
|
+
}
|
|
1446
|
+
if not payload:
|
|
1447
|
+
return
|
|
1448
|
+
ctx["payload"] = payload
|
|
1449
|
+
ctx["in_data"] = payload
|
|
1450
|
+
ctx["data"] = payload
|
|
1451
|
+
|
|
1452
|
+
@staticmethod
|
|
1453
|
+
def _publish_route_payload(ctx: _Ctx, hot: HotCtx) -> None:
|
|
1454
|
+
payload = getattr(hot, "route_payload", None)
|
|
1455
|
+
if not isinstance(payload, Mapping):
|
|
1456
|
+
return
|
|
1457
|
+
ctx["payload"] = dict(payload)
|
|
1458
|
+
ctx["in_data"] = dict(payload)
|
|
1459
|
+
ctx["data"] = dict(payload)
|
|
1460
|
+
|
|
1434
1461
|
def _resolve_segments_for_program(
|
|
1435
1462
|
self, packed: PackedKernel, program_id: int
|
|
1436
1463
|
) -> tuple[tuple[int, ...], tuple[int, ...]]:
|
|
@@ -2699,6 +2726,7 @@ class PackedPlanExecutor(ExecutorBase):
|
|
|
2699
2726
|
if hot is None:
|
|
2700
2727
|
return
|
|
2701
2728
|
await self._prepare_compiled_input(ctx, hot, packed, program_id, hot_op_plan)
|
|
2729
|
+
self._publish_route_payload(ctx, hot)
|
|
2702
2730
|
if hot.compiled_input_ready:
|
|
2703
2731
|
plan = self._resolve_compiled_param_plan(
|
|
2704
2732
|
ctx,
|
|
@@ -2707,6 +2735,7 @@ class PackedPlanExecutor(ExecutorBase):
|
|
|
2707
2735
|
hot.param_shape_id,
|
|
2708
2736
|
)
|
|
2709
2737
|
self._compiled_validate_and_assemble(ctx, hot, plan)
|
|
2738
|
+
self._publish_compiled_payload(ctx, hot)
|
|
2710
2739
|
current_phase = ""
|
|
2711
2740
|
for phase_name, invoke_kind, call, dep, is_async in compiled_steps:
|
|
2712
2741
|
if phase_name != current_phase:
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# tigrbl/runtime/executor/invoke.py
|
|
2
1
|
from __future__ import annotations
|
|
3
2
|
|
|
4
3
|
from types import SimpleNamespace
|
|
@@ -6,14 +5,11 @@ from typing import Any, Mapping, MutableMapping, Optional, Union
|
|
|
6
5
|
|
|
7
6
|
from tigrbl_atoms.atoms.sys._db import _in_transaction
|
|
8
7
|
from tigrbl_atoms.types import build_error_ctx, error_phase_for, select_error_edge
|
|
9
|
-
from tigrbl_kernel import build_phase_chains, get_cached_specs, _default_kernel
|
|
10
8
|
from tigrbl_kernel.helpers import _g, _run_chain
|
|
11
9
|
from tigrbl_typing.status import create_standardized_error, to_rpc_error_payload
|
|
12
10
|
|
|
13
11
|
from ..config.constants import CTX_SKIP_PERSIST_FLAG
|
|
14
12
|
from ._invoke_support import (
|
|
15
|
-
_OPVIEW_CACHE_ATTR as _OPVIEW_CACHE_ATTR,
|
|
16
|
-
_crud_result_fallback as _crud_result_fallback,
|
|
17
13
|
_default_status_for_alias as _default_status_for_alias,
|
|
18
14
|
_maybe_await as _maybe_await,
|
|
19
15
|
_normalize_result_payload as _normalize_result_payload,
|
|
@@ -25,11 +21,6 @@ from ._invoke_support import (
|
|
|
25
21
|
from .types import AsyncSession, PhaseChains, Request, Session, _Ctx
|
|
26
22
|
|
|
27
23
|
|
|
28
|
-
def resolve_phase_chains(model: type, alias: str) -> Mapping[str, list[Any]]:
|
|
29
|
-
"""Resolve executable phase chains for a model operation."""
|
|
30
|
-
return build_phase_chains(model, alias) or {}
|
|
31
|
-
|
|
32
|
-
|
|
33
24
|
async def _invoke(
|
|
34
25
|
*,
|
|
35
26
|
request: Optional[Request],
|
|
@@ -59,46 +50,10 @@ async def _invoke(
|
|
|
59
50
|
obj = getattr(ctx, "obj", None)
|
|
60
51
|
if obj is not None:
|
|
61
52
|
ctx.model = type(obj)
|
|
62
|
-
if getattr(ctx, "opview", None) is None:
|
|
63
|
-
model = getattr(ctx, "model", None)
|
|
64
|
-
alias = getattr(ctx, "op", None)
|
|
65
|
-
specs = ctx.get("specs")
|
|
66
|
-
if (
|
|
67
|
-
isinstance(model, type)
|
|
68
|
-
and isinstance(alias, str)
|
|
69
|
-
and isinstance(specs, Mapping)
|
|
70
|
-
):
|
|
71
|
-
try:
|
|
72
|
-
cached_views = getattr(model, _OPVIEW_CACHE_ATTR, None)
|
|
73
|
-
if not isinstance(cached_views, dict):
|
|
74
|
-
cached_views = {}
|
|
75
|
-
setattr(model, _OPVIEW_CACHE_ATTR, cached_views)
|
|
76
|
-
|
|
77
|
-
cached_view = cached_views.get(alias)
|
|
78
|
-
if cached_view is not None:
|
|
79
|
-
ctx.opview = cached_view
|
|
80
|
-
else:
|
|
81
|
-
from tigrbl_kernel.opview_compiler import compile_opview_from_specs
|
|
82
|
-
|
|
83
|
-
op_spec = next(
|
|
84
|
-
(
|
|
85
|
-
sp
|
|
86
|
-
for sp in (
|
|
87
|
-
getattr(getattr(model, "ops", None), "all", ()) or ()
|
|
88
|
-
)
|
|
89
|
-
if getattr(sp, "alias", None) == alias
|
|
90
|
-
),
|
|
91
|
-
None,
|
|
92
|
-
)
|
|
93
|
-
if op_spec is None:
|
|
94
|
-
op_spec = SimpleNamespace(alias=alias)
|
|
95
|
-
compiled_view = compile_opview_from_specs(specs, op_spec)
|
|
96
|
-
cached_views[alias] = compiled_view
|
|
97
|
-
ctx.opview = compiled_view
|
|
98
|
-
except Exception:
|
|
99
|
-
pass
|
|
100
53
|
skip_persist: bool = bool(ctx.get(CTX_SKIP_PERSIST_FLAG) or ctx.get("skip_persist"))
|
|
54
|
+
skip_ingress: bool = bool(ctx.get("skip_ingress"))
|
|
101
55
|
skip_egress: bool = bool(ctx.get("skip_egress"))
|
|
56
|
+
skip_post_commit: bool = bool(ctx.get("skip_post_commit"))
|
|
102
57
|
if not callable(ctx.get("rpc_error_builder")):
|
|
103
58
|
ctx["rpc_error_builder"] = lambda exc: to_rpc_error_payload(
|
|
104
59
|
create_standardized_error(exc)
|
|
@@ -156,15 +111,16 @@ async def _invoke(
|
|
|
156
111
|
return
|
|
157
112
|
raise create_standardized_error(exc)
|
|
158
113
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
114
|
+
if not skip_ingress:
|
|
115
|
+
await _run_phase(
|
|
116
|
+
"INGRESS_BEGIN", allow_flush=False, allow_commit=False, in_tx=False
|
|
117
|
+
)
|
|
118
|
+
await _run_phase(
|
|
119
|
+
"INGRESS_PARSE", allow_flush=False, allow_commit=False, in_tx=False
|
|
120
|
+
)
|
|
121
|
+
await _run_phase(
|
|
122
|
+
"INGRESS_ROUTE", allow_flush=False, allow_commit=False, in_tx=False
|
|
123
|
+
)
|
|
168
124
|
await _run_phase("PRE_TX_BEGIN", allow_flush=False, allow_commit=False, in_tx=False)
|
|
169
125
|
|
|
170
126
|
if not skip_persist:
|
|
@@ -231,7 +187,6 @@ async def _invoke(
|
|
|
231
187
|
current_result = getattr(ctx, "obj", None)
|
|
232
188
|
|
|
233
189
|
current_result = _unwrap_ctx_result(current_result)
|
|
234
|
-
current_result = await _crud_result_fallback(ctx, current_result)
|
|
235
190
|
|
|
236
191
|
if isinstance(rpc_error, Mapping):
|
|
237
192
|
ctx["result"] = None
|
|
@@ -254,7 +209,10 @@ async def _invoke(
|
|
|
254
209
|
else:
|
|
255
210
|
setattr(response_obj, "result", ctx.get("result"))
|
|
256
211
|
|
|
257
|
-
|
|
212
|
+
if not skip_post_commit:
|
|
213
|
+
await _run_phase(
|
|
214
|
+
"POST_COMMIT", allow_flush=True, allow_commit=False, in_tx=False
|
|
215
|
+
)
|
|
258
216
|
|
|
259
217
|
if not skip_egress:
|
|
260
218
|
await _run_phase(
|
|
@@ -321,56 +279,4 @@ async def _invoke(
|
|
|
321
279
|
ctx["result"] = result
|
|
322
280
|
return result
|
|
323
281
|
|
|
324
|
-
|
|
325
|
-
async def invoke_op(
|
|
326
|
-
*,
|
|
327
|
-
request: Any = None,
|
|
328
|
-
db: Any = None,
|
|
329
|
-
model: type,
|
|
330
|
-
alias: str,
|
|
331
|
-
ctx: Optional[MutableMapping[str, Any]] = None,
|
|
332
|
-
) -> Any:
|
|
333
|
-
"""Resolve phases and execute an operation through runtime invocation."""
|
|
334
|
-
seed_ctx: MutableMapping[str, Any] = dict(ctx or {})
|
|
335
|
-
seed_ctx.setdefault("model", model)
|
|
336
|
-
seed_ctx.setdefault("op", alias)
|
|
337
|
-
seed_ctx.setdefault("method", alias)
|
|
338
|
-
if request is not None:
|
|
339
|
-
seed_ctx.setdefault("request", request)
|
|
340
|
-
if db is not None:
|
|
341
|
-
seed_ctx.setdefault("db", db)
|
|
342
|
-
if seed_ctx.get("env") is None:
|
|
343
|
-
seed_ctx["env"] = SimpleNamespace(method=alias)
|
|
344
|
-
seed_ctx.setdefault("skip_egress", True)
|
|
345
|
-
|
|
346
|
-
app_ref = (
|
|
347
|
-
getattr(request, "app", None)
|
|
348
|
-
or seed_ctx.get("app")
|
|
349
|
-
or seed_ctx.get("router")
|
|
350
|
-
or model
|
|
351
|
-
)
|
|
352
|
-
seed_ctx.setdefault("app", app_ref)
|
|
353
|
-
seed_ctx.setdefault("router", seed_ctx.get("router") or app_ref)
|
|
354
|
-
|
|
355
|
-
if seed_ctx.get("specs") is None:
|
|
356
|
-
specs = get_cached_specs(model)
|
|
357
|
-
if specs is not None:
|
|
358
|
-
seed_ctx["specs"] = specs
|
|
359
|
-
|
|
360
|
-
if seed_ctx.get("opview") is None:
|
|
361
|
-
try:
|
|
362
|
-
seed_ctx["opview"] = _default_kernel.get_opview(app_ref, model, alias)
|
|
363
|
-
except Exception:
|
|
364
|
-
# Some call paths rely only on specs/schemas and can proceed without
|
|
365
|
-
# a compiled opview.
|
|
366
|
-
pass
|
|
367
|
-
|
|
368
|
-
return await _invoke(
|
|
369
|
-
request=request,
|
|
370
|
-
db=db,
|
|
371
|
-
phases=resolve_phase_chains(model, alias),
|
|
372
|
-
ctx=seed_ctx,
|
|
373
|
-
)
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
__all__ = ["_invoke", "resolve_phase_chains", "invoke_op"]
|
|
282
|
+
__all__ = ["_invoke"]
|
|
@@ -10,15 +10,18 @@ from tigrbl_runtime.executors import (
|
|
|
10
10
|
NumbaPackedPlanExecutor,
|
|
11
11
|
PackedPlanExecutor,
|
|
12
12
|
)
|
|
13
|
-
from tigrbl_runtime.rust import (
|
|
14
|
-
ExecutionBackend,
|
|
15
|
-
RustBackendConfig,
|
|
16
|
-
reject_rust_backend,
|
|
17
|
-
RustBindingsUnavailableError,
|
|
18
|
-
)
|
|
19
13
|
from .base import RuntimeBase
|
|
20
14
|
|
|
21
15
|
|
|
16
|
+
def _normalize_execution_backend(value: Any) -> str:
|
|
17
|
+
lowered = str(value or "auto").strip().lower()
|
|
18
|
+
if not lowered:
|
|
19
|
+
return "auto"
|
|
20
|
+
if lowered in {"auto", "python"}:
|
|
21
|
+
return lowered
|
|
22
|
+
raise ValueError(f"unsupported execution backend: {value!r}")
|
|
23
|
+
|
|
24
|
+
|
|
22
25
|
class Runtime(RuntimeBase):
|
|
23
26
|
"""Runtime orchestrator for kernel + executors."""
|
|
24
27
|
|
|
@@ -27,30 +30,16 @@ class Runtime(RuntimeBase):
|
|
|
27
30
|
kernel: Kernel | None = None,
|
|
28
31
|
*,
|
|
29
32
|
default_executor: str = "packed",
|
|
30
|
-
kernel_backend: str
|
|
31
|
-
atoms_backend: str
|
|
32
|
-
executor_backend: str
|
|
33
|
-
rust_backend: RustBackendConfig | None = None,
|
|
33
|
+
kernel_backend: str = "auto",
|
|
34
|
+
atoms_backend: str = "auto",
|
|
35
|
+
executor_backend: str = "python",
|
|
34
36
|
) -> None:
|
|
35
37
|
resolved_kernel = kernel if kernel is not None else _kernel()
|
|
36
38
|
super().__init__(kernel=resolved_kernel)
|
|
37
39
|
self.default_executor = default_executor
|
|
38
|
-
self.kernel_backend =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
)
|
|
42
|
-
self.atoms_backend = reject_rust_backend(
|
|
43
|
-
atoms_backend,
|
|
44
|
-
label="atoms_backend",
|
|
45
|
-
)
|
|
46
|
-
self.executor_backend = reject_rust_backend(
|
|
47
|
-
executor_backend,
|
|
48
|
-
label="executor_backend",
|
|
49
|
-
)
|
|
50
|
-
self.rust_backend = rust_backend or RustBackendConfig(
|
|
51
|
-
backend=self.executor_backend
|
|
52
|
-
)
|
|
53
|
-
reject_rust_backend(self.rust_backend, label="rust_backend")
|
|
40
|
+
self.kernel_backend = _normalize_execution_backend(kernel_backend)
|
|
41
|
+
self.atoms_backend = _normalize_execution_backend(atoms_backend)
|
|
42
|
+
self.executor_backend = _normalize_execution_backend(executor_backend)
|
|
54
43
|
self.register_executor(PackedPlanExecutor())
|
|
55
44
|
self.register_executor(NumbaPackedPlanExecutor())
|
|
56
45
|
|
|
@@ -66,36 +55,6 @@ class Runtime(RuntimeBase):
|
|
|
66
55
|
except Exception:
|
|
67
56
|
return 0
|
|
68
57
|
|
|
69
|
-
def _uses_rust_executor(self) -> bool:
|
|
70
|
-
return False
|
|
71
|
-
|
|
72
|
-
def _compile_rust(self, app: Any) -> tuple[Any, Any]:
|
|
73
|
-
del app
|
|
74
|
-
raise RustBindingsUnavailableError(
|
|
75
|
-
"Runtime._compile_rust is unavailable. "
|
|
76
|
-
"Tigrbl runtime execution is Python-only."
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
def rust_handle(self, app: Any) -> Any:
|
|
80
|
-
del app
|
|
81
|
-
raise RustBindingsUnavailableError(
|
|
82
|
-
"Runtime.rust_handle is unavailable. "
|
|
83
|
-
"Tigrbl runtime execution is Python-only."
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
def execute_rust(
|
|
87
|
-
self,
|
|
88
|
-
envelope: Any,
|
|
89
|
-
*,
|
|
90
|
-
app: Any | None = None,
|
|
91
|
-
handle: Any | None = None,
|
|
92
|
-
) -> dict[str, Any]:
|
|
93
|
-
del envelope, app, handle
|
|
94
|
-
raise RustBindingsUnavailableError(
|
|
95
|
-
"Runtime.execute_rust is unavailable. "
|
|
96
|
-
"Tigrbl runtime execution is Python-only."
|
|
97
|
-
)
|
|
98
|
-
|
|
99
58
|
def compile(self, *args: Any, **kwargs: Any) -> tuple[Any, Any | None]:
|
|
100
59
|
if args:
|
|
101
60
|
app = args[0]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tigrbl-runtime
|
|
3
|
-
Version: 0.4.4.
|
|
3
|
+
Version: 0.4.4.dev7
|
|
4
4
|
Summary: Runtime pipeline helpers and execution bridge surfaces for Tigrbl ASGI applications, transports, and operation dispatch.
|
|
5
5
|
License: Apache License
|
|
6
6
|
Version 2.0, January 2004
|
|
@@ -311,8 +311,7 @@ pip install tigrbl-runtime
|
|
|
311
311
|
`tigrbl-runtime` owns the `foundational framework package` boundary. It should be installed when you need this package's focused responsibility without assuming every other Tigrbl workspace package is present.
|
|
312
312
|
|
|
313
313
|
Implementation orientation:
|
|
314
|
-
- `tigrbl_runtime`: callbacks, channel/, config/, executors/,
|
|
315
|
-
- `tigrbl_runtime/rust/`: deprecated compatibility shims only; Rust execution is unavailable.
|
|
314
|
+
- `tigrbl_runtime`: callbacks, channel/, config/, executors/, protocol/, runtime/, transactions, webhooks
|
|
316
315
|
|
|
317
316
|
Runtime authoring BCP:
|
|
318
317
|
- Do use this package for runtime-owned routing, request execution, transport-unit execution, framing atoms, transport channels, transaction helpers, and kernel integration.
|
|
@@ -325,7 +324,6 @@ Runtime authoring BCP:
|
|
|
325
324
|
|
|
326
325
|
- Import roots: `tigrbl_runtime`.
|
|
327
326
|
- Public symbols: `Runtime`, `RuntimeBase`.
|
|
328
|
-
- Rust-named symbols live only under `tigrbl_runtime.rust` as deprecated compatibility shims and must not be used for execution.
|
|
329
327
|
- Workspace dependencies: [`tigrbl-typing`](https://pypi.org/project/tigrbl-typing/), [`tigrbl-kernel`](https://pypi.org/project/tigrbl-kernel/), [`tigrbl-atoms`](https://pypi.org/project/tigrbl-atoms/), [`tigrbl-base`](https://pypi.org/project/tigrbl-base/), [`tigrbl-core`](https://pypi.org/project/tigrbl-core/).
|
|
330
328
|
- External runtime dependencies: `numba>=0.61.2`.
|
|
331
329
|
|
|
@@ -7,27 +7,26 @@ tigrbl_runtime/channel/_asgi_jsonrpc.py,sha256=E4GpyW-2RX9npiDjlXEE5eHsHAWQ67U4g
|
|
|
7
7
|
tigrbl_runtime/channel/_asgi_receive.py,sha256=Ry1YDQVHMJWxe9DhsnTABHiO9vLb0AuukD9cMiHtk5w,2076
|
|
8
8
|
tigrbl_runtime/channel/_asgi_scope.py,sha256=zMiSh-zmEKI-sHoFbz1Wog2IgdInGXSJLe2K_VyFMHk,2322
|
|
9
9
|
tigrbl_runtime/channel/_asgi_send.py,sha256=iieRuVfyA6NmOx9ehim9wEWezFfw2Jzjub6UW5CEdi0,9290
|
|
10
|
-
tigrbl_runtime/channel/_asgi_webtransport.py,sha256
|
|
10
|
+
tigrbl_runtime/channel/_asgi_webtransport.py,sha256=-0J5qTCTFB1GRUTKgbWpmCfIYbse4h2sasEY4CexPhw,12009
|
|
11
11
|
tigrbl_runtime/channel/asgi.py,sha256=_y0arRyNeQkzmsl7mcrTMp_1SXWDatvU23ztp8tgsCE,2307
|
|
12
12
|
tigrbl_runtime/channel/capabilities.py,sha256=x6pURZvGu8dM_uIMmBXhFKM4K3gtpiQocPMfhU9MtCA,1802
|
|
13
13
|
tigrbl_runtime/channel/websocket.py,sha256=IDf_KLmCoSXcKk5m389sZ2IT80orstgPZs_uF8fmT3A,4076
|
|
14
14
|
tigrbl_runtime/config/__init__.py,sha256=7XuWvyAIgrZVHy54NWP8DFwf1kDBNa_RPOutWkN5b6s,82
|
|
15
15
|
tigrbl_runtime/config/constants.py,sha256=sJcU6X7IxkJ6BRerHZ4nPg7_CDEQVPLLGo87lK9SdXs,120
|
|
16
|
-
tigrbl_runtime/executors/__init__.py,sha256=
|
|
17
|
-
tigrbl_runtime/executors/_invoke_support.py,sha256=
|
|
16
|
+
tigrbl_runtime/executors/__init__.py,sha256=DzCnjd5VhhOclzEJ1mt2wTzZV94Ybm9RV4sbJHElRY0,674
|
|
17
|
+
tigrbl_runtime/executors/_invoke_support.py,sha256=A2P8bdXCJAxbJsJ-LuiFdtZ76pnl5NDSF7c-O_o2_sw,4047
|
|
18
18
|
tigrbl_runtime/executors/base.py,sha256=MUpvOCDPIgy-w3S5llFKcq09YPSUtfjVRXGPhMrwQZA,908
|
|
19
19
|
tigrbl_runtime/executors/ctx/__init__.py,sha256=bdMJn6yyclPFaeJGAOnnCdLpcOrkXFQaabVv2U6kxNY,299
|
|
20
20
|
tigrbl_runtime/executors/ctx/context.py,sha256=f0NB9fJhGrTs12cjCZ_-yq2OImo_EmK-gH0CcACa23c,12594
|
|
21
21
|
tigrbl_runtime/executors/ctx/hot.py,sha256=H8_tm617PLiQiyXosRIDUKeoETOncQm3oUp4uurVGsI,1076
|
|
22
22
|
tigrbl_runtime/executors/ctx/hot_namespaces.py,sha256=yMeD3DJ4cyNMTU7-r5xzXvZJTR7GsbyCa1_sgVk0jxM,16124
|
|
23
23
|
tigrbl_runtime/executors/ctx/hot_state.py,sha256=CjC_DXtYE93G7nsTT4AVD6VCrvE1k5qiNXXiUVhK-QE,7492
|
|
24
|
-
tigrbl_runtime/executors/
|
|
25
|
-
tigrbl_runtime/executors/kernel_executor.py,sha256=o-3ZeLdGTP_pWQ7oHJ3G2gahuA28EFVL3vGuK7Yur9g,808
|
|
24
|
+
tigrbl_runtime/executors/kernel_executor.py,sha256=QXMyZspKQX8CF7mjEecmor0NJprig4PO35qhAFsxh7g,2734
|
|
26
25
|
tigrbl_runtime/executors/numba_packed.py,sha256=ICntbbFDO05NOuW6F2sU0pre0Z2ipiJrgp9WOeU_Jd8,2930
|
|
27
|
-
tigrbl_runtime/executors/packed.py,sha256=
|
|
28
|
-
tigrbl_runtime/executors/phase.py,sha256=
|
|
26
|
+
tigrbl_runtime/executors/packed.py,sha256=Ti-JqQqHnN6n2eKFGCc6tZqN4qx-QZQoOGxeAkNzDPE,142289
|
|
27
|
+
tigrbl_runtime/executors/phase.py,sha256=9HxJUbdh1-FLvhb6cGe3sOaz_Ej6xydDT9hUpVi2ERQ,1057
|
|
28
|
+
tigrbl_runtime/executors/phase_runner.py,sha256=OshCk29OFn-5IMBgLO5_23zLHsewgk_tXOMAXgBZNrg,9856
|
|
29
29
|
tigrbl_runtime/executors/types.py,sha256=r4GsnCFXXvbi8XA2vVl8rP9hCsV0W3r_HyTnQq0DS04,1127
|
|
30
|
-
tigrbl_runtime/handle.py,sha256=_uUXn0Gq7NgqoVTLKSGAxVCCQev7u9Fe1vN0lHGjScI,507
|
|
31
30
|
tigrbl_runtime/runtime/__init__.py,sha256=oy7pj5NN8inWiXhkdU5htTxxqYcsbgkeEBRbRIIz_hc,652
|
|
32
31
|
tigrbl_runtime/runtime/_typing_aliases.py,sha256=sOkj2em2t7nzf1z6VD7U5AHGxhDqmfdcSOzLl-mZXcc,108
|
|
33
32
|
tigrbl_runtime/runtime/base.py,sha256=ejEE0JIoYC41OcLm4ikUR23MfITVs9ruSv2EftX1-R4,882
|
|
@@ -35,24 +34,11 @@ tigrbl_runtime/runtime/channel.py,sha256=Tv7gtaYpOsxm87Blbd89UBO0IpBrZuvVGT4a-zv
|
|
|
35
34
|
tigrbl_runtime/runtime/exceptions.py,sha256=7IygQ9pnWsBgnFXQSzmr6tsBsVKSc4vJb0oV8NS_v4s,199
|
|
36
35
|
tigrbl_runtime/runtime/hook_types.py,sha256=4q2ZbcGtORVuRxh46620wBZiTI9jGJPznKWagN9UXic,230
|
|
37
36
|
tigrbl_runtime/runtime/response.py,sha256=SCJKN-hyjeVoKmlLdf_N7RkTyx_f6noCx-fSgLG6eqI,1012
|
|
38
|
-
tigrbl_runtime/runtime/runtime.py,sha256=
|
|
37
|
+
tigrbl_runtime/runtime/runtime.py,sha256=gCIuwJkj_DmPzVfXAIpp5-3hEilv_yfyYvLDjrcBF7E,3624
|
|
39
38
|
tigrbl_runtime/runtime/system.py,sha256=5GWVYZscff1nUymCKJAEa7VYbqIeFfppV3seYyDxlvA,4301
|
|
40
|
-
tigrbl_runtime/rust/__init__.py,sha256=B7FG4zexmaAckX8MIQ3YTETDPDvVuX6wA9Uo1wp2Tb0,1684
|
|
41
|
-
tigrbl_runtime/rust/_fallback.py,sha256=G91FexwOB2SuDTLdio9si2B9StncCRkH-h8jDj4VfqQ,2042
|
|
42
|
-
tigrbl_runtime/rust/_load_rust.py,sha256=gNhmL3O1MPoTpocuGdxyLrsK9O-dwj9C1J7izGMjT5Y,506
|
|
43
|
-
tigrbl_runtime/rust/availability.py,sha256=Yw5EszEURlnxpvnXFnQecwFshp7yIUe-00Hcq3FoxoY,162
|
|
44
|
-
tigrbl_runtime/rust/backend.py,sha256=JqbygPSq_M0ipWpH9PgD7BjXVi8AzaXoVOMHQ3P7JeI,1828
|
|
45
|
-
tigrbl_runtime/rust/callbacks.py,sha256=SmOCxmcBt7A9i8IIDUXmB84j1cJX-vyoQa3UWmHfRyc,1497
|
|
46
|
-
tigrbl_runtime/rust/codec.py,sha256=s7AvyyikM5TQ8m65g_0ngoQLr88WcDWfF0jUPqAttso,626
|
|
47
|
-
tigrbl_runtime/rust/compile.py,sha256=BTV5DiGMtEUz4bVOHfRcJoNu7efbRsLf-2paNfj3yFA,341
|
|
48
|
-
tigrbl_runtime/rust/errors.py,sha256=bKZIALb9sKt6ycjl-arFZ-gr7z32sldFzHeiDrclQH4,848
|
|
49
|
-
tigrbl_runtime/rust/request.py,sha256=aVx-RXrUeNQ-WpzYd4BtIxpiMmPCq--rpUYq-3IE2YE,745
|
|
50
|
-
tigrbl_runtime/rust/response.py,sha256=Ablvlw6b-JHLbh50iGs64vSaiswrBvI2mRrLU97gcJc,552
|
|
51
|
-
tigrbl_runtime/rust/runtime.py,sha256=k05pm05S8sDOnyPE_Iv-tpNf_LzIBQDUwORupFoIUAk,2014
|
|
52
|
-
tigrbl_runtime/rust/trace.py,sha256=JKEXVhq0R5SlGO0x05lRMPV8l3YNfFfP5c4cGqt28iA,642
|
|
53
39
|
tigrbl_runtime/semantics.py,sha256=UwPeNdKXJ421XoXqL3oyko5gi9vNrXkBKwk5X9Ug2So,9972
|
|
54
|
-
tigrbl_runtime-0.4.4.
|
|
55
|
-
tigrbl_runtime-0.4.4.
|
|
56
|
-
tigrbl_runtime-0.4.4.
|
|
57
|
-
tigrbl_runtime-0.4.4.
|
|
58
|
-
tigrbl_runtime-0.4.4.
|
|
40
|
+
tigrbl_runtime-0.4.4.dev7.dist-info/METADATA,sha256=1Vo8p1S4obqG3GuhTA9mTm0E4ty4lwIbED_3oRVwyQM,23179
|
|
41
|
+
tigrbl_runtime-0.4.4.dev7.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
|
|
42
|
+
tigrbl_runtime-0.4.4.dev7.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
43
|
+
tigrbl_runtime-0.4.4.dev7.dist-info/licenses/NOTICE,sha256=EvJMTshzsWz43LiK-DeN2ZuLtrP49cxvlrFlJ8F_buc,221
|
|
44
|
+
tigrbl_runtime-0.4.4.dev7.dist-info/RECORD,,
|
tigrbl_runtime/handle.py
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from dataclasses import dataclass, field
|
|
4
|
-
from typing import Any
|
|
5
|
-
import warnings
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@dataclass(slots=True)
|
|
9
|
-
class RustRuntimeHandleRef:
|
|
10
|
-
description: str
|
|
11
|
-
backend: str = "deprecated-rust"
|
|
12
|
-
metadata: dict[str, Any] = field(default_factory=dict)
|
|
13
|
-
|
|
14
|
-
def __post_init__(self) -> None:
|
|
15
|
-
warnings.warn(
|
|
16
|
-
"RustRuntimeHandleRef is deprecated; Tigrbl runtime execution is Python-only.",
|
|
17
|
-
DeprecationWarning,
|
|
18
|
-
stacklevel=2,
|
|
19
|
-
)
|
tigrbl_runtime/rust/__init__.py
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from .backend import (
|
|
4
|
-
ExecutionBackend,
|
|
5
|
-
RustBackendConfig,
|
|
6
|
-
coerce_execution_backend,
|
|
7
|
-
reject_rust_backend,
|
|
8
|
-
wants_rust_backend,
|
|
9
|
-
)
|
|
10
|
-
from .callbacks import (
|
|
11
|
-
register_python_atom,
|
|
12
|
-
register_python_callback,
|
|
13
|
-
register_python_engine,
|
|
14
|
-
register_python_handler,
|
|
15
|
-
register_python_hook,
|
|
16
|
-
registered_python_callbacks,
|
|
17
|
-
)
|
|
18
|
-
from .codec import (
|
|
19
|
-
build_rust_app_spec,
|
|
20
|
-
coerce_rust_spec_dict,
|
|
21
|
-
coerce_rust_spec_json,
|
|
22
|
-
)
|
|
23
|
-
from .compile import compile_app, normalize_spec
|
|
24
|
-
from .request import RustRequest
|
|
25
|
-
from .response import RustResponse
|
|
26
|
-
from .errors import RustBindingsUnavailableError, RustSupportDeprecatedError
|
|
27
|
-
from .runtime import (
|
|
28
|
-
RustRuntimeHandle,
|
|
29
|
-
create_runtime,
|
|
30
|
-
create_runtime_from_compiled,
|
|
31
|
-
)
|
|
32
|
-
from .trace import (
|
|
33
|
-
clear_ffi_boundary_events,
|
|
34
|
-
compiled_extension_available,
|
|
35
|
-
ffi_boundary_events,
|
|
36
|
-
rust_available,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
__all__ = [
|
|
40
|
-
"ExecutionBackend",
|
|
41
|
-
"RustBackendConfig",
|
|
42
|
-
"RustBindingsUnavailableError",
|
|
43
|
-
"RustSupportDeprecatedError",
|
|
44
|
-
"RustRequest",
|
|
45
|
-
"RustResponse",
|
|
46
|
-
"RustRuntimeHandle",
|
|
47
|
-
"build_rust_app_spec",
|
|
48
|
-
"clear_ffi_boundary_events",
|
|
49
|
-
"coerce_rust_spec_dict",
|
|
50
|
-
"coerce_rust_spec_json",
|
|
51
|
-
"coerce_execution_backend",
|
|
52
|
-
"compile_app",
|
|
53
|
-
"compiled_extension_available",
|
|
54
|
-
"create_runtime",
|
|
55
|
-
"create_runtime_from_compiled",
|
|
56
|
-
"ffi_boundary_events",
|
|
57
|
-
"rust_available",
|
|
58
|
-
"normalize_spec",
|
|
59
|
-
"register_python_atom",
|
|
60
|
-
"register_python_callback",
|
|
61
|
-
"register_python_engine",
|
|
62
|
-
"register_python_handler",
|
|
63
|
-
"register_python_hook",
|
|
64
|
-
"registered_python_callbacks",
|
|
65
|
-
"reject_rust_backend",
|
|
66
|
-
"wants_rust_backend",
|
|
67
|
-
]
|
tigrbl_runtime/rust/_fallback.py
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import Any
|
|
4
|
-
|
|
5
|
-
from .errors import raise_rust_deprecated, warn_rust_deprecated
|
|
6
|
-
|
|
7
|
-
_BOUNDARY_EVENTS: list[dict[str, Any]] = []
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def ffi_boundary_events() -> list[dict[str, Any]]:
|
|
11
|
-
warn_rust_deprecated()
|
|
12
|
-
return [dict(item) for item in _BOUNDARY_EVENTS]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def clear_ffi_boundary_events() -> None:
|
|
16
|
-
warn_rust_deprecated()
|
|
17
|
-
_BOUNDARY_EVENTS.clear()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def rust_available() -> bool:
|
|
21
|
-
warn_rust_deprecated()
|
|
22
|
-
return False
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def compiled_extension_available() -> bool:
|
|
26
|
-
warn_rust_deprecated()
|
|
27
|
-
return False
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def normalize_spec(spec_json: str) -> str:
|
|
31
|
-
del spec_json
|
|
32
|
-
raise_rust_deprecated("tigrbl_runtime.rust._fallback.normalize_spec")
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def compile_spec(spec_json: str) -> str:
|
|
36
|
-
del spec_json
|
|
37
|
-
raise_rust_deprecated("tigrbl_runtime.rust._fallback.compile_spec")
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
class RuntimeHandle:
|
|
41
|
-
def __init__(self, plan_json_payload: str) -> None:
|
|
42
|
-
del plan_json_payload
|
|
43
|
-
raise_rust_deprecated("tigrbl_runtime.rust._fallback.RuntimeHandle")
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def create_runtime_handle(plan_json: str) -> RuntimeHandle:
|
|
47
|
-
del plan_json
|
|
48
|
-
raise_rust_deprecated("tigrbl_runtime.rust._fallback.create_runtime_handle")
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def register_python_callback(name: str, *_args: Any, **_kwargs: Any) -> str:
|
|
52
|
-
del name
|
|
53
|
-
raise_rust_deprecated("tigrbl_runtime.rust._fallback.register_python_callback")
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def register_python_atom(name: str, *_args: Any, **_kwargs: Any) -> str:
|
|
57
|
-
del name
|
|
58
|
-
raise_rust_deprecated("tigrbl_runtime.rust._fallback.register_python_atom")
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def register_python_hook(name: str, *_args: Any, **_kwargs: Any) -> str:
|
|
62
|
-
del name
|
|
63
|
-
raise_rust_deprecated("tigrbl_runtime.rust._fallback.register_python_hook")
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def register_python_handler(name: str, *_args: Any, **_kwargs: Any) -> str:
|
|
67
|
-
del name
|
|
68
|
-
raise_rust_deprecated("tigrbl_runtime.rust._fallback.register_python_handler")
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def register_python_engine(name: str, *_args: Any, **_kwargs: Any) -> str:
|
|
72
|
-
del name
|
|
73
|
-
raise_rust_deprecated("tigrbl_runtime.rust._fallback.register_python_engine")
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from types import ModuleType
|
|
4
|
-
|
|
5
|
-
from .errors import RUST_DEPRECATION_MESSAGE
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
_LOADED: ModuleType | None = None
|
|
9
|
-
_IMPORT_ERROR: Exception | None = None
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def load_rust_module() -> tuple[ModuleType, Exception | None]:
|
|
13
|
-
global _LOADED, _IMPORT_ERROR
|
|
14
|
-
|
|
15
|
-
if _LOADED is not None:
|
|
16
|
-
return _LOADED, _IMPORT_ERROR
|
|
17
|
-
|
|
18
|
-
from . import _fallback as module
|
|
19
|
-
|
|
20
|
-
_LOADED = module
|
|
21
|
-
_IMPORT_ERROR = RuntimeError(RUST_DEPRECATION_MESSAGE)
|
|
22
|
-
return _LOADED, _IMPORT_ERROR
|
tigrbl_runtime/rust/backend.py
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
from enum import Enum
|
|
5
|
-
|
|
6
|
-
from .errors import raise_rust_deprecated, warn_rust_deprecated
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class ExecutionBackend(str, Enum):
|
|
10
|
-
AUTO = "auto"
|
|
11
|
-
PYTHON = "python"
|
|
12
|
-
RUST = "rust"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@dataclass(slots=True, frozen=True)
|
|
16
|
-
class RustBackendConfig:
|
|
17
|
-
backend: ExecutionBackend = ExecutionBackend.AUTO
|
|
18
|
-
allow_python_callbacks: bool = True
|
|
19
|
-
emit_boundary_trace: bool = False
|
|
20
|
-
strict_rust: bool = False
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def coerce_execution_backend(value: str | ExecutionBackend | None) -> ExecutionBackend:
|
|
24
|
-
if isinstance(value, ExecutionBackend):
|
|
25
|
-
if value is ExecutionBackend.RUST:
|
|
26
|
-
warn_rust_deprecated()
|
|
27
|
-
return value
|
|
28
|
-
if value is None:
|
|
29
|
-
return ExecutionBackend.AUTO
|
|
30
|
-
lowered = str(value).strip().lower()
|
|
31
|
-
for item in ExecutionBackend:
|
|
32
|
-
if item.value == lowered:
|
|
33
|
-
if item is ExecutionBackend.RUST:
|
|
34
|
-
warn_rust_deprecated()
|
|
35
|
-
return item
|
|
36
|
-
raise ValueError(f"unsupported execution backend: {value!r}")
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def wants_rust_backend(value: str | ExecutionBackend | RustBackendConfig | None) -> bool:
|
|
40
|
-
if isinstance(value, RustBackendConfig):
|
|
41
|
-
backend = value.backend
|
|
42
|
-
else:
|
|
43
|
-
backend = coerce_execution_backend(value)
|
|
44
|
-
if backend is ExecutionBackend.RUST:
|
|
45
|
-
warn_rust_deprecated()
|
|
46
|
-
return False
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def reject_rust_backend(
|
|
50
|
-
value: str | ExecutionBackend | RustBackendConfig | None,
|
|
51
|
-
*,
|
|
52
|
-
label: str,
|
|
53
|
-
) -> ExecutionBackend:
|
|
54
|
-
if isinstance(value, RustBackendConfig):
|
|
55
|
-
if value.strict_rust:
|
|
56
|
-
raise_rust_deprecated(f"{label}.strict_rust")
|
|
57
|
-
backend = value.backend
|
|
58
|
-
else:
|
|
59
|
-
backend = coerce_execution_backend(value)
|
|
60
|
-
if backend is ExecutionBackend.RUST:
|
|
61
|
-
raise_rust_deprecated(label)
|
|
62
|
-
return backend
|
tigrbl_runtime/rust/callbacks.py
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from collections.abc import Callable
|
|
4
|
-
from typing import Any
|
|
5
|
-
|
|
6
|
-
from .errors import raise_rust_deprecated
|
|
7
|
-
from .trace import record_python_ffi_event
|
|
8
|
-
|
|
9
|
-
_REGISTRY: dict[str, Callable[..., Any]] = {}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def registered_python_callbacks() -> dict[str, Callable[..., Any]]:
|
|
13
|
-
return dict(_REGISTRY)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def register_python_callback(name: str, callback: Callable[..., Any]) -> str:
|
|
17
|
-
del callback
|
|
18
|
-
record_python_ffi_event("rust_callback_deprecated", name=name)
|
|
19
|
-
raise_rust_deprecated("tigrbl_runtime.rust.register_python_callback")
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def register_python_atom(name: str, callback: Callable[..., Any]) -> str:
|
|
23
|
-
del callback
|
|
24
|
-
record_python_ffi_event("rust_atom_deprecated", name=name)
|
|
25
|
-
raise_rust_deprecated("tigrbl_runtime.rust.register_python_atom")
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def register_python_hook(name: str, callback: Callable[..., Any]) -> str:
|
|
29
|
-
del callback
|
|
30
|
-
record_python_ffi_event("rust_hook_deprecated", name=name)
|
|
31
|
-
raise_rust_deprecated("tigrbl_runtime.rust.register_python_hook")
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def register_python_handler(name: str, callback: Callable[..., Any]) -> str:
|
|
35
|
-
del callback
|
|
36
|
-
record_python_ffi_event("rust_handler_deprecated", name=name)
|
|
37
|
-
raise_rust_deprecated("tigrbl_runtime.rust.register_python_handler")
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def register_python_engine(name: str, callback: Callable[..., Any] | None = None) -> str:
|
|
41
|
-
del callback
|
|
42
|
-
record_python_ffi_event("rust_engine_deprecated", name=name)
|
|
43
|
-
raise_rust_deprecated("tigrbl_runtime.rust.register_python_engine")
|
tigrbl_runtime/rust/codec.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import Any
|
|
4
|
-
|
|
5
|
-
from .errors import raise_rust_deprecated
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def build_rust_app_spec(app: Any) -> dict[str, Any]:
|
|
9
|
-
del app
|
|
10
|
-
raise_rust_deprecated("tigrbl_runtime.rust.codec.build_rust_app_spec")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def coerce_rust_spec_dict(app: Any) -> dict[str, Any]:
|
|
14
|
-
del app
|
|
15
|
-
raise_rust_deprecated("tigrbl_runtime.rust.codec.coerce_rust_spec_dict")
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def coerce_rust_spec_json(app: Any) -> str:
|
|
19
|
-
del app
|
|
20
|
-
raise_rust_deprecated("tigrbl_runtime.rust.codec.coerce_rust_spec_json")
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
__all__ = [
|
|
24
|
-
"build_rust_app_spec",
|
|
25
|
-
"coerce_rust_spec_dict",
|
|
26
|
-
"coerce_rust_spec_json",
|
|
27
|
-
]
|
tigrbl_runtime/rust/compile.py
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import Any
|
|
4
|
-
|
|
5
|
-
from .errors import raise_rust_deprecated
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def normalize_spec(spec: Any) -> str:
|
|
9
|
-
del spec
|
|
10
|
-
raise_rust_deprecated("tigrbl_runtime.rust.normalize_spec")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def compile_app(spec: Any) -> dict[str, Any]:
|
|
14
|
-
del spec
|
|
15
|
-
raise_rust_deprecated("tigrbl_runtime.rust.compile_app")
|
tigrbl_runtime/rust/errors.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import warnings
|
|
4
|
-
from typing import NoReturn
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
RUST_DEPRECATION_MESSAGE = (
|
|
8
|
-
"Tigrbl Rust runtime support is deprecated and unavailable; "
|
|
9
|
-
"Tigrbl runtime execution is Python-only. Use executor_backend='python'."
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class RustSupportDeprecatedError(RuntimeError):
|
|
14
|
-
"""Raised when deprecated Rust support is requested."""
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class RustBindingsUnavailableError(RustSupportDeprecatedError):
|
|
18
|
-
"""Raised when the deprecated Rust runtime binding surface is requested."""
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def warn_rust_deprecated(*, stacklevel: int = 2) -> None:
|
|
22
|
-
warnings.warn(RUST_DEPRECATION_MESSAGE, DeprecationWarning, stacklevel=stacklevel)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def raise_rust_deprecated(action: str) -> NoReturn:
|
|
26
|
-
warn_rust_deprecated(stacklevel=3)
|
|
27
|
-
raise RustBindingsUnavailableError(f"{action} is unavailable. {RUST_DEPRECATION_MESSAGE}")
|
tigrbl_runtime/rust/request.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from dataclasses import asdict, dataclass, field
|
|
4
|
-
from typing import Any
|
|
5
|
-
import warnings
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@dataclass(slots=True)
|
|
9
|
-
class RustRequest:
|
|
10
|
-
operation: str = ""
|
|
11
|
-
transport: str = "rest"
|
|
12
|
-
path: str = ""
|
|
13
|
-
method: str = ""
|
|
14
|
-
path_params: dict[str, Any] = field(default_factory=dict)
|
|
15
|
-
query_params: dict[str, Any] = field(default_factory=dict)
|
|
16
|
-
headers: dict[str, str] = field(default_factory=dict)
|
|
17
|
-
body: Any = None
|
|
18
|
-
|
|
19
|
-
def __post_init__(self) -> None:
|
|
20
|
-
warnings.warn(
|
|
21
|
-
"RustRequest is deprecated; Tigrbl runtime execution is Python-only.",
|
|
22
|
-
DeprecationWarning,
|
|
23
|
-
stacklevel=2,
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
def asdict(self) -> dict[str, Any]:
|
|
27
|
-
return asdict(self)
|
tigrbl_runtime/rust/response.py
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from dataclasses import asdict, dataclass, field
|
|
4
|
-
from typing import Any
|
|
5
|
-
import warnings
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@dataclass(slots=True)
|
|
9
|
-
class RustResponse:
|
|
10
|
-
status: int = 200
|
|
11
|
-
headers: dict[str, str] = field(default_factory=dict)
|
|
12
|
-
body: Any = None
|
|
13
|
-
|
|
14
|
-
def __post_init__(self) -> None:
|
|
15
|
-
warnings.warn(
|
|
16
|
-
"RustResponse is deprecated; Tigrbl runtime execution is Python-only.",
|
|
17
|
-
DeprecationWarning,
|
|
18
|
-
stacklevel=2,
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
def asdict(self) -> dict[str, Any]:
|
|
22
|
-
return asdict(self)
|
tigrbl_runtime/rust/runtime.py
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
from typing import Any
|
|
5
|
-
|
|
6
|
-
from .errors import raise_rust_deprecated
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@dataclass(slots=True)
|
|
10
|
-
class RustRuntimeHandle:
|
|
11
|
-
_handle: Any = None
|
|
12
|
-
|
|
13
|
-
def describe(self) -> str:
|
|
14
|
-
raise_rust_deprecated("RustRuntimeHandle.describe")
|
|
15
|
-
|
|
16
|
-
def plan(self) -> dict[str, object]:
|
|
17
|
-
raise_rust_deprecated("RustRuntimeHandle.plan")
|
|
18
|
-
|
|
19
|
-
def execute_rest(self, envelope: Any) -> dict[str, object]:
|
|
20
|
-
del envelope
|
|
21
|
-
raise_rust_deprecated("RustRuntimeHandle.execute_rest")
|
|
22
|
-
|
|
23
|
-
def execute_jsonrpc(self, envelope: Any) -> dict[str, object]:
|
|
24
|
-
del envelope
|
|
25
|
-
raise_rust_deprecated("RustRuntimeHandle.execute_jsonrpc")
|
|
26
|
-
|
|
27
|
-
def execute_ws(self, envelope: Any) -> dict[str, object]:
|
|
28
|
-
del envelope
|
|
29
|
-
raise_rust_deprecated("RustRuntimeHandle.execute_ws")
|
|
30
|
-
|
|
31
|
-
def execute_stream(self, envelope: Any) -> dict[str, object]:
|
|
32
|
-
del envelope
|
|
33
|
-
raise_rust_deprecated("RustRuntimeHandle.execute_stream")
|
|
34
|
-
|
|
35
|
-
def execute_sse(self, envelope: Any) -> dict[str, object]:
|
|
36
|
-
del envelope
|
|
37
|
-
raise_rust_deprecated("RustRuntimeHandle.execute_sse")
|
|
38
|
-
|
|
39
|
-
def begin_request(self, transport: str = "rest") -> None:
|
|
40
|
-
del transport
|
|
41
|
-
raise_rust_deprecated("RustRuntimeHandle.begin_request")
|
|
42
|
-
|
|
43
|
-
def callback_fence(self, kind: str, name: str) -> None:
|
|
44
|
-
del kind, name
|
|
45
|
-
raise_rust_deprecated("RustRuntimeHandle.callback_fence")
|
|
46
|
-
|
|
47
|
-
def finish_response(self, transport: str = "rest") -> None:
|
|
48
|
-
del transport
|
|
49
|
-
raise_rust_deprecated("RustRuntimeHandle.finish_response")
|
|
50
|
-
|
|
51
|
-
def ffi_events(self) -> list[dict[str, object]]:
|
|
52
|
-
raise_rust_deprecated("RustRuntimeHandle.ffi_events")
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def create_runtime_from_compiled(plan: Any) -> RustRuntimeHandle:
|
|
56
|
-
del plan
|
|
57
|
-
raise_rust_deprecated("tigrbl_runtime.rust.create_runtime_from_compiled")
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def create_runtime(spec: Any) -> RustRuntimeHandle:
|
|
61
|
-
del spec
|
|
62
|
-
raise_rust_deprecated("tigrbl_runtime.rust.create_runtime")
|
tigrbl_runtime/rust/trace.py
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from .errors import warn_rust_deprecated
|
|
4
|
-
|
|
5
|
-
_PYTHON_FFI_EVENTS: list[dict[str, object]] = []
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def ffi_boundary_events() -> list[dict[str, object]]:
|
|
9
|
-
warn_rust_deprecated()
|
|
10
|
-
return list(_PYTHON_FFI_EVENTS)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def clear_ffi_boundary_events() -> None:
|
|
14
|
-
warn_rust_deprecated()
|
|
15
|
-
_PYTHON_FFI_EVENTS.clear()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def record_python_ffi_event(event: str, **payload: object) -> None:
|
|
19
|
-
_PYTHON_FFI_EVENTS.append({"event": event, **payload})
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def rust_available() -> bool:
|
|
23
|
-
warn_rust_deprecated()
|
|
24
|
-
return False
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def compiled_extension_available() -> bool:
|
|
28
|
-
warn_rust_deprecated()
|
|
29
|
-
return False
|
|
File without changes
|
{tigrbl_runtime-0.4.4.dev1.dist-info → tigrbl_runtime-0.4.4.dev7.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|