Skip to main content

ML experiment tracking and data storage

Project description

ML-Dash

A simple and flexible SDK for ML experiment tracking and data storage with background buffering for high-performance training.

Features

Core Features

  • Three Usage Styles: Pre-configured singleton (dxp), context manager, or direct instantiation
  • Dual Operation Modes: Remote (API server) or local (filesystem)
  • OAuth2 Authentication: Secure device flow authentication for CLI and SDK
  • Auto-creation: Automatically creates namespace, project, and folder hierarchy
  • Upsert Behavior: Updates existing experiments or creates new ones
  • Experiment Lifecycle: Automatic status tracking (RUNNING, COMPLETED, FAILED, CANCELLED)
  • Organized File Storage: Prefix-based file organization with unique snowflake IDs
  • Rich Metadata: Tags, bindrs, descriptions, and custom metadata support
  • Simple API: Minimal configuration, maximum flexibility

Performance Features (New in 0.6.7)

  • Background Buffering: Non-blocking I/O operations eliminate training interruptions
  • Automatic Batching: Time-based (5s) and size-based (100 items) flush triggers
  • Track API: Time-series data tracking for robotics, RL, and sequential experiments
  • Numpy Image Support: Direct saving of numpy arrays as PNG/JPEG images
  • Parallel Uploads: ThreadPoolExecutor for efficient file uploads

Installation

Using uv (recommended) Using pip
uv add ml-dash
pip install ml-dash

Quick Start

1. Authenticate (Required for Remote Mode)

ml-dash login

This opens your browser for secure OAuth2 authentication. Your credentials are stored securely in your system keychain.

2. Start Tracking Experiments

Option A: Use the Pre-configured Singleton (Easiest)

from ml_dash.auto_start import dxp

# Start experiment (uploads to https://api.dash.ml by default)
with dxp.run:
    dxp.log("Training started", level="info")
    dxp.params.set(learning_rate=0.001, batch_size=32)

    for epoch in range(10):
        loss = train_one_epoch()
        dxp.metrics("train").log(loss=loss, epoch=epoch)

Option B: Create Your Own Experiment

from ml_dash import Experiment

with Experiment(
  prefix="alice/my-project/my-experiment",
  dash_url="https://api.dash.ml",  # token auto-loaded
).run as experiment:
  experiment.log("Hello!", level="info")
  experiment.params.set(lr=0.001)

Option C: Local Mode (No Authentication Required)

from ml_dash import Experiment

with Experiment(
  project="my-project", prefix="my-experiment", dash_root=".dash"
).run as experiment:
  experiment.log("Running locally", level="info")

New Features in 0.6.7

🚀 Background Buffering (Non-blocking I/O)

All write operations are now buffered and executed in background threads:

with Experiment("my-project/exp").run as experiment:
    for i in range(10000):
        # Non-blocking! Returns immediately
        experiment.log(f"Step {i}")
        experiment.metrics("train").log(loss=loss, accuracy=acc)
        experiment.files("frames").save_image(frame, to=f"frame_{i}.jpg")

    # All data automatically flushed when context exits

Configure buffering via environment variables:

export ML_DASH_BUFFER_ENABLED=true
export ML_DASH_FLUSH_INTERVAL=5.0
export ML_DASH_LOG_BATCH_SIZE=100

📊 Track API (Time-Series Data)

Perfect for robotics, RL, and sequential experiments. Supports timestamp inheritance for synchronized multi-modal data and track slicing for efficient querying.

