cognix-sdk
Package your own model as a CogniX bundle and check it on your machine before you publish it.
pip install "cognix-sdk[sklearn]" # or: uv add "cognix-sdk[sklearn]"
You install cognix-sdk and import cgx. The sklearn extra brings scikit-learn and
skl2onnx to export a model, and onnxruntime so that check() can run it. If you bring an
.onnx exported with anything else (PyTorch, TensorFlow…), cognix-sdk[runtime] is enough.
The problem it solves
You train the model, with whatever you like. What has to be right is the artifact, and there is a trap in it that raises no error:
the feature extractor is written twice — your
featurize()in Python, used to train, andfeatures.star(Starlark), which the engine evaluates in production. When they drift apart, the model keeps answering — only about a different input.
No exception, no trace, no metric going down. This package exists so that it fails on your laptop instead.
Quickstart
Two runnable examples ship with the source distribution, and neither needs data of your own or a network connection:
| example | what it builds |
|---|---|
examples/quickstart.py |
a ClassiX classifier (scikit-learn on iris), with calibration, decision, explanation and the OOD gate |
examples/desviantix_autoencoder.py |
a DesviantiX anomaly detector: an autoencoder, with its threshold calibrated on held-out normal data |
The core of the first one:
import cgx
from cgx import starlark
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler
iris = load_iris()
schema = ["sepal_length", "sepal_width", "petal_length", "petal_width"]
X, y = iris.data, iris.target_names[iris.target]
scaler = StandardScaler().fit(X)
clf = LogisticRegression(max_iter=1000).fit(scaler.transform(X), y)
onnx = cgx.to_onnx(clf, n_features=len(schema), out_path="dist/model.onnx")
bundle = cgx.Bundle(
domain="iris_byo",
feature="classix",
schema=schema,
featurizer=starlark.identity_featurizer(schema), # your Python extractor…
starlark=starlark.identity("iris_byo", schema), # …and the one production runs
onnx_path=onnx,
output_names=cgx.onnx.scores_output(onnx), # the scores tensor, not `label`
output_kind="probabilities", # skl2onnx already normalizes them
payloads=[dict(zip(schema, map(float, r))) for r in X[:8]],
labels=[str(c) for c in clf.classes_],
mean=scaler.mean_.tolist(),
std=scaler.scale_.tolist(),
extra_manifest={ # ClassiX's task block
"calibration": {"method": "temperature", "temperature": 1.0},
"decision": {"mode": "argmax", "top_k": 1},
"explanation": {"method": "global",
"global_importance": abs(clf.coef_).mean(axis=0).tolist()},
"ood": cgx.ood.mahalanobis(scaler.transform(X)),
},
)
bundle.check("dist/iris_byo") # writes the bundle and verifies it; raises BundleError if not
Then serve it with the cognix binary and ask it:
cognix serve --bundles dist --addr 127.0.0.1:8090
curl -s -X POST http://127.0.0.1:8090/classix/d/iris_byo/infer \
-H 'Content-Type: application/json' \
-d '{"sepal_length": 6.3, "sepal_width": 3.4, "petal_length": 5.6, "petal_width": 2.4}'
What check() verifies
In this order, and it stops at the first failure with the fix in the message:
- Your featurizer, in Python: a vector of the schema's length, made of numbers, for every payload.
- The model, with onnxruntime: it runs on each payload one row at a time, the way the engine feeds it, and answers with the shape the feature reads. A graph that passes everything else and would answer 500 on every inference fails here.
- With the
cgxbinary, which ships inside this package: the manifest against the feature's own contract (bundle inspect), andverify-parity— your Python featurizer against the real Starlark extractor.
Step 3 is done by the binary, not by a Starlark re-implementation in Python: a second
interpreter could differ from the production engine, which is the very problem this checks
for. If the binary is missing, check() says so and does not report an OK.
What it cannot verify for a bundle built outside a CogniX trainer is verify, which replays a
recorded result (class or value, probabilities, OOD gate) through the whole pipeline: that
recording is written by each feature's own trainer. check() says what is left uncovered. The
bundle serves just the same.
The five features
feature= picks the engine that will serve the bundle. The SDK writes the model block the
way each feature reads it; each feature's task block goes in extra_manifest=, and the
engine's own validation (step 3) names any field that is missing.
| feature | what it answers | model | task block (extra_manifest) |
|---|---|---|---|
classix |
class + calibrated probabilities + OOD + attribution | one scores tensor; output_kind logits or probabilities |
calibration, decision, explanation, ood |
regrex |
value + prediction interval + extrapolation flag + attribution | one output | prediction, interval, explanation, extrapolation |
clusterix |
cluster + membership + OOD + attribution | two outputs: label and per-cluster scores (output_kind="distances") |
clusters, membership, decision, explanation, ood |
desviantix |
normal / novelty / anomaly + explanation |
one output: the reconstruction (or a direct score); mean/std required |
scoring, classification |
decidix |
action + uncertainty + safety fallback | none for linucb and mlp_actor (onnx_path=None) |
policy, ood |
cgx.ood.mahalanobis(X) computes the ood (or extrapolation) block from your training
features, normalized the same way the model sees them.
If your featurizer is not the identity
starlark.identity() covers the case "each feature is a numeric field of the payload". For
anything else — a ratio of two fields, a one-hot, a saturation — write features.star by hand
and pass it in starlark=. When featurize() derives features from other fields, name the
keys a caller actually sends in payload_fields=.
There is no automatic Python-to-Starlark translation, on purpose. Translating an
arbitrary featurize() is the feature that charms and the one that can translate wrong
silently — exactly the class of failure this SDK exists to catch. check() works with any
extractor, and that is the guarantee that matters.
Reference
Bundle(...) |
the artifact: .manifest(), .payload_schema(), .save(dir), .check(dir) |
to_onnx(model, n_features) |
scikit-learn export with the opset and input name the engine expects, checked against the model after writing |
onnx.scores_output(path) / onnx.output_names(path) |
which graph outputs to declare |
ood.mahalanobis(X) |
the OOD gate block, from your normalized training features |
starlark.identity(domain, schema) |
the features.star of the identity case |
starlark.identity_featurizer(schema) |
its Python twin, to pass to featurizer= |
What this package is not
It is not a client for the CogniX REST API: that is cgxctl. Its contract is the
bundle format (v3), which is versioned and changes on purpose.
Release files for cognix-sdk 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cognix_sdk-0.2.0.tar.gz | 48.0 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| cognix_sdk-0.2.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| cognix_sdk-0.2.0-py3-none-musllinux_1_2_x86_64.whl | Python 3 | none | Linux musl 1.2+ x86-64 | Details |
| cognix_sdk-0.2.0-py3-none-musllinux_1_2_aarch64.whl | Python 3 | none | Linux musl 1.2+ ARM64 | Details |
| cognix_sdk-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| cognix_sdk-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| cognix_sdk-0.2.0-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
| cognix_sdk-0.2.0-py3-none-macosx_10_12_x86_64.whl | Python 3 | none | macOS 10.12+ x86-64 | Details |
| cognix_sdk-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.3 MB
Release files / cognix_sdk-0.2.0.tar.gz
| Download URL | cognix_sdk-0.2.0.tar.gz |
|---|---|
| Size | 48.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52499b0340a3888c58cbcfc5d4e3da0fb55eddb1b9db6639f740f5f5c69e0df2
|
|
BLAKE2b-256 checksum How to use checksums |
8e3e5872bd308b663bd93bd1c273db720be3fe696d8eb05336e568283d78dd65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / cognix_sdk-0.2.0-py3-none-win_amd64.whl
| Download URL | cognix_sdk-0.2.0-py3-none-win_amd64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5b040a0ebf6056a0cfdb0bcb81689c97940c55c50a12bdc1faf46798482306fc
|
|
BLAKE2b-256 checksum How to use checksums |
dfbafaa8d1f9b67b6c4d0796c8a89ccfe5aebe54ab7dba0daa27abd876a62cd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / cognix_sdk-0.2.0-py3-none-musllinux_1_2_x86_64.whl
| Download URL | cognix_sdk-0.2.0-py3-none-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
3c82fd970c7f65dd2091763b77e6319a13734f49668f134b00e47b5d6c59f7bf
|
|
BLAKE2b-256 checksum How to use checksums |
959957820815efba4548694e4dd5ba811866850bd596f666c41e98f11f50f934
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / cognix_sdk-0.2.0-py3-none-musllinux_1_2_aarch64.whl
| Download URL | cognix_sdk-0.2.0-py3-none-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Linux musl 1.2+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
31db21c41f24719177cb54b3bd954084bea28f0581905ed2027cdfa5a2622591
|
|
BLAKE2b-256 checksum How to use checksums |
859fd87616ba282ae1822d9ed1109df778b8799aaf0fdca38843442957d89057
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / cognix_sdk-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | cognix_sdk-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
6835c2008205697956ae60b0d938525955111848c1f9fa3f1e7a60c89ad00de3
|
|
BLAKE2b-256 checksum How to use checksums |
cc5541a415c94b770f5c1a66b6fc6425be0001becdaa946087acec885993eda1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / cognix_sdk-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | cognix_sdk-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
c9a1e3ff9431ea9f38a8fe529ce7c0be7e41c23a1730af9173c5a8e4e95b2feb
|
|
BLAKE2b-256 checksum How to use checksums |
8c127badce57884900cd2e12e16af96813c43b4298659cbdd179d365ef528c75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / cognix_sdk-0.2.0-py3-none-macosx_11_0_arm64.whl
| Download URL | cognix_sdk-0.2.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
745c939955b503e1e7042688942655761a2cbdde1610a2559e3049cbe6609ef2
|
|
BLAKE2b-256 checksum How to use checksums |
3c1f2e89bc633089b54fe192f7a11166467b6d9d7d7885df29bcf3f4cced893b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / cognix_sdk-0.2.0-py3-none-macosx_10_12_x86_64.whl
| Download URL | cognix_sdk-0.2.0-py3-none-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | Python 3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
96032a96ebca87dfd82f5c1bba23c04564c606bee4112f0fc3f8593b18607408
|
|
BLAKE2b-256 checksum How to use checksums |
947406d93c5cba850708d7812f28dde1350a5f5308b05a81a04b4e1294f10d5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / cognix_sdk-0.2.0-py3-none-any.whl
| Download URL | cognix_sdk-0.2.0-py3-none-any.whl |
|---|---|
| Size | 32.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
690a3548fa63d7611f3a25a87bac688f902bf0b6d1c74fc303bdc862b5d782f3
|
|
BLAKE2b-256 checksum How to use checksums |
7fa6e4373ae2af58abf8ca50f81d2b2e343dfd16da669ebf05d8cebe99005229
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency log