Skip to main content
Loss of provenance

A previous release had provenance metadata, but this release does not. View details.

MLbundle

Your trained model, schema and verified structure. One file.

Website source Documentation Playground Version 0.2.0 Source on GitHub CI status MIT license Part of eshkra

MLbundle packages a trained model with its manifest, locally inferred input schema and extractable structure in one compressed .mlbundle file. The same library writes the bundle and validates it when loaded, preserving feature order, class labels and output meaning across the training/runtime boundary.

Use it to hand a model to MLSuite, inspect its metadata or build your own consumer around the validated native model.

Why bundle a model?

A model file alone leaves the next application to recover its inputs, labels, environment and supporting metadata. Separate descriptions can drift from the model they are supposed to describe.

MLbundle keeps them together and checks model-derived claims against the loaded model. Schema inference runs locally through MLschema; real training rows are included only when explicitly requested. Native formats preserve the supported model without conversion.

Installation

MLbundle 0.2.0 requires Python 3.14 for export with the schema extra. The installation command for this release is:

python -m pip install "mlbundle[sklearn,schema]==0.2.0"

To use a local checkout, run python -m pip install -e ".[sklearn,schema]" from its root. The base library requires Python >=3.14; schema inference uses mlschema >=0.3.0,<0.4 on Python 3.14 only.

Choose xgboost, catboost or onnx instead of sklearn, or install [all]. Export always needs schema. Metadata-only inspection needs only the base package; load and CLI verification need the matching model extra.

Quick start

Train a model, export its schema without including training rows, then inspect and load the bundle:

import pandas as pd
from sklearn.tree import DecisionTreeClassifier

from mlbundle import export, inspect, load

training = pd.DataFrame(
    {
        "temperature": [0.0, 1.0, 0.1, 0.9],
        "humidity": [1.0, 0.0, 0.9, 0.1],
        "target": ["cold", "warm", "cold", "warm"],
    }
)
model = DecisionTreeClassifier(random_state=7).fit(
    training.drop(columns="target"), training["target"]
)

export(
    model,
    "trained.mlbundle",
    training_data=training,
    target_names=["target"],
)

metadata = inspect("trained.mlbundle")  # No model deserialization.
print(metadata.manifest.features.names)  # ["temperature", "humidity"]

bundle = load("trained.mlbundle")  # Recomputes native claims and structure.
result = bundle.predict_record({"temperature": 0.0, "humidity": 1.0})[0]
print(result.predicted_label)  # cold
print(result.probabilities)  # (1.0, 0.0)

The target column is excluded from the input schema. Add sample_rows=N only when you intend to include the first N real feature rows. Without training_data=, export infers a default schema from synthetic values.

Existing destinations require overwrite=True. Native feature names take precedence; otherwise mappings use zero-based positions. load and inspect accept paths, bytes or streams. The native model remains available as bundle.native_model; mutating it invalidates the verified metadata.

Choose your operation

Operation Purpose
export(model, destination, ...) Validate a native round trip, infer the schema locally and write a bundle.
inspect(source) Validate the container, manifest, hashes and declarations without loading a model.
load(source) Load through a closed adapter and verify model-derived claims and structure.
bundle.predict_proba(data) Classifier probabilities as plain lists.
bundle.predict(data) Regressor predictions as plain lists.
bundle.predict_record(record) Map one record through the schema and return frozen output-major results.
bundle.row_from_record(record) Validate and order record values for native inference or explanations.

The CLI exposes metadata inspection and full verification:

mlbundle inspect trained.mlbundle
mlbundle inspect trained.mlbundle --json
mlbundle verify trained.mlbundle

Inspection does not prove that metadata describes the model. Full verification loads the model and compares its claims. Neither operation establishes authorship or training history.

Supported models

Library Storage Support boundary
scikit-learn skops Closed fitted classifier/regressor families and supported transformers.
XGBoost Native UBJSON Exact single-target tree wrappers and closed objectives.
CatBoost Native CBM Exact numeric, single-target symmetric classifiers/regressors.
ONNX Original ONNX bytes Self-contained tabular models with supported signatures; no conversion.
Composite pipelines skops + UBJSON or CBM Supported sklearn preprocessing with an XGBoost/CatBoost final estimator.