with Experiment("robotics/training").run as experiment:
    for step in range(1000):
        # First track auto-generates timestamp
        experiment.tracks("robot/position").append(
            step=step,
            x=position[0],
            y=position[1],
            z=position[2]
        )

        # Other tracks inherit same timestamp with _ts=-1 (synchronized!)
        experiment.tracks("camera/left").append(width=640, height=480, _ts=-1)
        experiment.tracks("robot/velocity").append(vx=0.1, vy=0.0, _ts=-1)
        experiment.tracks("sensors/lidar").append(ranges=[1.5, 2.0], _ts=-1)

    experiment.tracks.flush()

    # Query synchronized data with floor-match timestamp queries
    pose_slice = experiment.tracks("robot/position").slice(0.0, 10.0)

    # Single timestamp query
    entry = pose_slice.findByTime(5.5)  # Returns entry at timestamp 5.0

    # Batch queries
    entries = pose_slice.findByTime([1.0, 3.5, 7.0])  # Returns list of 3 entries

    # Iterate through time range
    for entry in pose_slice:
        print(entry["timestamp"], entry["x"], entry["y"])

See docs/tracks.md for complete documentation.

🖼️ Numpy Image Support

Save numpy arrays directly as images (PNG/JPEG):

import numpy as np

with Experiment("vision/training").run as experiment:
    # From MuJoCo, OpenCV, PIL, etc.
    pixels = renderer.render()  # numpy array

    # Save as PNG (lossless)
    experiment.files("frames").save_image(pixels, to="frame.png")

    # Save as JPEG with quality control
    experiment.files("frames").save_image(pixels, to="frame.jpg", quality=85)

    # Auto-detection also works
    experiment.files("frames").save(pixels, to="frame.jpg")

See CHANGELOG.md for complete release notes.

Development Setup

Installing Dev Dependencies

To contribute to ML-Dash or run tests, install the development dependencies:

Using uv (recommended) Using pip
uv sync --extra dev
pip install -e ".[dev]"

This installs:

  • pytest>=8.0.0 - Testing framework
  • pytest-asyncio>=0.23.0 - Async test support
  • sphinx>=7.2.0 - Documentation builder
  • sphinx-rtd-theme>=2.0.0 - Read the Docs theme
  • sphinx-autobuild>=2024.0.0 - Live preview for documentation
  • myst-parser>=2.0.0 - Markdown support for Sphinx
  • ruff>=0.3.0 - Linter and formatter
  • mypy>=1.9.0 - Type checker

Running Tests

Using uv Using pytest directly
uv run pytest
pytest

Building Documentation

Documentation is built using Sphinx with Read the Docs theme.

Build docs Live preview Clean build
uv run python -m sphinx -b html docs docs/_build/html
uv run sphinx-autobuild docs docs/_build/html
rm -rf docs/_build

The live preview command starts a local server and automatically rebuilds when files change.

Alternatively, you can use the Makefile from within the docs directory:

cd docs
make html          # Build HTML documentation
make clean         # Clean build files

For maintainers, to build and publish a new release: uv build && uv publish

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

ml_dash-0.6.21.tar.gz (111.3 kB view details)

Uploaded Source

Built Distribution

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

ml_dash-0.6.21-py3-none-any.whl (127.7 kB view details)

Uploaded Python 3

File details

Details for the file ml_dash-0.6.21.tar.gz.

File metadata

  • Download URL: ml_dash-0.6.21.tar.gz
  • Upload date:
  • Size: 111.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ml_dash-0.6.21.tar.gz
Algorithm Hash digest
SHA256 4de1f586718f60d5f815baa9e10284580d1c3ef241f9f463178d966f1b8357fc
MD5 c418fccb0ebd5e5740323e9df2f9b47e
BLAKE2b-256 003f5404dc464b9b4bb2e57c479ae531dd54bc225487df4acd7d0bb5893acd31

See more details on using hashes here.

File details

Details for the file ml_dash-0.6.21-py3-none-any.whl.

File metadata

  • Download URL: ml_dash-0.6.21-py3-none-any.whl
  • Upload date:
  • Size: 127.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ml_dash-0.6.21-py3-none-any.whl
Algorithm Hash digest
SHA256 d90054cbe0b259df2a06c1f0eccb6a7b2f4968b61ee7020a3546de7d040ad2a6
MD5 1a8d8bb9a82aa775fc7b1acd82ed1c11
BLAKE2b-256 095c815fd807625dcf2558815fcd7c3cc6b41838fd512831aaff05c7f12cc792

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