Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

mangosta

Lightweight MLOps and Model Lifecycle Management for PyTorch.

"Simple by default, strict on demand" - Functional in three lines of code for rapid experimentation, yet robust enough for production pipelines and autonomous AI agents through formal contracts, deterministic fault tolerance, and immutable architecture versioning.


Overview

Modern MLOps frameworks frequently impose heavy operational complexity: daemon background services, external databases, cloud platform dependencies, and brittle networking setups.

mangosta is engineered to provide local-first, serverless model lifecycle primitives directly within Python and standard file systems. It eliminates infrastructure overhead while delivering strict guarantees regarding reproducibility, tensor contracts, and crash-consistent persistence.

Architectural Principles

  • Zero Service Dependencies: No background daemons, web servers, or remote databases. All operations use direct, atomic file system calls (JSONL, standard ZIP archives, and optional SQLite).
  • Strict Immutability: Architectures registered in ModelRegistry cannot be silently overwritten, preventing silent behavioral divergence between training runs.
  • Contract-Driven Inference: Non-invasive tensor signature inference captures shapes (including dynamic batch dimensions) and data types, enforcing runtime verification before execution.
  • Deterministic Fault Tolerance: Checkpoints capture complete training state including optimizer parameters, learning rate schedulers, gradient scalers, and pseudo-random number generator (RNG) states across Python, PyTorch (CPU and CUDA), and NumPy.
  • Decoupled Production Export: Development artifacts (.bundle) remain optimized for training continuity and auditability, while standalone production formats (such as ONNX) are cleanly exported with full user control over dynamic axes, precision, and output restructuring.

Comparison with Existing Tools

Capability mangosta MLflow Weights & Biases ClearML
Infrastructure Overhead None (Local files only) Local/Remote server Cloud daemon / SaaS Server / Agent daemon
External Services Required Zero Web server + DB API backend Server stack + DB
Persistence Mechanism Atomic JSONL & ZIP SQLite / File store Cloud storage MongoDB / MinIO
Fault-Tolerant RNG Restoration Native (CPU, CUDA, NumPy, Py) Manual Manual Manual
Tensor Contract Validation Native (Pre-inference) Signature schema Logged schema only Logged schema only
Packaging Architecture Modular (KISS & SOLID) Monolithic package Monolithic client Complex SDK
Offline Operation 100% Offline Partial Requires offline mode Requires local server

Installation

Install using uv (recommended):

uv add mangosta

Or using standard pip:

pip install mangosta

Optional Dependencies

For ONNX graph verification using onnx.checker:

uv add "mangosta[onnx]"
# or
pip install "mangosta[onnx]"

Quickstart

1. Atomic Local Tracking

Track hyperparameters and step-level metrics with atomic disk flushing:

from mangosta import quick_track

with quick_track(experiment="vision", run_name="baseline_resnet") as run:
    run.log_params({"learning_rate": 1e-3, "batch_size": 32, "weight_decay": 1e-4})
    run.set_dataset("data/processed_images.parquet")
    
    for epoch in range(10):
        # Training iteration ...
        run.log_metric("train_loss", 0.342, step=epoch)
        run.log_metric("val_accuracy", 0.912, step=epoch)

2. Architecture Registration

Register neural network architectures under a family name and semantic version:

import torch
import torch.nn as nn
from mangosta import register_model

@register_model(family="classifier", version="1.0.0")
class ConvClassifier(nn.Module):
    def __init__(self, in_channels: int = 3, num_classes: int = 10) -> None:
        super().__init__()
        self.encoder = nn.Sequential(
            nn.Conv2d(in_channels, 16, kernel_size=3, padding=1),
            nn.ReLU(),
            nn.AdaptiveAvgPool2d((1, 1)),
        )
        self.head = nn.Linear(16, num_classes)

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        return self.head(self.encoder(x).flatten(1))

3. Checkpointing and Fault-Tolerant Resumption

Save complete training state including optimizer, scheduler, and all random generator states:

from mangosta import save_bundle, resume_training, ModelRegistry

# Save crash-consistent checkpoint
save_bundle(
    output_path="checkpoints/epoch_5.bundle",
    model=model,
    family="classifier",
    version="1.0.0",
    init_args={"in_channels": 3, "num_classes": 10},
    sample_input=torch.randn(1, 3, 32, 32),
    is_checkpoint=True,
    optimizer=optimizer,
    scheduler=scheduler,
    epoch=5,
    step=1250,
)

# Resume deterministically following an interruption
fresh_model = ModelRegistry.build("classifier", version="1.0.0", in_channels=3, num_classes=10)
fresh_optimizer = torch.optim.Adam(fresh_model.parameters(), lr=1e-3)
fresh_scheduler = torch.optim.lr_scheduler.StepLR(fresh_optimizer, step_size=5)

state = resume_training(
    bundle_path="checkpoints/epoch_5.bundle",
    model=fresh_model,
    optimizer=fresh_optimizer,
    scheduler=fresh_scheduler,
    restore_rng=True,
)

start_epoch = state.epoch + 1
start_step = state.step

4. Decoupled Production Inference

Load models dynamically without importing the underlying model class in your serving scripts:

import torch
from mangosta import load_bundle

# Reconstructs architecture via registry and mounts weights
bundle = load_bundle("artifacts/model_final.bundle")

