Skip to main content

Local-first observability for ML systems

Project description

Contexta

Local-first observability for ML systems.

PyPI version Python versions alpha local-first

CI Test Matrix Docs and Examples Packaging

Quickstart | Product Surface | Docs Map

Contexta is a local-first ML observability library. It provides one canonical import root, one canonical CLI, one canonical workspace, and one consistent contract for writing, storing, querying, comparing, and recovering observability data — without a cloud backend.

Why Contexta

  • One product surface Start from from contexta import Contexta instead of stitching together separate tools.
  • Canonical local workspace Keep metadata, records, artifacts, reports, and recovery state in a local .contexta/ workspace.
  • Read-oriented investigation Query runs, compare outcomes, inspect diagnostics, follow lineage, and build reports from canonical data.
  • Recovery built in Replay, backup, restore, and artifact transfer are first-class features, not separate utilities.
  • Framework-agnostic Works alongside scikit-learn, PyTorch, HuggingFace Transformers, vLLM, or any other ML stack.

Quickstart

Install

pip install contexta

or with uv:

uv add contexta

Run your first example

The fastest way to see Contexta in action is the sklearn tabular example — no GPU required:

pip install contexta "scikit-learn>=1.6"
uv run python examples/quickstart/qs01_sklearn_tabular.py

This trains an SVM and a Random Forest on the UCI Wine dataset, logs CV fold metrics and evaluation metrics to a local .contexta/ workspace, then compares the two runs and registers the best model as a deployment.

For deep learning and LLM examples see examples/quickstart/.

Minimal usage

from datetime import datetime, timezone
from contexta import Contexta
from contexta.config import UnifiedConfig, WorkspaceConfig
from contexta.contract import (
    Project, Run, StageExecution,
    MetricPayload, MetricRecord, RecordEnvelope,
)

ctx = Contexta(config=UnifiedConfig(
    project_name="my-project",
    workspace=WorkspaceConfig(root_path=".contexta"),
))
store = ctx.metadata_store

now = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")

store.projects.put_project(Project(project_ref="project:my-project", name="my-project", created_at=now))
store.runs.put_run(Run(run_ref="run:my-project.run-01", project_ref="project:my-project",
                       name="run-01", status="completed", started_at=now, ended_at=now))

ctx.record_store.append(MetricRecord(
    envelope=RecordEnvelope(
        record_ref="record:my-project.run-01.r00001", record_type="metric",
        recorded_at=now, observed_at=now, producer_ref="my-script",
        run_ref="run:my-project.run-01",
        completeness_marker="complete", degradation_marker="none",
    ),
    payload=MetricPayload(metric_key="accuracy", value=0.95, value_type="float64"),
))

snapshot = ctx.get_run_snapshot("run:my-project.run-01")
report   = ctx.build_snapshot_report("run:my-project.run-01")
print(report.title)

store.close()

Optional dependencies

Contexta's core runtime only requires duckdb. Install framework extras only for what you use:

pip install "contexta[sklearn]"       # + scikit-learn
pip install "contexta[torch]"         # + PyTorch
pip install "contexta[transformers]"  # + HuggingFace Transformers + PyTorch
pip install "contexta[all-integrations]"  # all of the above

Product Surface

Surface Status Role When To Start Here
Contexta Stable Unified facade Default starting point
contexta.config Stable Config models, profiles, env overrides When you need explicit config control
contexta.contract Stable Canonical models, validation, serialization When you work directly with schema-level types
contexta.capture Stable Runtime capture scopes and emissions When facade-level capture is not enough
contexta.store.metadata Stable Metadata truth plane Advanced store access
contexta.store.records Stable Record truth plane Replay, scan, export, integrity workflows
contexta.store.artifacts Stable Artifact truth plane Artifact ingest, verify, export, import
contexta.interpretation Stable Query, compare, diagnostics, lineage, reports Read and investigation flows
contexta.recovery Advanced Replay, backup, restore Operator and recovery work

The internal namespaces contexta.api, contexta.runtime, contexta.common, and contexta.surfaces are not public API targets.

Documentation Map

Core Entry Points

  • README.md — product overview, install, quickstart
  • docs/index.md — document hub

User Guide

  • docs/user-guide/getting-started.md
  • docs/user-guide/key-features.md
  • docs/user-guide/tools-and-surfaces.md
  • docs/user-guide/core-concepts.md
  • docs/user-guide/common-workflows.md
  • docs/user-guide/advanced.md
  • docs/user-guide/case-studies.md

Reference

  • docs/reference/api-reference.md
  • docs/reference/cli-reference.md

Operations And Contribution

  • docs/operations.md
  • docs/faq.md
  • CONTRIBUTING.md
  • SECURITY.md

Examples

  • examples/quickstart/ — qs01 (sklearn), qs02 (PyTorch CNN), qs03 (BERT), qs04 (vLLM RAG)
  • examples/case_studies/ — 12 real-world observability scenarios
  • examples/recovery/ — operator-oriented recovery workflows

Design Notes

  • local-first: all data stays on your machine
  • schema-first: every record follows a canonical contract
  • reproducibility-oriented: environment snapshots and provenance are first-class
  • explicit about degraded or incomplete states

Internally, Contexta separates truth-owning planes for metadata, records, and artifact bodies, then builds query, report, and recovery surfaces over those planes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contexta-1.0.0.tar.gz (440.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

contexta-1.0.0-py3-none-any.whl (248.4 kB view details)

Uploaded Python 3

File details

Details for the file contexta-1.0.0.tar.gz.

File metadata

  • Download URL: contexta-1.0.0.tar.gz
  • Upload date:
  • Size: 440.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for contexta-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b9e95d895d1a4f30705dee21325824ba1ebb6c71b7675189c7c289f4c3706244
MD5 8177bdf422f1abdd0e79827d3b74a1c0
BLAKE2b-256 08efc69d3aa2f4a5d22e81baa59e3b5e5b4538428e2db933e3930c3dfe200801

See more details on using hashes here.

File details

Details for the file contexta-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: contexta-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 248.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for contexta-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 890b48af025806e30a590c71a4d3569a88ccf96bdb44f61959a4452b79c5a939
MD5 3260b9348bd43b405d8a6ecefa9bdd42
BLAKE2b-256 247b1c2baaf3e50a9a737c2215fe95e99c0a71fd626c0027315408c708fddc2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page