seldon-sdk 0.1.0.dev0__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.
- seldon_sdk-0.1.0.dev0/.github/workflows/ci.yml +29 -0
- seldon_sdk-0.1.0.dev0/.github/workflows/release.yml +99 -0
- seldon_sdk-0.1.0.dev0/.gitignore +10 -0
- seldon_sdk-0.1.0.dev0/CHANGELOG.md +23 -0
- seldon_sdk-0.1.0.dev0/LICENSE +202 -0
- seldon_sdk-0.1.0.dev0/PKG-INFO +263 -0
- seldon_sdk-0.1.0.dev0/README.md +241 -0
- seldon_sdk-0.1.0.dev0/WORK_LOG.md +170 -0
- seldon_sdk-0.1.0.dev0/pyproject.toml +35 -0
- seldon_sdk-0.1.0.dev0/scripts/conformance_cases.py +71 -0
- seldon_sdk-0.1.0.dev0/scripts/typecheck_example.py +31 -0
- seldon_sdk-0.1.0.dev0/scripts/verify_wheel.py +66 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/__init__.py +23 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/__init__.pyi +30 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/auth.py +286 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/cli.py +344 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/contract.py +200 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/decorator.py +114 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/errors.py +37 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/files.py +350 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/local.py +69 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/lockfile.py +42 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/management.py +532 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/preparation.py +225 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/py.typed +0 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/runtime.py +375 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/scanner.py +143 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/skill/SKILL.md +61 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/testing.py +32 -0
- seldon_sdk-0.1.0.dev0/src/seldon_sdk/testing.pyi +12 -0
- seldon_sdk-0.1.0.dev0/tests/fixtures/conformance.json +6084 -0
- seldon_sdk-0.1.0.dev0/tests/fixtures/operation.py +17 -0
- seldon_sdk-0.1.0.dev0/tests/fixtures/schema_matrix.json +106 -0
- seldon_sdk-0.1.0.dev0/tests/fixtures/sdk_source.json +73 -0
- seldon_sdk-0.1.0.dev0/tests/test_auth.py +139 -0
- seldon_sdk-0.1.0.dev0/tests/test_cli.py +313 -0
- seldon_sdk-0.1.0.dev0/tests/test_conformance.py +20 -0
- seldon_sdk-0.1.0.dev0/tests/test_foundation.py +70 -0
- seldon_sdk-0.1.0.dev0/tests/test_local.py +51 -0
- seldon_sdk-0.1.0.dev0/tests/test_preparation.py +95 -0
- seldon_sdk-0.1.0.dev0/tests/test_schema_matrix.py +66 -0
- seldon_sdk-0.1.0.dev0/tests/test_typed.py +152 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: SDK checks
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: ['**']
|
|
5
|
+
pull_request:
|
|
6
|
+
workflow_call:
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python: ['3.10', '3.13']
|
|
15
|
+
pydantic: ['2.11.0', 'latest']
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: '${{ matrix.python }}'
|
|
21
|
+
- run: python -m pip install '.[dev]'
|
|
22
|
+
- if: matrix.pydantic != 'latest'
|
|
23
|
+
run: python -m pip install 'pydantic==${{ matrix.pydantic }}'
|
|
24
|
+
- run: python -m ruff check . && python -m ruff format --check .
|
|
25
|
+
- run: python -m mypy scripts/typecheck_example.py --strict
|
|
26
|
+
- run: python -m pytest -q
|
|
27
|
+
- run: python -m build
|
|
28
|
+
- run: python -m twine check dist/*
|
|
29
|
+
- run: python scripts/verify_wheel.py dist/*.whl
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
name: SDK release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ['v*']
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: sdk-release-${{ github.ref }}
|
|
13
|
+
cancel-in-progress: false
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
checks:
|
|
17
|
+
uses: ./.github/workflows/ci.yml
|
|
18
|
+
|
|
19
|
+
build:
|
|
20
|
+
needs: checks
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
outputs:
|
|
23
|
+
version: ${{ steps.version.outputs.value }}
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: actions/setup-python@v5
|
|
27
|
+
with:
|
|
28
|
+
python-version: '3.13'
|
|
29
|
+
- name: Verify immutable release identity
|
|
30
|
+
id: version
|
|
31
|
+
env:
|
|
32
|
+
REF_TYPE: ${{ github.ref_type }}
|
|
33
|
+
REF_NAME: ${{ github.ref_name }}
|
|
34
|
+
run: |
|
|
35
|
+
python - <<'PY'
|
|
36
|
+
import os, tomllib
|
|
37
|
+
with open('pyproject.toml', 'rb') as source:
|
|
38
|
+
version = tomllib.load(source)['project']['version']
|
|
39
|
+
if os.environ['REF_TYPE'] == 'tag':
|
|
40
|
+
assert os.environ['REF_NAME'] == 'v' + version, 'tag/version mismatch'
|
|
41
|
+
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
|
|
42
|
+
output.write('value=' + version + '\n')
|
|
43
|
+
PY
|
|
44
|
+
- run: python -m pip install build twine
|
|
45
|
+
- run: python -m build && python -m twine check dist/*
|
|
46
|
+
- run: python scripts/verify_wheel.py dist/*.whl
|
|
47
|
+
- uses: actions/upload-artifact@v4
|
|
48
|
+
with:
|
|
49
|
+
name: sdk-distributions
|
|
50
|
+
path: dist/
|
|
51
|
+
if-no-files-found: error
|
|
52
|
+
|
|
53
|
+
testpypi:
|
|
54
|
+
needs: build
|
|
55
|
+
if: startsWith(github.ref, 'refs/tags/v') && vars.SELDON_SDK_TESTPYPI_PUBLISH_ENABLED == 'true'
|
|
56
|
+
runs-on: ubuntu-latest
|
|
57
|
+
environment: testpypi
|
|
58
|
+
permissions:
|
|
59
|
+
id-token: write
|
|
60
|
+
steps:
|
|
61
|
+
- uses: actions/download-artifact@v4
|
|
62
|
+
with:
|
|
63
|
+
name: sdk-distributions
|
|
64
|
+
path: dist/
|
|
65
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
66
|
+
with:
|
|
67
|
+
repository-url: https://test.pypi.org/legacy/
|
|
68
|
+
|
|
69
|
+
installed-testpypi:
|
|
70
|
+
needs: [build, testpypi]
|
|
71
|
+
runs-on: ubuntu-latest
|
|
72
|
+
steps:
|
|
73
|
+
- uses: actions/checkout@v4
|
|
74
|
+
- uses: actions/setup-python@v5
|
|
75
|
+
with:
|
|
76
|
+
python-version: '3.13'
|
|
77
|
+
- name: Download only the exact SDK from TestPyPI
|
|
78
|
+
env:
|
|
79
|
+
SDK_VERSION: ${{ needs.build.outputs.version }}
|
|
80
|
+
run: |
|
|
81
|
+
python -m pip download --no-deps --only-binary=:all: \
|
|
82
|
+
--index-url https://test.pypi.org/simple/ \
|
|
83
|
+
--dest downloaded "seldon-sdk==$SDK_VERSION"
|
|
84
|
+
- name: Verify downloaded wheel in a fresh environment
|
|
85
|
+
run: python scripts/verify_wheel.py downloaded/*.whl
|
|
86
|
+
|
|
87
|
+
pypi:
|
|
88
|
+
needs: [build, installed-testpypi]
|
|
89
|
+
if: startsWith(github.ref, 'refs/tags/v') && vars.SELDON_SDK_PUBLISH_ENABLED == 'true'
|
|
90
|
+
runs-on: ubuntu-latest
|
|
91
|
+
environment: pypi
|
|
92
|
+
permissions:
|
|
93
|
+
id-token: write
|
|
94
|
+
steps:
|
|
95
|
+
- uses: actions/download-artifact@v4
|
|
96
|
+
with:
|
|
97
|
+
name: sdk-distributions
|
|
98
|
+
path: dist/
|
|
99
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0.dev0 — local preview
|
|
4
|
+
|
|
5
|
+
- Add one shared CLI for explicit offline sources, WorkOS user sessions, durable
|
|
6
|
+
operation associations, bounded optimization and historical report inspection.
|
|
7
|
+
- Keep unknown create outcomes unretried; preserve command IDs across uncertain
|
|
8
|
+
prepare/evidence responses. Preserve rotated refresh tokens when the downstream
|
|
9
|
+
API is temporarily unavailable.
|
|
10
|
+
- Add optional typed contracts, reference fallback, isolated stubs, export/lock/sync,
|
|
11
|
+
digest-only drift inspection and AST discovery.
|
|
12
|
+
- Package the selected-operation skill and a thin local Runner integration. Reuse
|
|
13
|
+
the existing runtime for eligibility, conformance, active refresh and telemetry;
|
|
14
|
+
this package contains no compiler or model executor.
|
|
15
|
+
- Use argparse, httpx and Pydantic instead of adding a parallel CLI/auth/agent
|
|
16
|
+
framework. Structured output uses the constant schema name `output` so renaming
|
|
17
|
+
a function cannot alter its behavior digest.
|
|
18
|
+
|
|
19
|
+
- Resolve Function keys from the nearest explicit lockfile for every targeted CLI
|
|
20
|
+
command, rejecting malformed recursive mappings. Preserve authoritative selected
|
|
21
|
+
contract/run diagnostics in reports and source-import results. Offline source
|
|
22
|
+
previews identify the upload destination. Verify license and contents on built
|
|
23
|
+
wheel/sdist artifacts.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -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.
|