# Inference with automated input signature validation
input_tensor = torch.randn(4, 3, 32, 32)
predictions = bundle.predict(input_tensor)

5. Standalone ONNX Export

Export directly to standard ONNX with automatic dictionary-to-tuple output unrolling and float16 precision:

from mangosta import export_onnx

export_onnx(
    model_or_bundle="artifacts/model_final.bundle",
    output_path="exports/model.onnx",
    sample_input_shape=(1, 3, 512, 512),
    output_mapping=["semantic_mask", "radius_map", "gradient_map"],
    input_names=["input0"],
    output_names=["output0", "output1", "output2"],
    dynamic_axes={
        "input0": {0: "batch", 2: "height", 3: "width"},
        "output0": {0: "batch", 2: "height", 3: "width"},
        "output1": {0: "batch", 2: "height", 3: "width"},
        "output2": {0: "batch", 2: "height", 3: "width"},
    },
    float16=True,
    opset_version=18,
    verify=True,
)

Command Line Interface (CLI)

mangosta provides a zero-daemon CLI utility:

# Inspect internal bundle contents, tensor signatures, and metadata
mangosta inspect checkpoints/epoch_5.bundle

# Generate a self-contained, offline interactive HTML report
mangosta report experiments/vision/baseline_resnet -o report.html
mangosta report checkpoints/epoch_5.bundle -o report.html

# Launch an ephemeral browser viewer (terminates cleanly with Ctrl+C)
mangosta view ./experiments --port 8501

# Export a bundle directly to ONNX from the terminal
mangosta export-onnx checkpoints/epoch_5.bundle -o model.onnx --fp16 --input-shape 1 3 32 32 -m models.classifier

Package Architecture

The library follows Single Responsibility (SRP) and Open-Closed (OCP) design principles:

src/mangosta/
|-- __init__.py           # Unified high-level public API
|-- exceptions.py         # Domain-specific exception hierarchy
|-- core/                 # Architecture registry and tensor contracts
|   |-- registry.py       # ModelRegistry, @register_model, dynamic SemVer resolution
|   `-- schema.py         # TensorSpec, ModelSchema, infer_schema
|-- artifacts/            # Persistence, atomic packaging, and loading
|   |-- bundle.py         # Atomic ZIP creation, RNG serialization, checkpointing
|   `-- loader.py         # Decoupled reconstruction, LoadedBundle, resume_training
|-- tracking/             # Experiment tracking and lineage
|   |-- tracker.py        # RunTracker, quick_track, SHA-256 dataset fingerprinting
|   `-- report.py         # Offline interactive HTML report generator
|-- export/               # Standalone production exports
|   `-- onnx.py           # ONNX exporter, dictionary unrolling, precision handling
`-- cli/                  # Command-line interface
    `-- main.py           # CLI entrypoints (inspect, report, view, export-onnx)

AI Agent Integration (Gemini / Antigravity Skill)

mangosta provides a production-grade Agent Skill designed for LLMs (Google Gemini, Antigravity CLI, Claude, OpenAI). The skill equips AI coding agents with the exact runbooks, API contracts, and defensive patterns needed to manage models autonomously without hallucinating commands or corrupting checkpoint states.

Installing the Skill in Your Project

To make your local AI agent an expert in mangosta, copy the public skill specification to your workspace customization folder:

mkdir -p .agents/skills/mangosta
cp skills/mangosta/SKILL.md .agents/skills/mangosta/SKILL.md

Once installed, AI coding agents automatically discover the skill via its standard YAML frontmatter:

  • Scope: Automated model registration, contract validation, checkpoint recovery, and ONNX exports.
  • Location in repository: skills/mangosta/SKILL.md

Development

Run tests and verification suites locally:

# Sync virtual environment
uv sync

# Run automated tests with coverage
uv run pytest -v --cov=mangosta

# Run linter and formatting checks
uv run ruff check src tests examples
uv run ruff format --check src tests examples

# Build package distributions (sdist and wheel)
uv build

License

MIT License.

Metadata

Release files for mangosta 0.1.0a1

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

Source distribution (sdist)

Source distribution for mangosta 0.1.0a1
File Size Uploaded Provenance
mangosta-0.1.0a1.tar.gz 113.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mangosta 0.1.0a1
File Interpreter ABI Platform
mangosta-0.1.0a1-py3-none-any.whl Python 3 none any Details

Total release size: 144.1 kB

Release files / mangosta-0.1.0a1.tar.gz

Download URL mangosta-0.1.0a1.tar.gz
Size 113.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e61312c47f3d381fd535ab33ad5a8faa5d7f14fda6dfb8a8fd1808a8d7386de9
BLAKE2b-256 checksum
How to use checksums
83292e4b01005e187d6210919a96105b450f6fe7812817f17725577b6a4dd8e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 20, 2026.

Transparency log

Release files / mangosta-0.1.0a1-py3-none-any.whl

Download URL mangosta-0.1.0a1-py3-none-any.whl
Size 31.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1fbfada2d782218bf9133395db92b9f4d8dfbc779435b0c15979add6b6aaa2b
BLAKE2b-256 checksum
How to use checksums
5247a1fdaacc9fd5fd0b0a86a15a4e153c6805c6937e3354063c61a25cbe2c1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 20, 2026.

Transparency log

Security for mangosta 0.1.0a1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mangosta-0.1.0a1.tar.gz

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 Oct 20, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release
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