Custom types fail at export. Sklearn and CatBoost own their class labels; XGBoost can bind declared labels to a native copy. ONNX has no visualization structure, and all-sklearn Pipeline structure is null. The adapter contracts define the exact support limits.

Some notes

Package versions and wire-format versions are independent. Format 1 is not frozen; incompatible schema shapes require re-export. The security design has not had an independent review; do not accept bundles from untrusted parties.

The reader bounds ZIP/JSON data, verifies integrity and uses closed native loaders. Hashes detect corruption, not deliberate tampering. Native parsers and inference still need process isolation and application-owned resource limits. Read SECURITY.md for guarantees, limits and private reporting.

Training rows stay local by default, but feature names, categories, labels and learned structure can reveal information. Schemas and environment records remain author declarations. Model training, hosting, signing and conversion are outside the library's scope.

Documentation

The documentation site includes installation, adapter guides, record prediction and API reference. The normative contracts remain in this repository:

The playground provides editable examples and inspection of the generated .mlbundle file. It runs scikit-learn examples in the browser and inspects uploaded files without loading their models.

Contributing

The Python library uses uv and Python 3.14:

uv python install 3.14
uv sync --locked --all-extras
uv run pre-commit install
uv run ruff check .
uv run ruff format --check .
uv run pyright
uv run pytest
uv build

Tests use the installed package and enforce 80% branch-inclusive coverage. CI validates the built wheel on Windows and Linux. Read AGENTS.md for contribution rules and publishing for the owner-approved release workflow.

The landing, docs and playground use Vite+ and a pnpm workspace. With vp installed, run from the repository root:

vp install
vp run check
vp run build

Start a site with vp run dev:landing, vp run dev:docs or vp run dev:playground. Their local ports are 4340, 4341 and 10021 respectively. Each site also accepts vp run dev, vp run build and vp run preview from its directory. Astro sites run their framework CLI through vp exec; the playground uses Vite+ directly. vp run check runs frontend lint, landing formatting, all three sites' type checks, and the docs and playground unit tests. Runtime and browser tests live in playground/.

Actions runs Python and frontend checks on pushes and PRs to main and develop. After all checks pass on main, it deploys the three tested site builds to Cloudflare. Manual CI Pipeline runs on main use the same gates and can redeploy without publishing Python. A change to project.version on main automatically starts the PyPI workflow after its version and branch preflight. See website deployment and publishing.

License

MIT. The design takes ideas from MLflow's versioned manifest and native storage, not its code.

Metadata

Release files for mlbundle 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Loss of provenance

These files do not have provenance metadata, despite files in a prior release including this data.

We recommend further investigation before installing these files. View details.

Source distribution (sdist)

Source distribution for mlbundle 0.2.0
File Size Uploaded Provenance Actions
mlbundle-0.2.0.tar.gz 109.5 kB Without provenance Details for mlbundle-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mlbundle 0.2.0
File Interpreter ABI Platform Actions
mlbundle-0.2.0-py3-none-any.whl Python 3 none any Details for mlbundle-0.2.0-py3-none-any.whl

Total release size: 258.7 kB

Release files / mlbundle-0.2.0.tar.gz

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL mlbundle-0.2.0.tar.gz
Size 109.5 kB
Tags Source
SHA-256 checksum
How to use checksums
04c7d415a6d717e4c7d2505a635d5418165bffc5e651efed49952f91da065701
BLAKE2b-256 checksum
How to use checksums
ad7de62ea6e800d4d7e8bcbc0bbffaed5c93025fe8b3a8246822d22b80cd06a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / mlbundle-0.2.0-py3-none-any.whl

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL mlbundle-0.2.0-py3-none-any.whl
Size 149.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f8ed3e2241ff35b5f1f7c466745d4e8ee8aaf360266ce0f2f9b68923e2cd420
BLAKE2b-256 checksum
How to use checksums
fe16dd4af6d8f52c6e3add7e5e9cf9b0a6d155e13ae657d6d4727572d48ceca5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for mlbundle 0.2.0

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.

Loss of provenance

A previous release of these files had provenance metadata, but this release does not.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Release comparison

  • Removed 0.1.0a3 2 files With provenance
  • Added 0.2.0 2 files Without provenance

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page