tigrbl-runtime 0.4.5.dev1__tar.gz → 0.4.5.dev4__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.
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/PKG-INFO +11 -10
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/README.md +8 -7
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/pyproject.toml +3 -6
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/executors/ctx/context.py +1 -5
- tigrbl_runtime-0.4.5.dev1/tigrbl_runtime/executors/ctx/hot_namespaces.py → tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/ctx/hot_namespace_values.py +0 -221
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/ctx/hot_namespaces.py +240 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/__init__.py +4 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/_shared.py +169 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/batch.py +376 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/error_edges.py +303 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/execute.py +343 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/executor.py +86 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/hot_access.py +222 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/hot_context.py +301 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/input_compile.py +327 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/input_extract.py +310 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/request_select.py +209 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/route_select.py +319 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/runner_resolve.py +379 -0
- tigrbl_runtime-0.4.5.dev4/tigrbl_runtime/executors/packed/segments.py +337 -0
- tigrbl_runtime-0.4.5.dev1/tigrbl_runtime/executors/packed.py +0 -3591
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/LICENSE +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/NOTICE +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/__init__.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/callbacks.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/channel/__init__.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/channel/_asgi_completion.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/channel/_asgi_context.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/channel/_asgi_jsonrpc.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/channel/_asgi_receive.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/channel/_asgi_scope.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/channel/_asgi_send.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/channel/_asgi_webtransport.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/channel/asgi.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/channel/capabilities.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/channel/websocket.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/config/__init__.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/config/constants.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/executors/__init__.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/executors/_invoke_support.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/executors/base.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/executors/ctx/__init__.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/executors/ctx/hot.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/executors/ctx/hot_state.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/executors/kernel_executor.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/executors/numba_packed.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/executors/phase.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/executors/phase_runner.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/executors/types.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/runtime/__init__.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/runtime/_typing_aliases.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/runtime/base.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/runtime/channel.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/runtime/exceptions.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/runtime/hook_types.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/runtime/response.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/runtime/runtime.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/runtime/system.py +0 -0
- {tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/semantics.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tigrbl-runtime
|
|
3
|
-
Version: 0.4.5.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.4.5.dev4
|
|
4
|
+
Summary: Execution bridge for compiled Tigrbl kernel plans and narrow runtime context/carrier compatibility.
|
|
5
5
|
License: Apache License
|
|
6
6
|
Version 2.0, January 2004
|
|
7
7
|
http://www.apache.org/licenses/
|
|
@@ -205,7 +205,7 @@ License: Apache License
|
|
|
205
205
|
limitations under the License.
|
|
206
206
|
License-File: LICENSE
|
|
207
207
|
License-File: NOTICE
|
|
208
|
-
Keywords: tigrbl,asgi,api,
|
|
208
|
+
Keywords: tigrbl,asgi,api,sqlalchemy,pydantic,runtime,pipeline,bridge,schema-first
|
|
209
209
|
Author: Jacob Stewart
|
|
210
210
|
Author-email: jacob@swarmauri.com
|
|
211
211
|
Requires-Python: >=3.10,<3.15
|
|
@@ -241,7 +241,7 @@ Description-Content-Type: text/markdown
|
|
|
241
241
|
<div align="center">
|
|
242
242
|
<h1>tigrbl-runtime</h1>
|
|
243
243
|
<img src="https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/tigrbl_full_logo.png" alt="Tigrbl logo" width="140"/>
|
|
244
|
-
<p><strong>
|
|
244
|
+
<p><strong>Execution bridge for compiled Tigrbl kernel plans and narrow runtime context/carrier compatibility.</strong></p>
|
|
245
245
|
<a href="https://pypi.org/project/tigrbl-runtime/"><img src="https://img.shields.io/pypi/v/tigrbl-runtime?label=PyPI" alt="PyPI version for tigrbl-runtime"/></a>
|
|
246
246
|
<a href="https://pypi.org/project/tigrbl-runtime/"><img src="https://static.pepy.tech/badge/tigrbl-runtime" alt="Downloads for tigrbl-runtime"/></a>
|
|
247
247
|
<a href="https://discord.gg/K4YTAPapjR"><img src="https://img.shields.io/badge/Discord-Join%20chat-5865F2?logo=discord&logoColor=white" alt="Discord community for tigrbl-runtime"/></a>
|
|
@@ -253,7 +253,7 @@ Description-Content-Type: text/markdown
|
|
|
253
253
|
|
|
254
254
|
## What is tigrbl-runtime?
|
|
255
255
|
|
|
256
|
-
|
|
256
|
+
`tigrbl-runtime` executes compiled Tigrbl kernel plans and preserves the narrow runtime context/carrier bridge needed to run those plans. Route selection, protocol fallback policy, response shaping, transport envelopes, and operation semantics are owned by kernel, atoms, and ops packages.
|
|
257
257
|
|
|
258
258
|
## Why use tigrbl-runtime?
|
|
259
259
|
|
|
@@ -301,17 +301,18 @@ pip install tigrbl-runtime
|
|
|
301
301
|
|
|
302
302
|
## What It Owns
|
|
303
303
|
|
|
304
|
-
`tigrbl-runtime` owns the
|
|
304
|
+
`tigrbl-runtime` owns the compiled-plan execution boundary. It should be installed when you need the narrow bridge that runs already-planned Tigrbl work without assuming the full facade is present.
|
|
305
305
|
|
|
306
306
|
Implementation orientation:
|
|
307
|
-
- `tigrbl_runtime`:
|
|
307
|
+
- `tigrbl_runtime`: compiled plan execution, runtime context compatibility, and declared carrier lifecycle bridges
|
|
308
308
|
|
|
309
309
|
Runtime authoring BCP:
|
|
310
|
-
- Do use this package for
|
|
311
|
-
- Do keep
|
|
310
|
+
- Do use this package for executing compiled kernel plans and maintaining runtime context/carrier compatibility.
|
|
311
|
+
- Do keep execution aligned with compiled plans.
|
|
312
|
+
- Do not add route matching semantics, protocol fallback policy, JSON-RPC/REST envelope policy, response rendering, chunk emission semantics, operation behavior, or new executor families.
|
|
312
313
|
- Do not make application route handlers, FastAPI/Starlette objects, direct SQLAlchemy session calls, or ad-hoc engine construction the runtime contract.
|
|
313
314
|
- Do not bypass kernel plans or lifecycle phases when adding REST, JSON-RPC, stream, SSE, WebSocket, or WebTransport behavior.
|
|
314
|
-
- Avoid hiding behavior in
|
|
315
|
+
- Avoid hiding behavior in runtime wrappers that diagnostics and compiled plans cannot inspect.
|
|
315
316
|
|
|
316
317
|
## Public API and Import Surface
|
|
317
318
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<h1>tigrbl-runtime</h1>
|
|
3
3
|
<img src="https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/tigrbl_full_logo.png" alt="Tigrbl logo" width="140"/>
|
|
4
|
-
<p><strong>
|
|
4
|
+
<p><strong>Execution bridge for compiled Tigrbl kernel plans and narrow runtime context/carrier compatibility.</strong></p>
|
|
5
5
|
<a href="https://pypi.org/project/tigrbl-runtime/"><img src="https://img.shields.io/pypi/v/tigrbl-runtime?label=PyPI" alt="PyPI version for tigrbl-runtime"/></a>
|
|
6
6
|
<a href="https://pypi.org/project/tigrbl-runtime/"><img src="https://static.pepy.tech/badge/tigrbl-runtime" alt="Downloads for tigrbl-runtime"/></a>
|
|
7
7
|
<a href="https://discord.gg/K4YTAPapjR"><img src="https://img.shields.io/badge/Discord-Join%20chat-5865F2?logo=discord&logoColor=white" alt="Discord community for tigrbl-runtime"/></a>
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
## What is tigrbl-runtime?
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
`tigrbl-runtime` executes compiled Tigrbl kernel plans and preserves the narrow runtime context/carrier bridge needed to run those plans. Route selection, protocol fallback policy, response shaping, transport envelopes, and operation semantics are owned by kernel, atoms, and ops packages.
|
|
17
17
|
|
|
18
18
|
## Why use tigrbl-runtime?
|
|
19
19
|
|
|
@@ -61,17 +61,18 @@ pip install tigrbl-runtime
|
|
|
61
61
|
|
|
62
62
|
## What It Owns
|
|
63
63
|
|
|
64
|
-
`tigrbl-runtime` owns the
|
|
64
|
+
`tigrbl-runtime` owns the compiled-plan execution boundary. It should be installed when you need the narrow bridge that runs already-planned Tigrbl work without assuming the full facade is present.
|
|
65
65
|
|
|
66
66
|
Implementation orientation:
|
|
67
|
-
- `tigrbl_runtime`:
|
|
67
|
+
- `tigrbl_runtime`: compiled plan execution, runtime context compatibility, and declared carrier lifecycle bridges
|
|
68
68
|
|
|
69
69
|
Runtime authoring BCP:
|
|
70
|
-
- Do use this package for
|
|
71
|
-
- Do keep
|
|
70
|
+
- Do use this package for executing compiled kernel plans and maintaining runtime context/carrier compatibility.
|
|
71
|
+
- Do keep execution aligned with compiled plans.
|
|
72
|
+
- Do not add route matching semantics, protocol fallback policy, JSON-RPC/REST envelope policy, response rendering, chunk emission semantics, operation behavior, or new executor families.
|
|
72
73
|
- Do not make application route handlers, FastAPI/Starlette objects, direct SQLAlchemy session calls, or ad-hoc engine construction the runtime contract.
|
|
73
74
|
- Do not bypass kernel plans or lifecycle phases when adding REST, JSON-RPC, stream, SSE, WebSocket, or WebTransport behavior.
|
|
74
|
-
- Avoid hiding behavior in
|
|
75
|
+
- Avoid hiding behavior in runtime wrappers that diagnostics and compiled plans cannot inspect.
|
|
75
76
|
|
|
76
77
|
## Public API and Import Surface
|
|
77
78
|
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "tigrbl-runtime"
|
|
3
|
-
version = "0.4.5.
|
|
4
|
-
description = "
|
|
3
|
+
version = "0.4.5.dev4"
|
|
4
|
+
description = "Execution bridge for compiled Tigrbl kernel plans and narrow runtime context/carrier compatibility."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = { file = "LICENSE" }
|
|
7
7
|
keywords = [
|
|
8
8
|
"tigrbl",
|
|
9
9
|
"asgi",
|
|
10
10
|
"api",
|
|
11
|
-
"json-rpc",
|
|
12
|
-
"rest",
|
|
13
11
|
"sqlalchemy",
|
|
14
12
|
"pydantic",
|
|
15
13
|
"runtime",
|
|
16
14
|
"pipeline",
|
|
17
15
|
"bridge",
|
|
18
|
-
"openapi",
|
|
19
|
-
"openrpc",
|
|
20
16
|
"schema-first",
|
|
21
17
|
]
|
|
22
18
|
classifiers = [
|
|
@@ -77,4 +73,5 @@ dev = [
|
|
|
77
73
|
"pytest>=8.0",
|
|
78
74
|
"pytest-asyncio>=0.23",
|
|
79
75
|
"ruff>=0.9",
|
|
76
|
+
"tomli>=2.0; python_version < '3.11'",
|
|
80
77
|
]
|
{tigrbl_runtime-0.4.5.dev1 → tigrbl_runtime-0.4.5.dev4}/tigrbl_runtime/executors/ctx/context.py
RENAMED
|
@@ -16,11 +16,7 @@ from typing import (
|
|
|
16
16
|
runtime_checkable,
|
|
17
17
|
)
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
from sqlalchemy.ext.asyncio import AsyncSession
|
|
21
|
-
from sqlalchemy.orm import Session
|
|
22
|
-
except Exception: # pragma: no cover - optional ORM dependency for runtime typing
|
|
23
|
-
AsyncSession = Session = Any # type: ignore[assignment]
|
|
19
|
+
AsyncSession = Session = Any # type: ignore[assignment]
|
|
24
20
|
|
|
25
21
|
from tigrbl_atoms.types import BaseCtx
|
|
26
22
|
from tigrbl_base._base import AttrDict
|
|
@@ -198,224 +198,3 @@ def _clear_hot_namespace_value(kind: str, hot: HotCtx, key: str) -> None:
|
|
|
198
198
|
elif key == "sent":
|
|
199
199
|
hot.egress_sent = False
|
|
200
200
|
|
|
201
|
-
|
|
202
|
-
class _HotNamespaceDict(dict[str, Any]):
|
|
203
|
-
__slots__ = ("_kind", "_temp")
|
|
204
|
-
|
|
205
|
-
def __init__(
|
|
206
|
-
self, kind: str, temp: "_HotTemp", initial: Mapping[str, Any] | None = None
|
|
207
|
-
) -> None:
|
|
208
|
-
super().__init__(initial or {})
|
|
209
|
-
self._kind = kind
|
|
210
|
-
self._temp = temp
|
|
211
|
-
hot = temp._hot_ctx()
|
|
212
|
-
if hot is not None and initial:
|
|
213
|
-
for key, value in initial.items():
|
|
214
|
-
_sync_hot_namespace_value(kind, hot, key, value)
|
|
215
|
-
|
|
216
|
-
def _lazy_value(self, key: str) -> Any:
|
|
217
|
-
hot = self._temp._hot_ctx()
|
|
218
|
-
if hot is None:
|
|
219
|
-
return _LAZY_MISSING
|
|
220
|
-
return _namespace_lazy_value(self._kind, hot, key)
|
|
221
|
-
|
|
222
|
-
def __setitem__(self, key: str, value: Any) -> None:
|
|
223
|
-
dict.__setitem__(self, key, value)
|
|
224
|
-
hot = self._temp._hot_ctx()
|
|
225
|
-
if hot is not None:
|
|
226
|
-
_sync_hot_namespace_value(self._kind, hot, key, value)
|
|
227
|
-
|
|
228
|
-
def __delitem__(self, key: str) -> None:
|
|
229
|
-
dict.__delitem__(self, key)
|
|
230
|
-
hot = self._temp._hot_ctx()
|
|
231
|
-
if hot is not None:
|
|
232
|
-
_clear_hot_namespace_value(self._kind, hot, key)
|
|
233
|
-
|
|
234
|
-
def __getitem__(self, key: str) -> Any:
|
|
235
|
-
try:
|
|
236
|
-
return dict.__getitem__(self, key)
|
|
237
|
-
except KeyError:
|
|
238
|
-
value = self._lazy_value(key)
|
|
239
|
-
if value is _LAZY_MISSING:
|
|
240
|
-
raise
|
|
241
|
-
dict.__setitem__(self, key, value)
|
|
242
|
-
return value
|
|
243
|
-
|
|
244
|
-
def get(self, key: str, default: Any = None) -> Any:
|
|
245
|
-
if dict.__contains__(self, key):
|
|
246
|
-
return dict.get(self, key, default)
|
|
247
|
-
value = self._lazy_value(key)
|
|
248
|
-
if value is _LAZY_MISSING:
|
|
249
|
-
return default
|
|
250
|
-
dict.__setitem__(self, key, value)
|
|
251
|
-
return value
|
|
252
|
-
|
|
253
|
-
def setdefault(self, key: str, default: Any = None) -> Any:
|
|
254
|
-
if dict.__contains__(self, key):
|
|
255
|
-
return dict.__getitem__(self, key)
|
|
256
|
-
self[key] = default
|
|
257
|
-
return default
|
|
258
|
-
|
|
259
|
-
def update(self, *args: Any, **kwargs: Any) -> None:
|
|
260
|
-
for mapping in args:
|
|
261
|
-
if isinstance(mapping, ABCMapping):
|
|
262
|
-
for key, value in mapping.items():
|
|
263
|
-
self[key] = value
|
|
264
|
-
else:
|
|
265
|
-
for key, value in dict(mapping).items():
|
|
266
|
-
self[key] = value
|
|
267
|
-
for key, value in kwargs.items():
|
|
268
|
-
self[key] = value
|
|
269
|
-
|
|
270
|
-
def pop(self, key: str, default: Any = _LAZY_MISSING) -> Any:
|
|
271
|
-
if dict.__contains__(self, key):
|
|
272
|
-
value = dict.pop(self, key)
|
|
273
|
-
hot = self._temp._hot_ctx()
|
|
274
|
-
if hot is not None:
|
|
275
|
-
_clear_hot_namespace_value(self._kind, hot, key)
|
|
276
|
-
return value
|
|
277
|
-
if default is _LAZY_MISSING:
|
|
278
|
-
raise KeyError(key)
|
|
279
|
-
return default
|
|
280
|
-
|
|
281
|
-
def __contains__(self, key: object) -> bool:
|
|
282
|
-
if dict.__contains__(self, key):
|
|
283
|
-
return True
|
|
284
|
-
if not isinstance(key, str):
|
|
285
|
-
return False
|
|
286
|
-
return self._lazy_value(key) is not _LAZY_MISSING
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
class _HotTemp(dict[str, Any]):
|
|
290
|
-
__slots__ = ()
|
|
291
|
-
|
|
292
|
-
@classmethod
|
|
293
|
-
def from_mapping(cls, value: Mapping[str, Any] | None) -> "_HotTemp":
|
|
294
|
-
if isinstance(value, cls):
|
|
295
|
-
return value
|
|
296
|
-
temp = cls()
|
|
297
|
-
if value:
|
|
298
|
-
temp.update(value)
|
|
299
|
-
return temp
|
|
300
|
-
|
|
301
|
-
def _hot_ctx(self) -> HotCtx | None:
|
|
302
|
-
hot = dict.get(self, "hot_ctx")
|
|
303
|
-
return hot if isinstance(hot, HotCtx) else None
|
|
304
|
-
|
|
305
|
-
def _wrap_namespace(self, key: str, value: Any) -> Any:
|
|
306
|
-
if (
|
|
307
|
-
key in {"route", "dispatch", "egress"}
|
|
308
|
-
and isinstance(value, dict)
|
|
309
|
-
and not isinstance(value, _HotNamespaceDict)
|
|
310
|
-
):
|
|
311
|
-
return _HotNamespaceDict(key, self, value)
|
|
312
|
-
return value
|
|
313
|
-
|
|
314
|
-
def _lazy_value(self, key: str) -> Any:
|
|
315
|
-
hot = self._hot_ctx()
|
|
316
|
-
if hot is None:
|
|
317
|
-
return _LAZY_MISSING
|
|
318
|
-
if key in {"route", "dispatch", "egress"}:
|
|
319
|
-
return _HotNamespaceDict(key, self)
|
|
320
|
-
if key == "jsonrpc_request_id":
|
|
321
|
-
if hot.dispatch_jsonrpc_request_id is not None:
|
|
322
|
-
return hot.dispatch_jsonrpc_request_id
|
|
323
|
-
envelope = hot.dispatch_rpc_envelope or hot.route_rpc_envelope
|
|
324
|
-
if envelope is not None and "id" in envelope:
|
|
325
|
-
return envelope["id"]
|
|
326
|
-
if key == "compiled_in_values_ready" and hot.compiled_input_ready:
|
|
327
|
-
return True
|
|
328
|
-
if key == "in_values":
|
|
329
|
-
value = _ensure_hot_in_values_view(hot)
|
|
330
|
-
if value is not None:
|
|
331
|
-
return value
|
|
332
|
-
if key == "in_present" and hot.in_present_names:
|
|
333
|
-
return hot.in_present_names
|
|
334
|
-
if key == "assembled_values":
|
|
335
|
-
value = _ensure_hot_assembled_values_view(hot)
|
|
336
|
-
if value is not None:
|
|
337
|
-
return value
|
|
338
|
-
if key == "virtual_in":
|
|
339
|
-
value = _ensure_hot_virtual_in_view(hot)
|
|
340
|
-
if value is not None:
|
|
341
|
-
return value
|
|
342
|
-
if key == "absent_fields" and hot.absent_fields:
|
|
343
|
-
return hot.absent_fields
|
|
344
|
-
if key == "used_default_factory" and hot.used_default_factory:
|
|
345
|
-
return hot.used_default_factory
|
|
346
|
-
if key == "in_invalid" and hot.compiled_in_invalid is not None:
|
|
347
|
-
return hot.compiled_in_invalid
|
|
348
|
-
if key == "in_errors" and hot.compiled_in_errors is not None:
|
|
349
|
-
return [dict(error) for error in hot.compiled_in_errors]
|
|
350
|
-
if key == "in_coerced" and hot.compiled_in_coerced:
|
|
351
|
-
return hot.compiled_in_coerced
|
|
352
|
-
return _LAZY_MISSING
|
|
353
|
-
|
|
354
|
-
def __setitem__(self, key: str, value: Any) -> None:
|
|
355
|
-
value = self._wrap_namespace(key, value)
|
|
356
|
-
dict.__setitem__(self, key, value)
|
|
357
|
-
if key == "jsonrpc_request_id":
|
|
358
|
-
hot = self._hot_ctx()
|
|
359
|
-
if hot is not None:
|
|
360
|
-
hot.dispatch_jsonrpc_request_id = value
|
|
361
|
-
|
|
362
|
-
def update(self, *args: Any, **kwargs: Any) -> None:
|
|
363
|
-
for mapping in args:
|
|
364
|
-
if isinstance(mapping, ABCMapping):
|
|
365
|
-
for key, value in mapping.items():
|
|
366
|
-
self[key] = value
|
|
367
|
-
else:
|
|
368
|
-
for key, value in dict(mapping).items():
|
|
369
|
-
self[key] = value
|
|
370
|
-
for key, value in kwargs.items():
|
|
371
|
-
self[key] = value
|
|
372
|
-
|
|
373
|
-
def setdefault(self, key: str, default: Any = None) -> Any:
|
|
374
|
-
if dict.__contains__(self, key):
|
|
375
|
-
return dict.__getitem__(self, key)
|
|
376
|
-
value = self._wrap_namespace(key, default)
|
|
377
|
-
dict.__setitem__(self, key, value)
|
|
378
|
-
return value
|
|
379
|
-
|
|
380
|
-
def __getitem__(self, key: str) -> Any:
|
|
381
|
-
try:
|
|
382
|
-
return dict.__getitem__(self, key)
|
|
383
|
-
except KeyError:
|
|
384
|
-
value = self._lazy_value(key)
|
|
385
|
-
if value is _LAZY_MISSING:
|
|
386
|
-
raise
|
|
387
|
-
dict.__setitem__(self, key, value)
|
|
388
|
-
return value
|
|
389
|
-
|
|
390
|
-
def get(self, key: str, default: Any = None) -> Any:
|
|
391
|
-
if dict.__contains__(self, key):
|
|
392
|
-
return dict.get(self, key, default)
|
|
393
|
-
value = self._lazy_value(key)
|
|
394
|
-
if value is _LAZY_MISSING:
|
|
395
|
-
return default
|
|
396
|
-
dict.__setitem__(self, key, value)
|
|
397
|
-
return value
|
|
398
|
-
|
|
399
|
-
def __contains__(self, key: object) -> bool:
|
|
400
|
-
if dict.__contains__(self, key):
|
|
401
|
-
return True
|
|
402
|
-
if not isinstance(key, str):
|
|
403
|
-
return False
|
|
404
|
-
return self._lazy_value(key) is not _LAZY_MISSING
|
|
405
|
-
|
|
406
|
-
def __delitem__(self, key: str) -> None:
|
|
407
|
-
dict.__delitem__(self, key)
|
|
408
|
-
if key == "jsonrpc_request_id":
|
|
409
|
-
hot = self._hot_ctx()
|
|
410
|
-
if hot is not None:
|
|
411
|
-
hot.dispatch_jsonrpc_request_id = None
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
__all__ = [
|
|
415
|
-
"_HotNamespaceDict",
|
|
416
|
-
"_HotTemp",
|
|
417
|
-
"_clear_hot_namespace_value",
|
|
418
|
-
"_coerce_optional_dict",
|
|
419
|
-
"_namespace_lazy_value",
|
|
420
|
-
"_sync_hot_namespace_value",
|
|
421
|
-
]
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping as ABCMapping
|
|
4
|
+
from typing import Any, Mapping
|
|
5
|
+
|
|
6
|
+
from .hot_state import (
|
|
7
|
+
HotCtx,
|
|
8
|
+
_ensure_hot_assembled_values_view,
|
|
9
|
+
_ensure_hot_in_values_view,
|
|
10
|
+
_ensure_hot_virtual_in_view,
|
|
11
|
+
_LAZY_MISSING,
|
|
12
|
+
)
|
|
13
|
+
from .hot_namespace_values import (
|
|
14
|
+
_clear_hot_namespace_value,
|
|
15
|
+
_coerce_optional_dict,
|
|
16
|
+
_namespace_lazy_value,
|
|
17
|
+
_sync_hot_namespace_value,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class _HotNamespaceDict(dict[str, Any]):
|
|
22
|
+
__slots__ = ("_kind", "_temp")
|
|
23
|
+
|
|
24
|
+
def __init__(
|
|
25
|
+
self, kind: str, temp: "_HotTemp", initial: Mapping[str, Any] | None = None
|
|
26
|
+
) -> None:
|
|
27
|
+
super().__init__(initial or {})
|
|
28
|
+
self._kind = kind
|
|
29
|
+
self._temp = temp
|
|
30
|
+
hot = temp._hot_ctx()
|
|
31
|
+
if hot is not None and initial:
|
|
32
|
+
for key, value in initial.items():
|
|
33
|
+
_sync_hot_namespace_value(kind, hot, key, value)
|
|
34
|
+
|
|
35
|
+
def _lazy_value(self, key: str) -> Any:
|
|
36
|
+
hot = self._temp._hot_ctx()
|
|
37
|
+
if hot is None:
|
|
38
|
+
return _LAZY_MISSING
|
|
39
|
+
return _namespace_lazy_value(self._kind, hot, key)
|
|
40
|
+
|
|
41
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
42
|
+
dict.__setitem__(self, key, value)
|
|
43
|
+
hot = self._temp._hot_ctx()
|
|
44
|
+
if hot is not None:
|
|
45
|
+
_sync_hot_namespace_value(self._kind, hot, key, value)
|
|
46
|
+
|
|
47
|
+
def __delitem__(self, key: str) -> None:
|
|
48
|
+
dict.__delitem__(self, key)
|
|
49
|
+
hot = self._temp._hot_ctx()
|
|
50
|
+
if hot is not None:
|
|
51
|
+
_clear_hot_namespace_value(self._kind, hot, key)
|
|
52
|
+
|
|
53
|
+
def __getitem__(self, key: str) -> Any:
|
|
54
|
+
try:
|
|
55
|
+
return dict.__getitem__(self, key)
|
|
56
|
+
except KeyError:
|
|
57
|
+
value = self._lazy_value(key)
|
|
58
|
+
if value is _LAZY_MISSING:
|
|
59
|
+
raise
|
|
60
|
+
dict.__setitem__(self, key, value)
|
|
61
|
+
return value
|
|
62
|
+
|
|
63
|
+
def get(self, key: str, default: Any = None) -> Any:
|
|
64
|
+
if dict.__contains__(self, key):
|
|
65
|
+
return dict.get(self, key, default)
|
|
66
|
+
value = self._lazy_value(key)
|
|
67
|
+
if value is _LAZY_MISSING:
|
|
68
|
+
return default
|
|
69
|
+
dict.__setitem__(self, key, value)
|
|
70
|
+
return value
|
|
71
|
+
|
|
72
|
+
def setdefault(self, key: str, default: Any = None) -> Any:
|
|
73
|
+
if dict.__contains__(self, key):
|
|
74
|
+
return dict.__getitem__(self, key)
|
|
75
|
+
self[key] = default
|
|
76
|
+
return default
|
|
77
|
+
|
|
78
|
+
def update(self, *args: Any, **kwargs: Any) -> None:
|
|
79
|
+
for mapping in args:
|
|
80
|
+
if isinstance(mapping, ABCMapping):
|
|
81
|
+
for key, value in mapping.items():
|
|
82
|
+
self[key] = value
|
|
83
|
+
else:
|
|
84
|
+
for key, value in dict(mapping).items():
|
|
85
|
+
self[key] = value
|
|
86
|
+
for key, value in kwargs.items():
|
|
87
|
+
self[key] = value
|
|
88
|
+
|
|
89
|
+
def pop(self, key: str, default: Any = _LAZY_MISSING) -> Any:
|
|
90
|
+
if dict.__contains__(self, key):
|
|
91
|
+
value = dict.pop(self, key)
|
|
92
|
+
hot = self._temp._hot_ctx()
|
|
93
|
+
if hot is not None:
|
|
94
|
+
_clear_hot_namespace_value(self._kind, hot, key)
|
|
95
|
+
return value
|
|
96
|
+
if default is _LAZY_MISSING:
|
|
97
|
+
raise KeyError(key)
|
|
98
|
+
return default
|
|
99
|
+
|
|
100
|
+
def __contains__(self, key: object) -> bool:
|
|
101
|
+
if dict.__contains__(self, key):
|
|
102
|
+
return True
|
|
103
|
+
if not isinstance(key, str):
|
|
104
|
+
return False
|
|
105
|
+
return self._lazy_value(key) is not _LAZY_MISSING
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class _HotTemp(dict[str, Any]):
|
|
109
|
+
__slots__ = ()
|
|
110
|
+
|
|
111
|
+
@classmethod
|
|
112
|
+
def from_mapping(cls, value: Mapping[str, Any] | None) -> "_HotTemp":
|
|
113
|
+
if isinstance(value, cls):
|
|
114
|
+
return value
|
|
115
|
+
temp = cls()
|
|
116
|
+
if value:
|
|
117
|
+
temp.update(value)
|
|
118
|
+
return temp
|
|
119
|
+
|
|
120
|
+
def _hot_ctx(self) -> HotCtx | None:
|
|
121
|
+
hot = dict.get(self, "hot_ctx")
|
|
122
|
+
return hot if isinstance(hot, HotCtx) else None
|
|
123
|
+
|
|
124
|
+
def _wrap_namespace(self, key: str, value: Any) -> Any:
|
|
125
|
+
if (
|
|
126
|
+
key in {"route", "dispatch", "egress"}
|
|
127
|
+
and isinstance(value, dict)
|
|
128
|
+
and not isinstance(value, _HotNamespaceDict)
|
|
129
|
+
):
|
|
130
|
+
return _HotNamespaceDict(key, self, value)
|
|
131
|
+
return value
|
|
132
|
+
|
|
133
|
+
def _lazy_value(self, key: str) -> Any:
|
|
134
|
+
hot = self._hot_ctx()
|
|
135
|
+
if hot is None:
|
|
136
|
+
return _LAZY_MISSING
|
|
137
|
+
if key in {"route", "dispatch", "egress"}:
|
|
138
|
+
return _HotNamespaceDict(key, self)
|
|
139
|
+
if key == "jsonrpc_request_id":
|
|
140
|
+
if hot.dispatch_jsonrpc_request_id is not None:
|
|
141
|
+
return hot.dispatch_jsonrpc_request_id
|
|
142
|
+
envelope = hot.dispatch_rpc_envelope or hot.route_rpc_envelope
|
|
143
|
+
if envelope is not None and "id" in envelope:
|
|
144
|
+
return envelope["id"]
|
|
145
|
+
if key == "compiled_in_values_ready" and hot.compiled_input_ready:
|
|
146
|
+
return True
|
|
147
|
+
if key == "in_values":
|
|
148
|
+
value = _ensure_hot_in_values_view(hot)
|
|
149
|
+
if value is not None:
|
|
150
|
+
return value
|
|
151
|
+
if key == "in_present" and hot.in_present_names:
|
|
152
|
+
return hot.in_present_names
|
|
153
|
+
if key == "assembled_values":
|
|
154
|
+
value = _ensure_hot_assembled_values_view(hot)
|
|
155
|
+
if value is not None:
|
|
156
|
+
return value
|
|
157
|
+
if key == "virtual_in":
|
|
158
|
+
value = _ensure_hot_virtual_in_view(hot)
|
|
159
|
+
if value is not None:
|
|
160
|
+
return value
|
|
161
|
+
if key == "absent_fields" and hot.absent_fields:
|
|
162
|
+
return hot.absent_fields
|
|
163
|
+
if key == "used_default_factory" and hot.used_default_factory:
|
|
164
|
+
return hot.used_default_factory
|
|
165
|
+
if key == "in_invalid" and hot.compiled_in_invalid is not None:
|
|
166
|
+
return hot.compiled_in_invalid
|
|
167
|
+
if key == "in_errors" and hot.compiled_in_errors is not None:
|
|
168
|
+
return [dict(error) for error in hot.compiled_in_errors]
|
|
169
|
+
if key == "in_coerced" and hot.compiled_in_coerced:
|
|
170
|
+
return hot.compiled_in_coerced
|
|
171
|
+
return _LAZY_MISSING
|
|
172
|
+
|
|
173
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
174
|
+
value = self._wrap_namespace(key, value)
|
|
175
|
+
dict.__setitem__(self, key, value)
|
|
176
|
+
if key == "jsonrpc_request_id":
|
|
177
|
+
hot = self._hot_ctx()
|
|
178
|
+
if hot is not None:
|
|
179
|
+
hot.dispatch_jsonrpc_request_id = value
|
|
180
|
+
|
|
181
|
+
def update(self, *args: Any, **kwargs: Any) -> None:
|
|
182
|
+
for mapping in args:
|
|
183
|
+
if isinstance(mapping, ABCMapping):
|
|
184
|
+
for key, value in mapping.items():
|
|
185
|
+
self[key] = value
|
|
186
|
+
else:
|
|
187
|
+
for key, value in dict(mapping).items():
|
|
188
|
+
self[key] = value
|
|
189
|
+
for key, value in kwargs.items():
|
|
190
|
+
self[key] = value
|
|
191
|
+
|
|
192
|
+
def setdefault(self, key: str, default: Any = None) -> Any:
|
|
193
|
+
if dict.__contains__(self, key):
|
|
194
|
+
return dict.__getitem__(self, key)
|
|
195
|
+
value = self._wrap_namespace(key, default)
|
|
196
|
+
dict.__setitem__(self, key, value)
|
|
197
|
+
return value
|
|
198
|
+
|
|
199
|
+
def __getitem__(self, key: str) -> Any:
|
|
200
|
+
try:
|
|
201
|
+
return dict.__getitem__(self, key)
|
|
202
|
+
except KeyError:
|
|
203
|
+
value = self._lazy_value(key)
|
|
204
|
+
if value is _LAZY_MISSING:
|
|
205
|
+
raise
|
|
206
|
+
dict.__setitem__(self, key, value)
|
|
207
|
+
return value
|
|
208
|
+
|
|
209
|
+
def get(self, key: str, default: Any = None) -> Any:
|
|
210
|
+
if dict.__contains__(self, key):
|
|
211
|
+
return dict.get(self, key, default)
|
|
212
|
+
value = self._lazy_value(key)
|
|
213
|
+
if value is _LAZY_MISSING:
|
|
214
|
+
return default
|
|
215
|
+
dict.__setitem__(self, key, value)
|
|
216
|
+
return value
|
|
217
|
+
|
|
218
|
+
def __contains__(self, key: object) -> bool:
|
|
219
|
+
if dict.__contains__(self, key):
|
|
220
|
+
return True
|
|
221
|
+
if not isinstance(key, str):
|
|
222
|
+
return False
|
|
223
|
+
return self._lazy_value(key) is not _LAZY_MISSING
|
|
224
|
+
|
|
225
|
+
def __delitem__(self, key: str) -> None:
|
|
226
|
+
dict.__delitem__(self, key)
|
|
227
|
+
if key == "jsonrpc_request_id":
|
|
228
|
+
hot = self._hot_ctx()
|
|
229
|
+
if hot is not None:
|
|
230
|
+
hot.dispatch_jsonrpc_request_id = None
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
__all__ = [
|
|
234
|
+
"_HotNamespaceDict",
|
|
235
|
+
"_HotTemp",
|
|
236
|
+
"_clear_hot_namespace_value",
|
|
237
|
+
"_coerce_optional_dict",
|
|
238
|
+
"_namespace_lazy_value",
|
|
239
|
+
"_sync_hot_namespace_value",
|
|
240
|
+
]
|