Skip to main content

Export trained ML models to ML-Dash

Project description

mldash

Export trained ML models from notebooks to ML-Dash.

Install

uv tool install mldash-sdk

Or with pipx:

pipx install mldash-sdk

Requires Python 3.8+.

Update

Use whichever installer you used:

uv tool upgrade mldash-sdk        # uv
pipx upgrade mldash-sdk           # pipx
pip install --upgrade mldash-sdk  # pip

After updating the CLI, restart the bridge if it's running: Ctrl-C the mldash connect terminal, then re-run mldash connect.

Quick Start

import mldash

# One-time login (saved to ~/.config/mldash/credentials)
mldash.login()

# See your projects
mldash.list_projects()

# Set active project for this notebook (by name or ID)
mldash.init(project="Churn Analysis")

# Train your model
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier()
model.fit(X_train, y_train)

# Export — just model + name, everything else is resolved
mldash.export(model=model, name="Churn Predictor")

Authentication

mldash.login() — One-time setup

Run once per machine. You'll be prompted for your ML-Dash URL and API key:

>>> mldash.login()
ML-Dash URL: https://api.mldash.com
Get your API key from: https://www.mldash.com/developers/keys
API Key: ········
Authenticated with https://api.mldash.com
Credentials saved to ~/.config/mldash/credentials

Credentials are stored locally at ~/.config/mldash/credentials (chmod 600) and reused automatically.

You can also pass values directly (useful for CI or scripting):

mldash.login(url="https://api.mldash.com", api_key="mldash_xxx")

mldash.logout()

mldash.logout()  # removes stored credentials

mldash.whoami()

mldash.whoami()
# URL:     https://api.mldash.com
# API Key: mldash_abcde...
# Project: Churn Analysis (id=3)

Alternative auth methods

These work without calling login():

Environment variables:

export MLDASH_URL=https://api.mldash.com
export MLDASH_API_KEY=mldash_your_key_here

Google Colab Secrets:

Add MLDASH_URL and MLDASH_API_KEY to your Colab Secrets (key icon in sidebar).

Browsing

mldash.list_projects()

mldash.list_projects()
# ID     Name                           Models   Datasets
# ----------------------------------------------------
# 1      Churn Analysis                 3        2
# 2      Imported Models                1        0

mldash.list_models()

mldash.list_models()                          # all models
mldash.list_models(project="Churn Analysis")  # filter by project
mldash.list_models(project=1)                 # filter by project ID

mldash.list_datasets()

mldash.list_datasets()                          # all datasets
mldash.list_datasets(project="Churn Analysis")  # filter by project

mldash.read_dataset() — Download as DataFrame

df = mldash.read_dataset(1)                    # by ID
df = mldash.read_dataset("my-dataset")         # by slug
df = mldash.read_dataset("alice/her-dataset")  # public dataset by username/slug
# Loaded dataset: 150 rows, 5 columns

Requires pandas (not included in SDK dependencies — install separately).

Project Association

mldash.init() — Set active project

Accepts a project name (string) or project ID (int):

mldash.init(project="Churn Analysis")   # by name
mldash.init(project=3)                  # by ID

# All exports now go to that project
mldash.export(model=model1, name="Logistic v1")
mldash.export(model=model2, name="XGBoost v1")

The project is saved to credentials, so it persists across sessions. Override per-export with the project= argument:

mldash.export(model=model, name="Experiment", project="Other Project")

If no project is set, exports go to an auto-created Imported Models project.

Usage

Export with artifacts

mldash.export(
    model=model,
    name="Sales Predictor",
    scaler=scaler,              # StandardScaler, MinMaxScaler, etc.
    encoder=encoder,            # OneHotEncoder, LabelEncoder, etc.
    label_map={"0": "no", "1": "yes"},
    features={"age": "numeric", "dept": "categorical", "review": "text"},
    target={"churn": "categorical"},
)

mldash.push() — Alias for export

mldash.push(model=model, name="My Model")  # same as export()

Save to local ZIP (offline)

mldash.save(
    model=model,
    name="My Model",
    path="./my_model.zip",
)
# Upload the ZIP manually via the ML-Dash web UI

Auto-detection

The package auto-detects:

  • task_type — classification or regression (from sklearn mixins)
  • framework — sklearn, xgboost, lightgbm, etc. (from module path)
  • hyperparameters — via model.get_params()
  • model_class — e.g., RandomForestClassifier
  • n_features — from model.n_features_in_
  • class_labels — from model.classes_

Typical Notebook Workflow

# Cell 1: Setup (run once)
import mldash
mldash.login()
mldash.init(project="MAS 648 Final")

# Cell 2-N: Train models...
model = RandomForestClassifier(n_estimators=100)
model.fit(X_train, y_train)

# Cell N+1: Export
mldash.export(model=model, name="RF 100 trees")

CLI

The SDK includes a command-line interface:

mldash login              # Authenticate (prompts for URL + API key)
mldash logout             # Remove stored credentials
mldash whoami             # Show current auth status
mldash connect            # Start local compute bridge for Studio
mldash setup              # Create managed Python venv (~/.mldash/venv/)
mldash install xgboost    # Install packages into managed venv
mldash uninstall          # Remove managed venv + credentials

mldash connect

Starts a local Python bridge so code written in ML-Dash Studio executes on your machine:

mldash connect                      # auto-select port
mldash connect --port 8765          # specific port
mldash connect --url http://...     # custom server URL

mldash setup

Creates a managed Python environment at ~/.mldash/venv/ with common ML packages (pandas, numpy, scikit-learn, matplotlib, seaborn, mldash-sdk). The bridge auto-uses this environment.

mldash setup              # create environment
mldash setup --force      # recreate from scratch

mldash uninstall

Removes the managed environment (~/.mldash/) and stored credentials (~/.config/mldash/credentials):

mldash uninstall                    # confirms before deleting
mldash uninstall --yes              # no prompts
mldash uninstall --keep-credentials # remove the venv but keep your login

To remove the CLI itself, run pipx uninstall mldash-sdk afterwards.

Errors

from mldash import MLDashValidationError, MLDashAuthError, MLDashUploadError

try:
    mldash.export(model=model, name="Test")
except MLDashValidationError as e:
    print(f"Invalid input: {e}")
except MLDashAuthError as e:
    print(f"Auth failed: {e}")
except MLDashUploadError as e:
    print(f"Upload failed: {e}")

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

mldash_sdk-0.7.0.tar.gz (42.4 kB view details)

Uploaded Source

Built Distribution

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

mldash_sdk-0.7.0-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

Details for the file mldash_sdk-0.7.0.tar.gz.

File metadata

  • Download URL: mldash_sdk-0.7.0.tar.gz
  • Upload date:
  • Size: 42.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for mldash_sdk-0.7.0.tar.gz
Algorithm Hash digest
SHA256 e4db7e435a45fcbe24b92d0f3aaf5eddbf785356f1d2872a6f336349e1529703
MD5 7d17e30c2e8a84afc0627ef3f3c1ede2
BLAKE2b-256 acae40c5e852df61c08cf024b84bc43083219d50f04e5a3c213d8731d6fc9986

See more details on using hashes here.

File details

Details for the file mldash_sdk-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: mldash_sdk-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 36.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for mldash_sdk-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be7466df45b9e0a78c3fc60a2e6e2ba72617bddd24d07f5b7930f7f357cae260
MD5 d64acc37d292d17aa54ebc316cdd939e
BLAKE2b-256 ffe483deda7e27d583ae3a17276acf3f0221f2f1cb919b328efc946c7f068088

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