seldon-runtime 0.1.1.dev0__tar.gz → 0.1.1.dev2__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.
Files changed (70) hide show
  1. seldon_runtime-0.1.1.dev2/CHANGELOG.md +61 -0
  2. seldon_runtime-0.1.1.dev2/MANIFEST.in +5 -0
  3. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/NOTICE +4 -0
  4. {seldon_runtime-0.1.1.dev0/seldon_runtime.egg-info → seldon_runtime-0.1.1.dev2}/PKG-INFO +111 -7
  5. seldon_runtime-0.1.1.dev2/README.md +256 -0
  6. seldon_runtime-0.1.1.dev2/THIRD_PARTY_NOTICES.md +66 -0
  7. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/pyproject.toml +6 -2
  8. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/runtime_modules.txt +2 -0
  9. seldon_runtime-0.1.1.dev2/schemas/compiler-artifact-v1.json +1666 -0
  10. seldon_runtime-0.1.1.dev2/scripts/export_artifact_schema.py +38 -0
  11. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/__init__.py +1 -1
  12. seldon_runtime-0.1.1.dev2/seldon_runtime/artifact.py +336 -0
  13. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/contract_versions.py +1 -0
  14. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/contracts.py +1 -0
  15. seldon_runtime-0.1.1.dev2/seldon_runtime/data/o200k_base.tiktoken +199998 -0
  16. seldon_runtime-0.1.1.dev2/seldon_runtime/data/provenance.json +11 -0
  17. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/executor.py +4 -1
  18. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/output_budget.py +24 -7
  19. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/semantic.py +64 -6
  20. seldon_runtime-0.1.1.dev2/seldon_runtime/tokenizer.py +60 -0
  21. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2/seldon_runtime.egg-info}/PKG-INFO +111 -7
  22. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime.egg-info/SOURCES.txt +15 -0
  23. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime.egg-info/requires.txt +3 -0
  24. seldon_runtime-0.1.1.dev2/tests/fixtures/compiler-artifact/manifest.json +90 -0
  25. seldon_runtime-0.1.1.dev2/tests/fixtures/compiler-artifact-dev1/manifest.json +90 -0
  26. seldon_runtime-0.1.1.dev2/tests/fixtures/tokenizer_goldens.json +1417 -0
  27. seldon_runtime-0.1.1.dev2/tests/test_artifact.py +431 -0
  28. seldon_runtime-0.1.1.dev2/tests/test_correctness_repairs.py +161 -0
  29. seldon_runtime-0.1.1.dev2/tests/test_tokenizer.py +86 -0
  30. seldon_runtime-0.1.1.dev2/tests/tokenizer_cases.py +45 -0
  31. seldon_runtime-0.1.1.dev2/tests/wheel_probe.py +101 -0
  32. seldon_runtime-0.1.1.dev0/MANIFEST.in +0 -2
  33. seldon_runtime-0.1.1.dev0/README.md +0 -155
  34. seldon_runtime-0.1.1.dev0/tests/wheel_probe.py +0 -45
  35. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/LICENSE +0 -0
  36. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/attempt_bound.py +0 -0
  37. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/components.py +0 -0
  38. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/conditional.py +0 -0
  39. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/deadline.py +0 -0
  40. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/gliner_normalize.py +0 -0
  41. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/instruction_envelope.py +0 -0
  42. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/json_pointer.py +0 -0
  43. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/local.py +0 -0
  44. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/local_models.py +0 -0
  45. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/local_telemetry.py +0 -0
  46. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/native_schema.py +0 -0
  47. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/program_validation.py +0 -0
  48. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/provider_error.py +0 -0
  49. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/research_kernels.py +0 -0
  50. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/runner.py +0 -0
  51. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/telemetry.py +0 -0
  52. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/templates.py +0 -0
  53. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime/tool_wire.py +0 -0
  54. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime.egg-info/dependency_links.txt +0 -0
  55. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/seldon_runtime.egg-info/top_level.txt +0 -0
  56. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/setup.cfg +0 -0
  57. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/fixtures/digest_goldens.json +0 -0
  58. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/fixtures/local_gliner_raw.json +0 -0
  59. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/fixtures/serving_compat/function-plan-v1.json +0 -0
  60. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/fixtures/serving_compat/function-plan-v2.json +0 -0
  61. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/fixtures/serving_compat/function-plan-v3.json +0 -0
  62. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/fixtures/serving_compat/function-plan-v4.json +0 -0
  63. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/fixtures/serving_compat/function-plan-v5.json +0 -0
  64. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/installed_local_probe.py +0 -0
  65. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/test_contracts.py +0 -0
  66. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/test_gliner_normalize.py +0 -0
  67. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/test_import_closure.py +0 -0
  68. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/test_install.py +0 -0
  69. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/test_local.py +0 -0
  70. {seldon_runtime-0.1.1.dev0 → seldon_runtime-0.1.1.dev2}/tests/test_runner.py +0 -0
