seldon-sdk 0.1.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- seldon_sdk/__init__.py +23 -0
- seldon_sdk/__init__.pyi +30 -0
- seldon_sdk/auth.py +286 -0
- seldon_sdk/cli.py +344 -0
- seldon_sdk/contract.py +200 -0
- seldon_sdk/decorator.py +114 -0
- seldon_sdk/errors.py +37 -0
- seldon_sdk/files.py +350 -0
- seldon_sdk/local.py +69 -0
- seldon_sdk/lockfile.py +42 -0
- seldon_sdk/management.py +532 -0
- seldon_sdk/preparation.py +225 -0
- seldon_sdk/py.typed +0 -0
- seldon_sdk/runtime.py +375 -0
- seldon_sdk/scanner.py +143 -0
- seldon_sdk/skill/SKILL.md +61 -0
- seldon_sdk/testing.py +32 -0
- seldon_sdk/testing.pyi +12 -0
- seldon_sdk-0.1.0.dev0.dist-info/METADATA +263 -0
- seldon_sdk-0.1.0.dev0.dist-info/RECORD +23 -0
- seldon_sdk-0.1.0.dev0.dist-info/WHEEL +4 -0
- seldon_sdk-0.1.0.dev0.dist-info/entry_points.txt +2 -0
- seldon_sdk-0.1.0.dev0.dist-info/licenses/LICENSE +202 -0
seldon_sdk/scanner.py
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"""Conservative AST discovery. No imports, prompt output, network or volume estimates."""
|
|
2
|
+
|
|
3
|
+
import ast
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
EXCLUDED = {".git", ".venv", "venv", "node_modules", "__pycache__"}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def scan(path, *, suggest=False, format="existing"):
|
|
10
|
+
path = Path(path)
|
|
11
|
+
files = [path] if path.is_file() else sorted(path.rglob("*.py"))
|
|
12
|
+
rows = []
|
|
13
|
+
for file in files:
|
|
14
|
+
if any(part in EXCLUDED for part in file.parts):
|
|
15
|
+
continue
|
|
16
|
+
if file.stat().st_size > 1_048_576:
|
|
17
|
+
continue
|
|
18
|
+
try:
|
|
19
|
+
tree = ast.parse(file.read_text())
|
|
20
|
+
except (SyntaxError, UnicodeError):
|
|
21
|
+
continue
|
|
22
|
+
constants, aliases, clients, parents = {}, {}, {}, {}
|
|
23
|
+
for parent in ast.walk(tree):
|
|
24
|
+
for child in ast.iter_child_nodes(parent):
|
|
25
|
+
parents[child] = parent
|
|
26
|
+
if isinstance(parent, ast.ImportFrom):
|
|
27
|
+
for item in parent.names:
|
|
28
|
+
aliases[item.asname or item.name] = (parent.module or "") + "." + item.name
|
|
29
|
+
elif isinstance(parent, ast.Import):
|
|
30
|
+
for item in parent.names:
|
|
31
|
+
aliases[item.asname or item.name] = item.name
|
|
32
|
+
elif isinstance(parent, ast.Assign):
|
|
33
|
+
for target in parent.targets:
|
|
34
|
+
if isinstance(target, ast.Name):
|
|
35
|
+
if isinstance(parent.value, ast.Constant) and isinstance(
|
|
36
|
+
parent.value.value, str
|
|
37
|
+
):
|
|
38
|
+
constants[target.id] = parent.value.value
|
|
39
|
+
elif isinstance(parent.value, ast.Call):
|
|
40
|
+
clients[target.id] = ast.unparse(parent.value.func)
|
|
41
|
+
|
|
42
|
+
def ancestry(node, parents=parents):
|
|
43
|
+
while node in parents:
|
|
44
|
+
node = parents[node]
|
|
45
|
+
yield node
|
|
46
|
+
|
|
47
|
+
for node in ast.walk(tree):
|
|
48
|
+
if not isinstance(node, ast.Call):
|
|
49
|
+
continue
|
|
50
|
+
name = ast.unparse(node.func)
|
|
51
|
+
parts = name.split(".")
|
|
52
|
+
root = clients.get(parts[0], aliases.get(parts[0], parts[0]))
|
|
53
|
+
resolved = aliases.get(root, root) + "." + ".".join(parts[1:])
|
|
54
|
+
lower = resolved.lower()
|
|
55
|
+
framework = None
|
|
56
|
+
if parts[-1] in {"create", "parse"} and (
|
|
57
|
+
"openai" in lower or ".chat.completions." in name or ".responses." in name
|
|
58
|
+
):
|
|
59
|
+
framework = "openai"
|
|
60
|
+
elif parts[-1] in {"completion", "acompletion"} and "litellm" in lower:
|
|
61
|
+
framework = "litellm"
|
|
62
|
+
elif parts[-1] in {"invoke", "ainvoke", "with_structured_output"} and (
|
|
63
|
+
"langchain" in lower or "chatopenai" in lower or parts[0] in clients
|
|
64
|
+
):
|
|
65
|
+
framework = "langchain"
|
|
66
|
+
elif parts[-1] == "Agent" and "pydantic_ai" in lower:
|
|
67
|
+
framework = "pydantic_ai"
|
|
68
|
+
if framework is None:
|
|
69
|
+
continue
|
|
70
|
+
keywords = {item.arg: item.value for item in node.keywords if item.arg}
|
|
71
|
+
reasons = []
|
|
72
|
+
if isinstance(keywords.get("stream"), ast.Constant) and keywords["stream"].value:
|
|
73
|
+
reasons.append("streaming")
|
|
74
|
+
if "tools" in keywords:
|
|
75
|
+
reasons.append("tool_use")
|
|
76
|
+
if "message_history" in keywords or any(
|
|
77
|
+
isinstance(parent, (ast.For, ast.While, ast.AsyncFor)) for parent in ancestry(node)
|
|
78
|
+
):
|
|
79
|
+
reasons.append("conversation_history")
|
|
80
|
+
source = None
|
|
81
|
+
for candidate in ast.walk(node):
|
|
82
|
+
if isinstance(candidate, ast.Name) and candidate.id in constants:
|
|
83
|
+
source = candidate.id
|
|
84
|
+
break
|
|
85
|
+
structured = (
|
|
86
|
+
"schema"
|
|
87
|
+
if set(keywords) & {"response_format", "output_type", "result_type"}
|
|
88
|
+
or parts[-1] in {"parse", "with_structured_output"}
|
|
89
|
+
else "none"
|
|
90
|
+
)
|
|
91
|
+
if any(
|
|
92
|
+
isinstance(keywords.get(key), ast.Name) and keywords[key].id == "str"
|
|
93
|
+
for key in ("output_type", "result_type")
|
|
94
|
+
):
|
|
95
|
+
structured = "text"
|
|
96
|
+
if source is None:
|
|
97
|
+
reasons.append("dynamic_prompt")
|
|
98
|
+
eligibility = (
|
|
99
|
+
"out_of_scope"
|
|
100
|
+
if any(
|
|
101
|
+
reason in reasons
|
|
102
|
+
for reason in ("streaming", "tool_use", "conversation_history")
|
|
103
|
+
)
|
|
104
|
+
else "needs_change"
|
|
105
|
+
if "dynamic_prompt" in reasons
|
|
106
|
+
else "eligible"
|
|
107
|
+
)
|
|
108
|
+
row = {
|
|
109
|
+
"file": str(file),
|
|
110
|
+
"line": node.lineno,
|
|
111
|
+
"framework": framework,
|
|
112
|
+
"structured_output": structured,
|
|
113
|
+
"template_source": source,
|
|
114
|
+
"eligibility": eligibility,
|
|
115
|
+
"reasons": reasons,
|
|
116
|
+
}
|
|
117
|
+
if suggest and eligibility == "eligible":
|
|
118
|
+
row["suggestion"] = (
|
|
119
|
+
"seldon import --source operation.json; "
|
|
120
|
+
"replace selected call model with its Function alias"
|
|
121
|
+
)
|
|
122
|
+
if format == "sdk":
|
|
123
|
+
row["suggestion"] = (
|
|
124
|
+
"Use @seldon.function with the selected fixed template "
|
|
125
|
+
"and explicit typed parameters"
|
|
126
|
+
)
|
|
127
|
+
row["render_differences"] = (
|
|
128
|
+
"Non-string inputs use canonical JSON; review against str.format"
|
|
129
|
+
)
|
|
130
|
+
rows.append(row)
|
|
131
|
+
order = {"eligible": 0, "needs_change": 1, "out_of_scope": 2}
|
|
132
|
+
return {
|
|
133
|
+
"items": sorted(
|
|
134
|
+
rows,
|
|
135
|
+
key=lambda item: (
|
|
136
|
+
order[item["eligibility"]],
|
|
137
|
+
item["structured_output"] == "none",
|
|
138
|
+
item["template_source"] is None,
|
|
139
|
+
item["file"],
|
|
140
|
+
item["line"],
|
|
141
|
+
),
|
|
142
|
+
)
|
|
143
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: seldon-operation
|
|
3
|
+
description: Compare and adopt one explicitly selected AI operation through Seldon Functions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Improve one selected operation
|
|
7
|
+
|
|
8
|
+
Use only the selected call and its immediate dependencies. Never upload the whole repository.
|
|
9
|
+
Preserve the existing framework, rendered instructions, output parser and omitted settings.
|
|
10
|
+
Capture a representative request at the actual adapter seam. Static inspection is not proof
|
|
11
|
+
of dynamic behavior. Ask only about consequential ambiguity; do not invent labels or criteria.
|
|
12
|
+
|
|
13
|
+
Prepare source.json and representative examples locally. Show exactly which files/fields would
|
|
14
|
+
be uploaded, to which Seldon host, and which checks remain unknown. Never include credentials.
|
|
15
|
+
Run `seldon import --source source.json --offline` before remote work. Source import does not
|
|
16
|
+
require a decorator or application-module import. With no CLI login, offer dashboard Import.
|
|
17
|
+
|
|
18
|
+
# After the user approves
|
|
19
|
+
|
|
20
|
+
Use `seldon login` for management; inference keys cannot manage Functions.
|
|
21
|
+
Run `seldon import --source source.json`, retaining the returned Function identity in the local
|
|
22
|
+
association. If creation has an unknown outcome, inspect `seldon status` and reconcile the
|
|
23
|
+
actual Function before retrying with `--function`; never infer identity from prompt/model.
|
|
24
|
+
Run `seldon examples import <function> --file examples.jsonl --replace` only after showing the
|
|
25
|
+
replacement scope. Missing expected-output provenance is unspecified, not human labelled.
|
|
26
|
+
Choose comparison first when the scoped readiness is unknown or insufficient. For an explicitly
|
|
27
|
+
chosen integrate-first journey, inspect `seldon reference-readiness <function>`; explain the
|
|
28
|
+
55-second deadline, workspace capacity and unknowns. `seldon serve-reference <function>` requires
|
|
29
|
+
the user's own login and interactive approval; `--acknowledge-deadline-risk` is an explicit
|
|
30
|
+
acknowledgement only after discussing the scoped risk. Reference serving is not optimization.
|
|
31
|
+
Later comparison uses the saved source run and its explicit additional cap.
|
|
32
|
+
Run `seldon optimize <function> --cap <authorized-total> --yes --wait` only within the explicit
|
|
33
|
+
cumulative budget. Preserve its run id, held/spent amounts and cancellation state. A timeout or
|
|
34
|
+
new agent session never authorizes another paid run. Use `seldon status <function>` and
|
|
35
|
+
`seldon report <function> --run <saved-run>` to resume. `--new-run` requires a new bounded scope.
|
|
36
|
+
|
|
37
|
+
Present measured tradeoffs, disagreements, missing evidence and a next action: adopt, retain
|
|
38
|
+
original or obtain better evidence. Inspection is optional. Generated explanation is not
|
|
39
|
+
semantic verification. Report-only targets never become activation vetoes. Never hide warnings.
|
|
40
|
+
|
|
41
|
+
Prepare a small patch for this operation plus necessary configuration/tests. Rehearse success,
|
|
42
|
+
a real boundary failure and recovery through the owning application's call site. Preserve its
|
|
43
|
+
production alias during rehearsal. `seldon publish <function> --revision <revision>` and
|
|
44
|
+
`seldon activate <function> --revision <revision>` require the human's interactive confirmation;
|
|
45
|
+
an agent must not simulate a terminal or bypass it. Distinguish publication, activation,
|
|
46
|
+
application testing and deployment. Show whether the patch pins a revision or follows the alias.
|
|
47
|
+
|
|
48
|
+
Offer `seldon function pull <function>`, `seldon function verify <function>` or
|
|
49
|
+
`seldon function run <function> --input inputs.json` only for an eligible, activated local revision. Explain
|
|
50
|
+
model installation, conformance, refresh, cloud-capable fallback and opt-out telemetry. Hosted
|
|
51
|
+
measurements do not prove local benefit. Local ineligibility never blocks hosted adoption.
|
|
52
|
+
|
|
53
|
+
Typed integration is optional: export the selected decorated module, import one generated source,
|
|
54
|
+
then write its Function id with `seldon lock set <key> <function> --module selected.module`. Explain canonical JSON rendering differences,
|
|
55
|
+
strict input/output validation and configured reference fallback. Existing-client integration
|
|
56
|
+
retains its framework and parser; both use the same evidence and approval flow.
|
|
57
|
+
|
|
58
|
+
Use `seldon check --source source.json` for offline drift. On return, read the saved association
|
|
59
|
+
then authoritative server state; changed source/evidence invalidates the recommendation.
|
|
60
|
+
Do not silently create another Function, rerun paid work, activate or deploy. Record exact
|
|
61
|
+
source/run/revision identifiers, tested boundaries and remaining gaps without secrets.
|
seldon_sdk/testing.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Context-local typed stubs; application tests make no network requests."""
|
|
2
|
+
|
|
3
|
+
from contextlib import contextmanager
|
|
4
|
+
|
|
5
|
+
from pydantic import ValidationError
|
|
6
|
+
|
|
7
|
+
from .errors import SeldonOutputValidationError
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@contextmanager
|
|
11
|
+
def stub(function, *, returns=None, side_effect=None):
|
|
12
|
+
calls = []
|
|
13
|
+
try:
|
|
14
|
+
expected = function.output.validate_python(returns) if side_effect is None else None
|
|
15
|
+
except ValidationError:
|
|
16
|
+
raise SeldonOutputValidationError("invalid_stub_output") from None
|
|
17
|
+
|
|
18
|
+
def invoke(inputs):
|
|
19
|
+
calls.append(inputs)
|
|
20
|
+
if isinstance(side_effect, BaseException):
|
|
21
|
+
raise side_effect
|
|
22
|
+
value = side_effect(**inputs) if callable(side_effect) else expected
|
|
23
|
+
try:
|
|
24
|
+
return function.output.validate_python(value)
|
|
25
|
+
except ValidationError:
|
|
26
|
+
raise SeldonOutputValidationError("invalid_stub_output") from None
|
|
27
|
+
|
|
28
|
+
token = function.stub.set(invoke)
|
|
29
|
+
try:
|
|
30
|
+
yield calls
|
|
31
|
+
finally:
|
|
32
|
+
function.stub.reset(token)
|
seldon_sdk/testing.pyi
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
from contextlib import AbstractContextManager
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from . import Function
|
|
6
|
+
|
|
7
|
+
def stub(
|
|
8
|
+
function: Function[..., Any],
|
|
9
|
+
*,
|
|
10
|
+
returns: Any = ...,
|
|
11
|
+
side_effect: BaseException | Callable[..., Any] | None = ...,
|
|
12
|
+
) -> AbstractContextManager[list[dict[str, Any]]]: ...
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: seldon-sdk
|
|
3
|
+
Version: 0.1.0.dev0
|
|
4
|
+
Summary: Explicit Seldon Functions tooling and Python client
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: httpx<1,>=0.27
|
|
9
|
+
Requires-Dist: pydantic<3,>=2.11
|
|
10
|
+
Provides-Extra: dev
|
|
11
|
+
Requires-Dist: build>=1; extra == 'dev'
|
|
12
|
+
Requires-Dist: mypy>=1.15; extra == 'dev'
|
|
13
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
14
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
15
|
+
Requires-Dist: ruff>=0.8; extra == 'dev'
|
|
16
|
+
Requires-Dist: twine>=6; extra == 'dev'
|
|
17
|
+
Provides-Extra: local
|
|
18
|
+
Requires-Dist: seldon-runtime>=0.1.1.dev0; extra == 'local'
|
|
19
|
+
Provides-Extra: login
|
|
20
|
+
Requires-Dist: keyring<26,>=25; extra == 'login'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# Seldon Python
|
|
24
|
+
|
|
25
|
+
Source preview of `seldon-sdk`: one CLI for preparing an existing AI
|
|
26
|
+
operation, comparing explicit alternatives and adopting a revision. A typed Python
|
|
27
|
+
Function decorator is optional. This is a separate project from SeldonIO.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
# Install the reviewed source preview without requiring a PyPI release:
|
|
33
|
+
python -m pip install 'seldon-sdk[login] @ git+https://github.com/Deep-Insight-Labs/seldon-python.git@74a0aa3680c9174d433be197cb6283e1832436f6'
|
|
34
|
+
# Or install from your checkout:
|
|
35
|
+
python -m pip install '.[login]'
|
|
36
|
+
# or, from a built wheel:
|
|
37
|
+
python -m pip install dist/seldon_sdk-0.1.0.dev0-py3-none-any.whl
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Python 3.10+ is supported. Core dependencies are httpx and Pydantic 2.11+.
|
|
41
|
+
The lower bound was measured with twenty synthetic schema shapes against the
|
|
42
|
+
latest Pydantic; earlier 2.x versions change generated contract digests.
|
|
43
|
+
`keyring` is optional. Only macOS Keychain, Windows Credential Locker and Linux
|
|
44
|
+
Secret Service backends are accepted. A login without an available secure backend
|
|
45
|
+
is memory-only; its result explicitly reports `persisted: false`.
|
|
46
|
+
|
|
47
|
+
The SDK is currently a source preview. Live WorkOS device login, macOS Keychain
|
|
48
|
+
storage, token rotation and session logout were exercised before package release.
|
|
49
|
+
Server SDK capabilities are independently feature flagged. The optional runtime
|
|
50
|
+
preview is published separately.
|
|
51
|
+
|
|
52
|
+
## Existing client workflow
|
|
53
|
+
|
|
54
|
+
Prepare one captured request or explicit `kind: template` JSON source. Missing
|
|
55
|
+
request settings remain missing. Offline validation does not import application
|
|
56
|
+
modules, contact a service, read inference credentials or access a keychain.
|
|
57
|
+
The server remains authoritative for schema/evaluator/provider eligibility.
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
seldon import --source operation.json --offline
|
|
61
|
+
seldon login
|
|
62
|
+
seldon import --source operation.json
|
|
63
|
+
seldon examples import FUNCTION_UUID --file examples.jsonl --replace
|
|
64
|
+
seldon optimize FUNCTION_UUID --cap 2.00 --yes --wait
|
|
65
|
+
seldon report FUNCTION_UUID --run RUN_UUID
|
|
66
|
+
seldon publish FUNCTION_UUID --revision REVISION_UUID
|
|
67
|
+
seldon activate FUNCTION_UUID --revision REVISION_UUID
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`--yes` authorizes the specified run cap, including all held and settled work;
|
|
71
|
+
it is never inferred from a login or prior success. The CLI saves a command UUID
|
|
72
|
+
before creating a run and reconciles it through the authoritative returned run
|
|
73
|
+
identifier. Waiting can be interrupted without cancelling a run. Resume with the
|
|
74
|
+
same association; use `cancel FUNCTION_UUID --run RUN_UUID` to cancel explicitly.
|
|
75
|
+
`--new-run` explicitly creates another budget scope. An active Function recheck can
|
|
76
|
+
identify its baseline with `--source-run RUN_UUID`.
|
|
77
|
+
|
|
78
|
+
Publication and activation require an interactive human confirmation of the exact
|
|
79
|
+
revision. Neither is a side effect of optimization. They retain server owner/admin,
|
|
80
|
+
warning and eligibility checks. Test the consuming application against a published
|
|
81
|
+
revision before changing its production alias. These commands do not deploy code.
|
|
82
|
+
|
|
83
|
+
Management uses a WorkOS user session only. Configure the approved public-client
|
|
84
|
+
identifier as `SELDON_WORKOS_CLIENT_ID`; `SELDON_API_KEY` never grants management
|
|
85
|
+
access. `--base-url` selects an HTTPS origin (HTTP localhost is allowed for tests).
|
|
86
|
+
Credentials are bound to origin and profile. Refresh tokens live in the secure
|
|
87
|
+
keychain; access tokens remain in memory. `logout` clears local credentials and
|
|
88
|
+
opens the provider session-logout URL; its output distinguishes pending browser
|
|
89
|
+
confirmation from confirmed local deletion. `logout --all-profiles` clears recorded
|
|
90
|
+
profiles. No client secret is needed.
|
|
91
|
+
|
|
92
|
+
`.seldon/operation.json` is a non-secret local association. It stores identifiers,
|
|
93
|
+
digests and local paths, never prompts, examples or credentials. Gitignore it. A
|
|
94
|
+
create request with an unknown outcome is not retried: inspect `seldon status`,
|
|
95
|
+
then reconcile by explicitly supplying `import --function FUNCTION_UUID`. Source
|
|
96
|
+
or imported evidence edits invalidate a saved recommendation. Historical reports
|
|
97
|
+
use the saved or explicitly selected run, not whichever run is newest.
|
|
98
|
+
|
|
99
|
+
## Typed Python functions
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from pydantic import BaseModel
|
|
103
|
+
import seldon_sdk as seldon
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class Classification(BaseModel):
|
|
107
|
+
label: str
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
@seldon.function(
|
|
111
|
+
model="your/reference-model", prompt="Classify {text}", example={"text": "A synthetic sample"}
|
|
112
|
+
)
|
|
113
|
+
def classify(text: str) -> Classification: ...
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
result = classify("Sample")
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Function bodies are never executed. Inputs are validated before a request. Explicit
|
|
120
|
+
annotations build a frozen contract and digest. Defaults are included in inputs.
|
|
121
|
+
Placeholders support `{name}` only: no format specifiers, conversions, attribute
|
|
122
|
+
lookups or repeated names in one message. Strings render directly; all other inputs
|
|
123
|
+
render as canonical JSON (`true`, `null`, compact arrays/objects), which can differ
|
|
124
|
+
from Python `str.format`. Recursive schemas and unsupported regex keywords fail at
|
|
125
|
+
decoration. Output must be an object or array. Function-key renames preserve the
|
|
126
|
+
behavior digest; the structured-output schema name is always `output`.
|
|
127
|
+
|
|
128
|
+
```sh
|
|
129
|
+
seldon export your_package.operations --out sources.json
|
|
130
|
+
seldon lock set your_package.operations:classify FUNCTION_UUID --module your_package.operations
|
|
131
|
+
seldon check your_package.operations
|
|
132
|
+
# With SDK management capabilities enabled:
|
|
133
|
+
seldon sync your_package.operations --json
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Export imports only explicitly named modules, with ordinary socket connects blocked;
|
|
137
|
+
Python imports can still have filesystem effects. It writes a list of source
|
|
138
|
+
objects, one per decorated function, sorted by key. Paste an individual object into
|
|
139
|
+
the dashboard Import tab. Missing examples report an item error and exit 1.
|
|
140
|
+
Commit `seldon.lock.json`; it contains IDs, contract digests and per-field digests,
|
|
141
|
+
not prompt contents. `SELDON_LOCKFILE` overrides upward lookup from the declaration.
|
|
142
|
+
`check` reports field pointers when a local contract changes. Template-mode drift
|
|
143
|
+
can instead use `check --function FUNCTION_UUID --template-file prompt.txt
|
|
144
|
+
--syntax python_format`; this fetches segment digests without uploading text.
|
|
145
|
+
|
|
146
|
+
Serving requires `SELDON_API_KEY` or explicit `api_key=`. Function execution uses
|
|
147
|
+
one idempotency key for up to three bounded transport/capacity attempts. Reference
|
|
148
|
+
fallback defaults on for documented unavailable paths; set `fallback="never"` to
|
|
149
|
+
raise. Authentication, funding and input errors never trigger fallback. Contract
|
|
150
|
+
drift defaults to the current local reference request; `on_drift="raise"` rejects.
|
|
151
|
+
Invalid Function output raises by default (`on_invalid_output="reference"` is an
|
|
152
|
+
explicit override). `reference_base_url` on another host requires a separate
|
|
153
|
+
`reference_api_key`. No credentials are forwarded on redirects.
|
|
154
|
+
|
|
155
|
+
Sync declarations reuse a client per thread; async declarations reuse one per event
|
|
156
|
+
loop. Call `seldon.close()` / `await seldon.aclose()` at shutdown. Calling a sync
|
|
157
|
+
Function inside an active event loop raises; declare it `async def` there.
|
|
158
|
+
`call_with_info` returns `(result, metadata)` and `on_call=` receives the same safe
|
|
159
|
+
metadata. `SELDON_MODE=reference` explicitly selects reference execution.
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
from seldon_sdk.testing import stub
|
|
163
|
+
|
|
164
|
+
with stub(classify, returns={"label": "sample"}) as calls:
|
|
165
|
+
assert classify("input").label == "sample"
|
|
166
|
+
assert calls == [{"text": "input"}]
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Local execution
|
|
170
|
+
|
|
171
|
+
Local execution requires an eligible deployment and the separately released
|
|
172
|
+
`seldon-runtime` package. Follow the CPU and model-extra instructions in the
|
|
173
|
+
[public runtime repository](https://github.com/Deep-Insight-Labs/seldon-runtime).
|
|
174
|
+
The [0.1.1.dev0 runtime preview](https://pypi.org/project/seldon-runtime/0.1.1.dev0/)
|
|
175
|
+
is available for Python 3.11 and later.
|
|
176
|
+
|
|
177
|
+
```sh
|
|
178
|
+
seldon function pull FUNCTION_UUID --out bundle.json
|
|
179
|
+
seldon function verify FUNCTION_UUID
|
|
180
|
+
seldon function run FUNCTION_UUID --input inputs.json --fallback raise --no-telemetry
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Pull validates and saves bundle JSON without loading model weights. Verify runs the
|
|
184
|
+
runtime conformance cohort and reports its size, agreement and latency; it is not
|
|
185
|
+
whole-workload or business evaluation. Run keeps automatic verification enabled.
|
|
186
|
+
Only activated eligible revisions can load. Bundles refresh with the active alias;
|
|
187
|
+
immutable local pinning is not promised. `--fallback seldon` can call a hosted
|
|
188
|
+
service; `raise` keeps failures local. Counts-only telemetry is optional.
|
|
189
|
+
Typed declarations use `local=True`, `local_fallback="seldon"|"raise"` and
|
|
190
|
+
`telemetry=False`. Async handles retain a Runner per event loop; call
|
|
191
|
+
`await classify.aclose()`. Sync calls load and close a Runner per invocation and
|
|
192
|
+
reuse the runtime's disk caches. Eligibility and verification belong to the runtime.
|
|
193
|
+
|
|
194
|
+
## Discovery and skill
|
|
195
|
+
|
|
196
|
+
`seldon scan path --json` conservatively finds Python call sites through AST only.
|
|
197
|
+
It does not import or upload scanned code and makes no volume claim. `--suggest`
|
|
198
|
+
prioritizes existing-client imports; `--format sdk` suggests a typed declaration
|
|
199
|
+
only when a fixed template is found. Results need review at the real adapter seam.
|
|
200
|
+
`seldon skill print` prints the packaged narrow selected-operation skill.
|
|
201
|
+
|
|
202
|
+
## Development and evidence
|
|
203
|
+
|
|
204
|
+
```sh
|
|
205
|
+
python -m pip install '.[dev]'
|
|
206
|
+
python -m ruff check .
|
|
207
|
+
python -m ruff format --check .
|
|
208
|
+
python -m pytest -q
|
|
209
|
+
python -m build
|
|
210
|
+
python scripts/verify_wheel.py dist/*.whl
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Unit tests replace HTTP through `httpx.MockTransport`, keychain through the `Login`
|
|
214
|
+
store seam and local execution through `Runner.load`. `scripts/verify_wheel.py`
|
|
215
|
+
creates a fresh environment and tests the installed console script from an unrelated
|
|
216
|
+
working directory. Cross-repository real-route/persistence tests live with the
|
|
217
|
+
server. No passing SDK unit test establishes production activation or provider
|
|
218
|
+
qualification. See `WORK_LOG.md` for actual evidence and outstanding acceptance.
|
|
219
|
+
|
|
220
|
+
For integrate-first adoption, inspect `seldon reference-readiness FUNCTION_UUID`
|
|
221
|
+
then explicitly confirm `seldon serve-reference FUNCTION_UUID`. Readiness is scoped
|
|
222
|
+
to that Function; unknown evidence recommends comparing first. This action serves
|
|
223
|
+
the reference without starting optimization and ordinary inference remains billed.
|
|
224
|
+
A known deadline risk additionally requires `--acknowledge-deadline-risk`.
|
|
225
|
+
When the server requires consent to use managed funding for a selected revision,
|
|
226
|
+
`publish` / `activate --approve-managed-fallback` carries that consent in the
|
|
227
|
+
interactive confirmation. It is never inferred from general access or optimization.
|
|
228
|
+
|
|
229
|
+
`status` without a locator reads every key in the nearest `seldon.lock.json` (or
|
|
230
|
+
`SELDON_LOCKFILE`) and shows active/pending/stale digest state plus seven-day usage.
|
|
231
|
+
With no lockfile it lists remote Functions. `activate <function> --alternative N`
|
|
232
|
+
selects the 1-based item from the associated run's authoritative report; it prints
|
|
233
|
+
the returned immutable revision before the same owner confirmation as `--revision`.
|
|
234
|
+
|
|
235
|
+
### Release setup
|
|
236
|
+
|
|
237
|
+
The approved public repository is `Deep-Insight-Labs/seldon-python`. Releases use
|
|
238
|
+
`.github/workflows/release.yml` and the existing Python/Pydantic CI matrix. A
|
|
239
|
+
`v<version>` tag must exactly match `pyproject.toml`; a branch dispatch builds and
|
|
240
|
+
checks artifacts only. Current `0.1.0.dev0` is an unpublished prerelease.
|
|
241
|
+
|
|
242
|
+
Before enabling publication, the package owner must register pending trusted
|
|
243
|
+
publishers for project `seldon-sdk` on **both** registries:
|
|
244
|
+
|
|
245
|
+
| Registry | GitHub owner | Repository | Workflow | Environment |
|
|
246
|
+
| --- | --- | --- | --- | --- |
|
|
247
|
+
| TestPyPI | Deep-Insight-Labs | seldon-python | release.yml | testpypi |
|
|
248
|
+
| PyPI | Deep-Insight-Labs | seldon-python | release.yml | pypi |
|
|
249
|
+
|
|
250
|
+
Create matching GitHub environments and set
|
|
251
|
+
`SELDON_SDK_TESTPYPI_PUBLISH_ENABLED=true` only after TestPyPI registration.
|
|
252
|
+
The first tag publishes there, downloads that exact wheel from TestPyPI, and runs
|
|
253
|
+
fresh-environment artifact checks with dependencies from PyPI. Production upload
|
|
254
|
+
also requires `SELDON_SDK_PUBLISH_ENABLED=true` and a successful TestPyPI install
|
|
255
|
+
in the same workflow. It uploads the original checked distributions. Registry
|
|
256
|
+
versions are immutable; do not replace an uploaded release or silently skip an
|
|
257
|
+
existing artifact. Keep both variables unset until the release is authorized and
|
|
258
|
+
the issued-token, refresh-rotation and remote-logout qualification described above
|
|
259
|
+
is recorded. These external checks have not been established by local unit tests.
|
|
260
|
+
|
|
261
|
+
No registry token belongs in this repository: publication uses GitHub OIDC.
|
|
262
|
+
`pip install 'seldon-sdk[local]'` additionally requires a separately published
|
|
263
|
+
`seldon-runtime>=0.1.1.dev0`; the base SDK has no runtime dependency.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
seldon_sdk/__init__.py,sha256=7hkp_e1lz3BRSf7tOLh7vHLx8edPwSXF5g7lh_onFqw,496
|
|
2
|
+
seldon_sdk/__init__.pyi,sha256=uNUAiXtPxocWUZlWYgzEfuC9Kibu4LkvUmxkmipOyKo,931
|
|
3
|
+
seldon_sdk/auth.py,sha256=VSs6xxS_OFV00u3PA2lKaejVRTrzRoJfObnk4gB9uq8,11047
|
|
4
|
+
seldon_sdk/cli.py,sha256=nIAEcP6C7Rdf423757mWdvI7TnN6XK2UJWIoqj-flf8,14503
|
|
5
|
+
seldon_sdk/contract.py,sha256=i1_WosL2KB21xHsM8cfc1XTTxfkyqjnimO4-uzHKhh4,7723
|
|
6
|
+
seldon_sdk/decorator.py,sha256=lqMxSMUhmZO7AA_HT6xv2afpNjXA2qwpJX0yPnAGipk,3595
|
|
7
|
+
seldon_sdk/errors.py,sha256=hmibR8LtjxRULsZGj-W26Vs1sR3GdH-VS5vXUOOUnGY,665
|
|
8
|
+
seldon_sdk/files.py,sha256=MMWqDHgam0NmuTxLe81301F75F5isp-2cAL0GskhkY4,11862
|
|
9
|
+
seldon_sdk/local.py,sha256=apETudlz46RAUCpZekEFE9UIuP_GMiiH50jBIctNEjM,2561
|
|
10
|
+
seldon_sdk/lockfile.py,sha256=hDgKO8MWc7NBHaJriTQuU2LcPp3injNogsMr4ObJWNg,1388
|
|
11
|
+
seldon_sdk/management.py,sha256=1oozbUYh91K7IkoDl2H1PwDHSNkNG7cSl1yl1-gXKIM,21493
|
|
12
|
+
seldon_sdk/preparation.py,sha256=pEjGHZtpeTAk7MNPSa6N6kSr0k2w6eMjOIfy7bSGPaI,8645
|
|
13
|
+
seldon_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
seldon_sdk/runtime.py,sha256=xHJeHBJckQ9ekAC6oE8TnjvyX1kiSOheMb3XGh7Qnic,13033
|
|
15
|
+
seldon_sdk/scanner.py,sha256=nE02rl5AIlLTMGcgTmnISsC22OD5zGyw-2JydmF5XxU,6015
|
|
16
|
+
seldon_sdk/testing.py,sha256=_1rSr6mG9hJFpJ-fR4S1JJ4PsucukGcjqKjD4oRSXUM,1006
|
|
17
|
+
seldon_sdk/testing.pyi,sha256=t7SpAC76bImzSSPe3RsI14Kl6DDFkDfKRHJm82HO1Ms,327
|
|
18
|
+
seldon_sdk/skill/SKILL.md,sha256=neNjTRY0QKwsT0VBgYHNwTbEnx39XpIX8FxO27wxppo,4398
|
|
19
|
+
seldon_sdk-0.1.0.dev0.dist-info/METADATA,sha256=Ax8QY50DcVMfZZaWsHWh0tZA6vUplMpNGVssamarL90,13285
|
|
20
|
+
seldon_sdk-0.1.0.dev0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
21
|
+
seldon_sdk-0.1.0.dev0.dist-info/entry_points.txt,sha256=s2uszDyqgWJsPMKorki435-amyBGfepGsVANOOs8N1g,47
|
|
22
|
+
seldon_sdk-0.1.0.dev0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
23
|
+
seldon_sdk-0.1.0.dev0.dist-info/RECORD,,
|