@@ -0,0 +1,61 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1.dev2 — unreleased
4
+
5
+ - Bundle the immutable o200k_base rank data and construct its encoding locally.
6
+ Token budgets and both historical/UTF-8 chunk boundaries previously depended on
7
+ tiktoken downloading a rank file on first use; a warm developer cache concealed
8
+ failures in isolated installations. No runtime download, ambient cache, or writable
9
+ tokenizer directory is now needed. The rank hash, regex, special tokens and all
10
+ existing token estimation policies remain unchanged.
11
+ - Record upstream code licenses, asset provenance and the lack of a separately
12
+ stated Azure asset license in THIRD_PARTY_NOTICES.md. Corrupt or missing packaged
13
+ tokenizer data fails closed; it never triggers a replacement download.
14
+ - Pin newly exported standalone manifests to runtime `0.1.1.dev2`. The reader
15
+ explicitly accepts both `0.1.1.dev1` and `0.1.1.dev2`: dev2 changes tokenizer
16
+ delivery, preserving dev1 token and plan semantics. Original dev1 manifests
17
+ remain immutable and executable without rewriting hashes. dev0 and unreviewed
18
+ future versions remain rejected; compatibility is not inferred from a range.
19
+ - Add frozen pre-change token/chunk vectors and cold-cache, network-denied
20
+ subprocess checks. Release wheel/sdist probes now forbid socket/DNS calls and
21
+ supply empty cache directories. Optional model weights remain separately prepared.
22
+
23
+ ## 0.1.1.dev1 — published 2026-11-30
24
+
25
+ Published through [Runtime Publish](https://github.com/Deep-Insight-Labs/seldon-runtime/actions/runs/46391393622)
26
+ after Linux compatibility checks, wheel/sdist verification and an installed-TestPyPI
27
+ probe. PyPI artifact hashes match the CI build. This release does not deploy hosted
28
+ Seldon or complete the compiler exporter.
29
+
30
+ ### Standalone compiler artifact reader
31
+
32
+ - Add a separate `compiler-artifact-v1` reader for a bounded, inline JSON manifest
33
+ and caller-owned asynchronous model bindings. Validate hashes, explicit semantic
34
+ versions, plan/spec compatibility, model capabilities and context/output bounds
35
+ before dispatch; no endpoint or credential is loaded from an artifact.
36
+ - Preserve the hosted `Runner`, bundle eligibility, authorization, expiry and
37
+ refresh behavior. Standalone artifacts have no control-plane or telemetry calls.
38
+ - Reject research code, native protocols not yet supported by this handoff, external
39
+ file references, symlinks, oversized manifests and secret-bearing configuration
40
+ fields. Hashes establish integrity relative to a manifest, not publisher trust;
41
+ prompts and specs remain potentially sensitive customer data.
42
+ - This is a reader implementation awaiting integration with the compiler exporter.
43
+ No live model has been qualified and no new serving capability has been enabled
44
+ in hosted Seldon.
45
+
46
+ ### Correctness contracts — implemented 2026-11-27
47
+
48
+ - Add `optimizer-correctness-v8` execution readers without changing historical
49
+ plan or spec digests.
50
+ - Add the explicit `chunk_text.token_boundary: "utf8-v2"` contract. Individual
51
+ tokenizer tokens can contain incomplete UTF-8 characters; decoding those tokens
52
+ independently previously counted the remaining document as one token. New
53
+ marked chunks keep complete source characters, full coverage and the actual
54
+ requested token budget. Unmarked chunks retain historical boundaries.
55
+ - Add `context_measured_v3`: native Fastino GLiNER extraction reserves its
56
+ inherited output allowance for accounting and response bounds without subtracting
57
+ it from the encoder input window. The actual provider input is still checked;
58
+ other protocols retain their existing context rules. Older policy values do
59
+ not change. The provider's encoder input contract is documented at
60
+ <https://docs.fastino.ai/inference/chat-completions>.
61
+ - Hosted rollout requires compatible readers before new marked runs are created.
@@ -0,0 +1,5 @@
1
+ include LICENSE NOTICE THIRD_PARTY_NOTICES.md README.md CHANGELOG.md runtime_modules.txt
2
+ recursive-include seldon_runtime/data *.tiktoken *.json
3
+ recursive-include tests *.py *.json
4
+ recursive-include schemas *.json
5
+ include scripts/export_artifact_schema.py
@@ -7,3 +7,7 @@ infrastructure and dashboard are not part of this distribution.
7
7
 
8
8
  Optional GLiNER2 code and downloaded model weights remain under their respective
9
9
  upstream licenses. Their licenses are not replaced by this project license.
10
+
11
+ The bundled o200k_base tokenizer constructor and vocabulary have separate upstream
12
+ provenance and MIT notices in THIRD_PARTY_NOTICES.md. That file records the absence
13
+ of a separately stated license for the Azure rank asset without claiming one.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seldon-runtime
3
- Version: 0.1.1.dev0
3
+ Version: 0.1.1.dev2
4
4
  Summary: Standalone Seldon Functions interpreter and local execution client
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Source, https://github.com/Deep-Insight-Labs/seldon-runtime
@@ -9,6 +9,7 @@ Requires-Python: >=3.11
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE
11
11
  License-File: NOTICE
12
+ License-File: THIRD_PARTY_NOTICES.md
12
13
  Requires-Dist: pydantic>=2.2
13
14
  Requires-Dist: jsonschema>=4.21
14
15
  Requires-Dist: tiktoken>=0.7
@@ -19,6 +20,8 @@ Requires-Dist: pytest>=8; extra == "dev"
19
20
  Requires-Dist: ruff==0.16.4; extra == "dev"
20
21
  Requires-Dist: build>=1; extra == "dev"
21
22
  Requires-Dist: twine>=6; extra == "dev"
23
+ Provides-Extra: schema
24
+ Requires-Dist: pydantic==2.14.4; extra == "schema"
22
25
  Dynamic: license-file
23
26
 
24
27
  # Seldon Runtime
@@ -32,27 +35,30 @@ Optimization and hosted comparison happen on Seldon. The runtime contains no
32
35
  optimizer, billing service, dashboard or server infrastructure. Its first local
33
36
  model adapter uses pinned GLiNER2 open weights for extraction and classification.
34
37
 
35
- This is a source preview. A source checkout or successful build does not establish
36
- PyPI publication, production feature activation, or quality on your own inputs.
38
+ The current preview, [`0.1.1.dev1`](https://pypi.org/project/seldon-runtime/0.1.1.dev1/),
39
+ is available on PyPI. Hosted bundle execution requires a Seldon deployment with
40
+ bundle delivery enabled for your workspace. The separate standalone artifact reader
41
+ uses caller-supplied model bindings without a Seldon service; its compiler exporter
42
+ is still in development.
37
43
 
38
44
  ## Install
39
45
 
40
46
  Python 3.11 or later is required. The base interpreter uses Pydantic, jsonschema
41
47
  and tiktoken. Local GLiNER inference additionally needs PyTorch and the model extra.
42
- Before publication, replace the package name below with a locally built wheel.
48
+ The commands below pin the published preview.
43
49
 
44
50
  On Linux, install CPU PyTorch explicitly to avoid downloading CUDA dependencies:
45
51
 
46
52
  ```sh
47
53
  python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
48
- python -m pip install 'seldon-runtime[gliner]'
54
+ python -m pip install 'seldon-runtime[gliner]==0.1.1.dev1'
49
55
  ```
50
56
 
51
57
  On macOS:
52
58
 
53
59
  ```sh
54
60
  python -m pip install torch
55
- python -m pip install 'seldon-runtime[gliner]'
61
+ python -m pip install 'seldon-runtime[gliner]==0.1.1.dev1'
56
62
  ```
57
63
 
58
64
  In a uv environment, use `uv pip install` for the same commands. In a Linux uv
@@ -60,13 +66,23 @@ project, persist the dedicated torch index:
60
66
 
61
67
  ```sh
62
68
  uv add torch --index pytorch=https://download.pytorch.org/whl/cpu
63
- uv add 'seldon-runtime[gliner]'
69
+ uv add 'seldon-runtime[gliner]==0.1.1.dev1'
64
70
  ```
65
71
 
66
72
  The model weights and tokenizer files download on first use. Cache the pinned
67
73
  snapshot in advance for restricted networks. Token-chunked plans also need the
68
74
  tiktoken BPE cache (`TIKTOKEN_CACHE_DIR`). Model weights are not bundled in the wheel.
69
75
 
76
+ The unreleased `0.1.1.dev2` candidate removes the separate tiktoken cache prerequisite:
77
+ its wheel and source distribution include the fixed `o200k_base` vocabulary used
78
+ for Seldon token budgets and chunking. The runtime verifies its hash and constructs
79
+ the encoding directly; it never downloads or repairs missing/corrupt tokenizer
80
+ data. No network or writable cache is required for these operations. Optional
81
+ GLiNER weights and their own tokenizer files still require advance preparation.
82
+ See [third-party notices](THIRD_PARTY_NOTICES.md) and
83
+ [asset provenance](seldon_runtime/data/provenance.json) for sources and license basis.
84
+ The published dev1 installation commands above retain their original prerequisites.
85
+
70
86
  ## Run a Function locally
71
87
 
72
88
  Only activated, locally eligible v3/v4 revisions can be loaded. Hosted-only models,
@@ -135,6 +151,94 @@ Always close the runner to stop background tasks and attempt a bounded flush.
135
151
 
136
152
  ## Development
137
153
 
154
+ ### Standalone compiler artifacts (unreleased)
155
+
156
+ The separate compiler-artifact reader executes locally compiled user-owned plans.
157
+ It does not use `Runner.load`, hosted Function IDs, a Seldon API key, refresh or
158
+ telemetry. This reader is under development; a public compiler/exporter is not yet
159
+ available. The existing hosted-bundle instructions above remain unchanged.
160
+
161
+ An export directory contains one `manifest.json`, at most 2 MiB. Plan and spec are
162
+ inline; no file paths, URLs, credentials or executable Python are supported. The
163
+ generated [JSON schema](schemas/compiler-artifact-v1.json) defines the envelope.
164
+ Schema generation uses a separately pinned development dependency because supported
165
+ Pydantic versions emit different schema descriptions. Runtime compatibility remains
166
+ `pydantic>=2.2`; all supported versions run the semantic reader tests. Regenerate in
167
+ a development environment with `python -m pip install '.[schema]'` followed by
168
+ `python -m scripts.export_artifact_schema`. CI checks the committed schema using
169
+ that generator's `--check` mode, independently of the runtime compatibility matrix.
170
+
171
+ The manifest freezes the compiler version and an explicit runtime version. New
172
+ exports target the current producer version (`0.1.1.dev2` in this unreleased
173
+ candidate). The dev2 reader accepts the reviewed set `0.1.1.dev1` and `0.1.1.dev2`;
174
+ original dev1 manifests retain their pin and hashes. This packaging fix preserves
175
+ token and plan semantics. dev0 and future versions are rejected until explicitly
176
+ reviewed; there is no version-prefix or range-based compatibility inference.
177
+ The manifest also freezes the optimizer contract (v1–v8), evaluation semantics,
178
+ instruction envelope, conditional
179
+ permission, plan/spec hashes, model requirements and a small evidence summary.
180
+ `manifest_digest` is the canonical runtime `digest` of all raw manifest fields
181
+ except `manifest_digest`. Plan/spec digests use their validated model `.digest`.
182
+ Omitted/default fields therefore follow the existing runtime serialization contract.
183
+
184
+ Supply endpoint configuration and credentials through your own transport, never
185
+ through the artifact. For example, given an independently configured asynchronous
186
+ `customer_provider(payload)` that returns decoded JSON output:
187
+
188
+ ```python
189
+ from seldon_runtime.artifact import ModelRequirements, RuntimeBinding, load_artifact
190
+
191
+ artifact = load_artifact("./selected-pipeline")
192
+ configured_model = ModelRequirements(
193
+ protocol="openai-chat-completions",
194
+ capabilities=("chat", "structured_output"),
195
+ context_length=8192,
196
+ max_output_tokens=256,
197
+ revision="deployment-1",
198
+ )
199
+ bindings = {"custom": RuntimeBinding(configured_model, customer_provider)}
200
+ result = await artifact.run({"text": "customer input"}, bindings=bindings, timeout=55)
201
+ ```
202
+
203
+ The binding keys must exactly cover the models used by the plan and its explicit
204
+ reference fallback. Configure capabilities and revision from your actual endpoint;
205
+ copying them from an untrusted artifact does not qualify a model. Protocol/revision
206
+ and output ceiling must match, capabilities must cover the requirements, and context
207
+ must be at least the declared size. The reader applies the frozen output/context
208
+ policy before invoking a provider; your transport still owns TLS, credential origin
209
+ binding, response-size limits and protocol decoding. Known transport failures use
210
+ `ProviderError`; untyped failures stop without automatic fallback or retry.
211
+
212
+ This initial handoff supports OpenAI-compatible chat steps and supported deterministic
213
+ operators, including versioned chunking/conditional graphs. Native `choice`/`extract`
214
+ adapters and research `generated_kernel` steps are explicitly rejected. A model
215
+ revision is an operator-supplied identity, not proof of immutable upstream weights.
216
+ Artifacts may contain sensitive prompts/spec text. Digest checks detect corruption,
217
+ not malicious replacement of both the content and its digest; trust the producer
218
+ separately. Linux/macOS filesystem APIs are used; Windows is not qualified.
219
+
220
+ The standalone fixture in `tests/fixtures/compiler-artifact` is generated from the
221
+ runtime test factory, pending a real compiler producer. Installed wheel/sdist probes
222
+ exercise its nonconstant execution through the real interpreter with a deterministic
223
+ provider callback. They do not qualify a live model, compiler selection quality or
224
+ the complete compiler-to-runtime lifecycle.
225
+
226
+ ### Interpreter development
227
+
228
+ The published `0.1.1.dev1` readers support `optimizer-correctness-v8`.
229
+ New `chunk_text` steps may freeze `token_boundary: "utf8-v2"` with `unit: "tokens"`;
230
+ this counts tokenizer tokens without splitting UTF-8 characters. Steps without
231
+ the marker keep their historical chunk boundaries. The kernel still enforces its
232
+ 32-chunk cap, and hosted plans may set a lower fan-out cap.
233
+
234
+ `context_measured_v3` treats native Fastino GLiNER extraction as an encoder input
235
+ window. Its inherited LLM output allowance still bounds financial reservations,
236
+ response sizing and admission tokens; it no longer consumes encoder input context.
237
+ Other native protocols retain `context_measured_v2` context rules. These policies
238
+ are frozen identities: existing bundles and requests keep their saved behavior.
239
+ See [the changelog](CHANGELOG.md). Upgrade readers before creating these new
240
+ contracts; an old runtime must not serve a new marked plan or policy.
241
+
138
242
  ```sh
139
243
  python -m pip install -e '.[dev]'
140
244
  python -m ruff check .
@@ -0,0 +1,256 @@
1
+ # Seldon Runtime
2
+
3
+ `seldon-runtime` is the standalone Python interpreter and local execution client
4
+ for eligible Seldon Functions. The package name is **`seldon-runtime`**, and the
5
+ Python import is `seldon_runtime`. This project is separate from SeldonIO.
6
+
7
+ A single generic runtime executes authorized Function bundles on your hardware.
8
+ Optimization and hosted comparison happen on Seldon. The runtime contains no
9
+ optimizer, billing service, dashboard or server infrastructure. Its first local
10
+ model adapter uses pinned GLiNER2 open weights for extraction and classification.
11
+
12
+ The current preview, [`0.1.1.dev1`](https://pypi.org/project/seldon-runtime/0.1.1.dev1/),
13
+ is available on PyPI. Hosted bundle execution requires a Seldon deployment with
14
+ bundle delivery enabled for your workspace. The separate standalone artifact reader
15
+ uses caller-supplied model bindings without a Seldon service; its compiler exporter
16
+ is still in development.
17
+
18
+ ## Install
19
+
20
+ Python 3.11 or later is required. The base interpreter uses Pydantic, jsonschema
21
+ and tiktoken. Local GLiNER inference additionally needs PyTorch and the model extra.
22
+ The commands below pin the published preview.
23
+
24
+ On Linux, install CPU PyTorch explicitly to avoid downloading CUDA dependencies:
25
+
26
+ ```sh
27
+ python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
28
+ python -m pip install 'seldon-runtime[gliner]==0.1.1.dev1'
29
+ ```
30
+
31
+ On macOS:
32
+
33
+ ```sh
34
+ python -m pip install torch
35
+ python -m pip install 'seldon-runtime[gliner]==0.1.1.dev1'
36
+ ```
37
+
38
+ In a uv environment, use `uv pip install` for the same commands. In a Linux uv
39
+ project, persist the dedicated torch index:
40
+
41
+ ```sh
42
+ uv add torch --index pytorch=https://download.pytorch.org/whl/cpu
43
+ uv add 'seldon-runtime[gliner]==0.1.1.dev1'
44
+ ```
45
+
46
+ The model weights and tokenizer files download on first use. Cache the pinned
47
+ snapshot in advance for restricted networks. Token-chunked plans also need the
48
+ tiktoken BPE cache (`TIKTOKEN_CACHE_DIR`). Model weights are not bundled in the wheel.
49
+
50
+ The unreleased `0.1.1.dev2` candidate removes the separate tiktoken cache prerequisite:
51
+ its wheel and source distribution include the fixed `o200k_base` vocabulary used
52
+ for Seldon token budgets and chunking. The runtime verifies its hash and constructs
53
+ the encoding directly; it never downloads or repairs missing/corrupt tokenizer
54
+ data. No network or writable cache is required for these operations. Optional
55
+ GLiNER weights and their own tokenizer files still require advance preparation.
56
+ See [third-party notices](THIRD_PARTY_NOTICES.md) and
57
+ [asset provenance](seldon_runtime/data/provenance.json) for sources and license basis.
58
+ The published dev1 installation commands above retain their original prerequisites.
59
+
60
+ ## Run a Function locally
61
+
62
+ Only activated, locally eligible v3/v4 revisions can be loaded. Hosted-only models,
63
+ reference-bound Functions and v5 plans are ineligible. Authorization uses your
64
+ workspace API key; it does not grant management access.
65
+
66
+ ```python
67
+ import asyncio
68
+ import os
69
+
70
+ from seldon_runtime.runner import Runner
71
+
72
+
73
+ async def main():
74
+ runner = await Runner.load(
75
+ "FUNCTION_UUID",
76
+ os.environ["SELDON_API_KEY"],
77
+ fallback="raise",
78
+ telemetry=False,
79
+ )
80
+ try:
81
+ result = await runner({"document": "Ada works at Acme"})
82
+ print(result["output"])
83
+ print(runner.status())
84
+ finally:
85
+ await runner.aclose()
86
+
87
+
88
+ asyncio.run(main())
89
+ ```
90
+
91
+ Use the input names from your Function contract. Each result also reports
92
+ `fallback_used` and `fallback_reason`. `LocalExecutionError.reason` is a bounded
93
+ machine-readable code; errors do not expose credentials or internal paths.
94
+
95
+ `fallback="raise"` prevents hosted inference fallback. `fallback="seldon"` sends
96
+ failed calls to Seldon and incurs ordinary hosted usage charges. An explicit
97
+ `{"endpoint": "...", "api_key": "..."}` uses your own OpenAI-compatible endpoint.
98
+ A failed initial verification raises before installing the bundle.
99
+
100
+ The [Seldon Python SDK](https://github.com/Deep-Insight-Labs/seldon-python) provides
101
+ optional typed declarations and `seldon function pull`, `verify` and `run` commands
102
+ using this runtime. It is not required for direct `Runner` use.
103
+
104
+ ## Verification and refresh
105
+
106
+ `Runner.load()` checks at least 95% exact agreement against the revision's held-out
107
+ conformance set before installing a new revision/model/runtime combination.
108
+ `await runner.verify()` reruns up to 200 local inputs and reports agreement,
109
+ sample count and p50/p95 latency. This measures agreement on that set, not business
110
+ correctness or coverage of all inputs. `allow_unverified=True` explicitly skips
111
+ verification and is not parity evidence.
112
+
113
+ Bundles are cached without API keys, revalidated at load and every 15 minutes on
114
+ a long-lived event loop. A failed refresh keeps the last validated revision for
115
+ at most 24 hours from its last successful check; expiry applies your fallback
116
+ policy. A disabled, deleted or unauthorized Function stops serving when observed.
117
+ Short-lived loops may not finish background refresh, so the 24-hour expiry is the
118
+ upper bound. Local execution still needs these control-plane calls.
119
+
120
+ `runner.status()` reads current local state without network or inference. Optional
121
+ reporting sends bounded counts, latency histograms and status outside inference;
122
+ it never sends inputs, outputs or payload hashes. `telemetry=False` disables both
123
+ usage and status reporting. Reports are best effort and are not billing authority.
124
+ Always close the runner to stop background tasks and attempt a bounded flush.
125
+
126
+ ## Development
127
+
128
+ ### Standalone compiler artifacts (unreleased)
129
+
130
+ The separate compiler-artifact reader executes locally compiled user-owned plans.
131
+ It does not use `Runner.load`, hosted Function IDs, a Seldon API key, refresh or
132
+ telemetry. This reader is under development; a public compiler/exporter is not yet
133
+ available. The existing hosted-bundle instructions above remain unchanged.
134
+
135
+ An export directory contains one `manifest.json`, at most 2 MiB. Plan and spec are
136
+ inline; no file paths, URLs, credentials or executable Python are supported. The
137
+ generated [JSON schema](schemas/compiler-artifact-v1.json) defines the envelope.
138
+ Schema generation uses a separately pinned development dependency because supported
139
+ Pydantic versions emit different schema descriptions. Runtime compatibility remains
140
+ `pydantic>=2.2`; all supported versions run the semantic reader tests. Regenerate in
141
+ a development environment with `python -m pip install '.[schema]'` followed by
142
+ `python -m scripts.export_artifact_schema`. CI checks the committed schema using
143
+ that generator's `--check` mode, independently of the runtime compatibility matrix.
144
+
145
+ The manifest freezes the compiler version and an explicit runtime version. New
146
+ exports target the current producer version (`0.1.1.dev2` in this unreleased
147
+ candidate). The dev2 reader accepts the reviewed set `0.1.1.dev1` and `0.1.1.dev2`;
148
+ original dev1 manifests retain their pin and hashes. This packaging fix preserves
149
+ token and plan semantics. dev0 and future versions are rejected until explicitly
150
+ reviewed; there is no version-prefix or range-based compatibility inference.
151
+ The manifest also freezes the optimizer contract (v1–v8), evaluation semantics,
152
+ instruction envelope, conditional
153
+ permission, plan/spec hashes, model requirements and a small evidence summary.
154
+ `manifest_digest` is the canonical runtime `digest` of all raw manifest fields
155
+ except `manifest_digest`. Plan/spec digests use their validated model `.digest`.
156
+ Omitted/default fields therefore follow the existing runtime serialization contract.
157
+
158
+ Supply endpoint configuration and credentials through your own transport, never
159
+ through the artifact. For example, given an independently configured asynchronous
160
+ `customer_provider(payload)` that returns decoded JSON output:
161
+
162
+ ```python
163
+ from seldon_runtime.artifact import ModelRequirements, RuntimeBinding, load_artifact
164
+
165
+ artifact = load_artifact("./selected-pipeline")
166
+ configured_model = ModelRequirements(
167
+ protocol="openai-chat-completions",
168
+ capabilities=("chat", "structured_output"),
169
+ context_length=8192,
170
+ max_output_tokens=256,
171
+ revision="deployment-1",
172
+ )
173
+ bindings = {"custom": RuntimeBinding(configured_model, customer_provider)}
174
+ result = await artifact.run({"text": "customer input"}, bindings=bindings, timeout=55)
175
+ ```
176
+
177
+ The binding keys must exactly cover the models used by the plan and its explicit
178
+ reference fallback. Configure capabilities and revision from your actual endpoint;
179
+ copying them from an untrusted artifact does not qualify a model. Protocol/revision
180
+ and output ceiling must match, capabilities must cover the requirements, and context
181
+ must be at least the declared size. The reader applies the frozen output/context
182
+ policy before invoking a provider; your transport still owns TLS, credential origin
183
+ binding, response-size limits and protocol decoding. Known transport failures use
184
+ `ProviderError`; untyped failures stop without automatic fallback or retry.
185
+
186
+ This initial handoff supports OpenAI-compatible chat steps and supported deterministic
187
+ operators, including versioned chunking/conditional graphs. Native `choice`/`extract`
188
+ adapters and research `generated_kernel` steps are explicitly rejected. A model
189
+ revision is an operator-supplied identity, not proof of immutable upstream weights.
190
+ Artifacts may contain sensitive prompts/spec text. Digest checks detect corruption,
191
+ not malicious replacement of both the content and its digest; trust the producer
192
+ separately. Linux/macOS filesystem APIs are used; Windows is not qualified.
193
+
194
+ The standalone fixture in `tests/fixtures/compiler-artifact` is generated from the
195
+ runtime test factory, pending a real compiler producer. Installed wheel/sdist probes
196
+ exercise its nonconstant execution through the real interpreter with a deterministic
197
+ provider callback. They do not qualify a live model, compiler selection quality or
198
+ the complete compiler-to-runtime lifecycle.
199
+
200
+ ### Interpreter development
201
+
202
+ The published `0.1.1.dev1` readers support `optimizer-correctness-v8`.
203
+ New `chunk_text` steps may freeze `token_boundary: "utf8-v2"` with `unit: "tokens"`;
204
+ this counts tokenizer tokens without splitting UTF-8 characters. Steps without
205
+ the marker keep their historical chunk boundaries. The kernel still enforces its
206
+ 32-chunk cap, and hosted plans may set a lower fan-out cap.
207
+
208
+ `context_measured_v3` treats native Fastino GLiNER extraction as an encoder input
209
+ window. Its inherited LLM output allowance still bounds financial reservations,
210
+ response sizing and admission tokens; it no longer consumes encoder input context.
211
+ Other native protocols retain `context_measured_v2` context rules. These policies
212
+ are frozen identities: existing bundles and requests keep their saved behavior.
213
+ See [the changelog](CHANGELOG.md). Upgrade readers before creating these new
214
+ contracts; an old runtime must not serve a new marked plan or policy.
215
+
216
+ ```sh
217
+ python -m pip install -e '.[dev]'
218
+ python -m ruff check .
219
+ python -m ruff format --check .
220
+ python -m pytest -q
221
+ python -m build
222
+ python -m twine check dist/*
223
+ python scripts/verify_artifacts.py dist/*
224
+ ```
225
+
226
+ Default tests replace model weights and HTTP at explicit runtime seams. They
227
+ exercise execution, output normalization, authorization refusals, conformance,
228
+ refresh, cache handling, fallback and reporting. Synthetic frozen plan/spec
229
+ fixtures check serialization and digest stability. No private repository or
230
+ server package is required. Run `pytest -m local_model` only after installing the
231
+ GLiNER extra; it downloads or reuses the pinned model weights.
232
+
233
+ `tests/installed_local_probe.py` verifies a real installed GLiNER runtime in a
234
+ server-free environment. Base-wheel installation alone does not qualify native
235
+ model dependencies or performance. Existing model probes cover macOS ARM64 and
236
+ Linux ARM64 CPU; other hardware and Windows are not claimed as qualified.
237
+
238
+ ## Releases
239
+
240
+ The publishing workflow is `.github/workflows/runtime-publish.yml` in
241
+ `Deep-Insight-Labs/seldon-runtime`. Register project `seldon-runtime` as a trusted
242
+ publisher on TestPyPI with environment `testpypi`, and on PyPI with environment
243
+ `pypi`. A `runtime-v<version>` tag must match `pyproject.toml` and `__version__`.
244
+
245
+ Publication is disabled unless `SELDON_RUNTIME_TESTPYPI_PUBLISH_ENABLED` and
246
+ `SELDON_RUNTIME_PUBLISH_ENABLED` are enabled separately. The workflow checks the
247
+ standalone project, builds wheel and sdist, publishes to TestPyPI, downloads and
248
+ installs that exact wheel with normal dependencies from PyPI, then publishes the
249
+ original checked artifacts to PyPI. A manual branch dispatch only builds artifacts.
250
+ No stored registry token is required. Registry versions are immutable.
251
+
252
+ ## License
253
+
254
+ Apache-2.0; see [LICENSE](LICENSE) and [NOTICE](NOTICE). Optional GLiNER2 code and
255
+ downloaded weights retain their own upstream licenses. The release is scoped to
256
+ this repository; it does not license the separately operated Seldon service.
@@ -0,0 +1,66 @@
1
+ # Third-party notices
2
+
3
+ Seldon Runtime's original code remains Apache-2.0. These upstream MIT notices
4
+ cover copied constructor/regex code and document vocabulary provenance; they
5
+ do not replace this distribution's license.
6
+
7
+ `data/o200k_base.tiktoken` is copied unchanged from OpenAI's public encoding URL.
8
+ Its SHA-256 and upstream constructor revision are in `data/provenance.json`.
9
+ The same bytes were independently verified in the MIT-licensed tiktoken-rs
10
+ repository at the recorded commit. No separate license statement for the Azure
11
+ rank file was located. The upstream project's MIT license and that existing
12
+ redistribution are the recorded basis, not an assertion of a separate asset
13
+ license or a legal determination.
14
+
15
+ ## OpenAI tiktoken (regex/constructor and vocabulary provenance)
16
+
17
+ Source: https://raw.githubusercontent.com/openai/tiktoken/bfe00ad1bf59fac47513b45fe5173672dcbbcbb4/LICENSE
18
+
19
+ MIT License
20
+
21
+ Copyright (c) 2022 OpenAI, Shantanu Jain
22
+
23
+ Permission is hereby granted, free of charge, to any person obtaining a copy
24
+ of this software and associated documentation files (the "Software"), to deal
25
+ in the Software without restriction, including without limitation the rights
26
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
+ copies of the Software, and to permit persons to whom the Software is
28
+ furnished to do so, subject to the following conditions:
29
+
30
+ The above copyright notice and this permission notice shall be included in all
31
+ copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
+ SOFTWARE.
40
+
41
+
42
+ ## tiktoken-rs (byte-identical vocabulary redistribution provenance)
43
+
44
+ Source: https://raw.githubusercontent.com/zurawiki/tiktoken-rs/72a5a800651a1cea1ad609292446ba02c80e3bcd/LICENSE
45
+
46
+ MIT License
47
+
48
+ Copyright (c) 2023 Roger Zurawicki
49
+
50
+ Permission is hereby granted, free of charge, to any person obtaining a copy
51
+ of this software and associated documentation files (the "Software"), to deal
52
+ in the Software without restriction, including without limitation the rights
53
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
54
+ copies of the Software, and to permit persons to whom the Software is
55
+ furnished to do so, subject to the following conditions:
56
+
57
+ The above copyright notice and this permission notice shall be included in all
58
+ copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
61
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
62
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
63
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
64
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
65
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
66
+ SOFTWARE.
@@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "seldon-runtime"
7
- version = "0.1.1.dev0"
7
+ version = "0.1.1.dev2"
8
8
  description = "Standalone Seldon Functions interpreter and local execution client"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
11
- license-files = ["LICENSE", "NOTICE"]
11
+ license-files = ["LICENSE", "NOTICE", "THIRD_PARTY_NOTICES.md"]
12
12
  requires-python = ">=3.11"
13
13
  dependencies = ["pydantic>=2.2", "jsonschema>=4.21", "tiktoken>=0.7"]
14
14
 
@@ -19,10 +19,14 @@ Issues = "https://github.com/Deep-Insight-Labs/seldon-runtime/issues"
19
19
  [project.optional-dependencies]
20
20
  gliner = ["gliner2[local]~=2.1.0"]
21
21
  dev = ["pytest>=8", "ruff==0.16.4", "build>=1", "twine>=6"]
22
+ schema = ["pydantic==2.14.4"]
22
23
 
23
24
  [tool.setuptools]
24
25
  packages = ["seldon_runtime"]
25
26
 
27
+ [tool.setuptools.package-data]
28
+ seldon_runtime = ["data/*.tiktoken", "data/*.json"]
29
+
26
30
  [tool.pytest.ini_options]
27
31
  testpaths = ["tests"]
28
32
  markers = [
@@ -19,3 +19,5 @@ output_budget
19
19
  instruction_envelope
20
20
  local_models
21
21
  local_telemetry
22
+ artifact
23
+ tokenizer