ML-Dash API Reference
Complete API reference for the ML-Dash Python SDK. For tutorials and workflow examples, see /parameters, /metrics, /files, and /complete-examples.
Table of Contents
- Experiment
- Parameters (
exp.params) - Logging (
exp.log,exp.logs) - Metrics (
exp.metrics) - Files (
exp.files) - Auto-Start (
dxp)
Experiment
The Experiment class is the main entry point for ML-Dash. It represents a single machine learning experiment run.
Constructor
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
prefix | str | None | Universal key in format owner/project/path/name |
readme | str | None | Human-readable experiment readme/description |
tags | List[str] | None | Tags for categorization and search |
bindrs | List[str] | None | Binders for advanced organization |
metadata | Dict[str, Any] | None | Additional structured metadata |
dash_url | str | bool | None | Remote API URL. None = local-only (no remote); True = use default remote (https://api.dash.ml); string = custom URL. Token auto-loaded from ~/.dash/token.enc |
dash_root | str | ".dash" | Local storage root path. Set to None for remote-only mode |
Prefix format: owner/project/path.../name — first segment is owner, second is project, remaining segments form the folder path, last segment becomes the experiment name.
Example:
Properties
| Property | Type | Description |
|---|---|---|
experiment.name | str | Experiment name |
experiment.project | str | Project name |
experiment.readme | str | Experiment readme/description |
experiment.tags | List[str] | Experiment tags |
experiment.bindrs | List[str] | Experiment bindrs |
experiment.folder | str | Folder path |
experiment.id | str | Experiment ID (remote mode only, after start) |
experiment.data | dict | Full experiment data (remote mode only, after start) |
RunManager
exp.run returns a RunManager supporting three usage patterns: context manager, decorator, or manual control.
Context Manager
Decorator
Manual Control
Methods
| Method | Description | Status Set |
|---|---|---|
run.start() | Start the experiment | RUNNING |
run.complete() | Mark as successfully completed | COMPLETED |
run.fail() | Mark as failed | FAILED |
run.cancel() | Mark as cancelled | CANCELLED |
Parameters
Access via the exp.params property. See /parameters for usage patterns.
params.set(**kwargs)
Set or merge experiment parameters. Supports nested dicts (auto-flattened to dot notation for storage).
Returns: ParametersBuilder
params.get(flatten=True)
Retrieve parameters.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
flatten | bool | True | If True, return dot-notation flat dict; if False, return hierarchical dict |
Returns: dict
Logging
Log messages with severity levels and optional metadata. See /logging for patterns.
exp.log(message, level="info", metadata=None, **kwargs)
Log a message.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
message | str | required | Log message |
level | str | "info" | Log level: debug, info, warn, error, fatal |
metadata | dict | None | Structured metadata |
**kwargs | any | — | Metadata as keyword arguments |
Fluent API: exp.logs
Convenience methods for each level.
| Method | Equivalent |
|---|---|
exp.logs.debug(msg, **meta) | exp.log(msg, level="debug", **meta) |
exp.logs.info(msg, **meta) | exp.log(msg, level="info", **meta) |
exp.logs.warn(msg, **meta) | exp.log(msg, level="warn", **meta) |
exp.logs.error(msg, **meta) | exp.log(msg, level="error", **meta) |
exp.logs.fatal(msg, **meta) | exp.log(msg, level="fatal", **meta) |
Log Levels
| Level | Description |
|---|---|
debug | Detailed diagnostic information |
info | General informational messages (default) |
warn | Warning messages for potential issues |
error | Error messages for failures |
fatal | Fatal errors causing termination |
Metrics
Track time-series metrics. Access via exp.metrics. See /metrics for patterns.
exp.metrics(prefix)
Create/get a MetricBuilder for the given namespace prefix.
Parameters: prefix: str
Returns: MetricBuilder
metrics.log(**data)
Log a metric data point. When called on a prefixed builder, the prefix is applied. When called on the top-level metrics, supports grouped fields like train=dict(...), eval=dict(...).
Returns: MetricBuilder
metrics("prefix").buffer(**data)
Buffer per-batch values in memory (not yet written). Use with log_summary() to aggregate.
Returns: None
metrics.buffer.log_summary(*aggregations)
Compute and log summary statistics from buffered values.
Parameters: *aggregations: str — names of aggregations. Defaults to "mean". Supported: mean, std, min, max, count, percentile codes like p50, p90, p95, p99.
Returns: None
metrics.flush()
Flush pending metric writes to disk/remote.
Returns: None
metrics("prefix").read(start_index=0, limit=100)
Read logged data points for the given metric.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
start_index | int | 0 | First index to read |
limit | int | 100 | Maximum points to return |
Returns: dict — {"data": [...], "startIndex", "endIndex", "total", "hasMore"}
metrics("prefix").stats()
Get summary statistics for a metric.
Returns: dict — {"count", "firstValue", "lastValue", ...}
Method Summary
| Method | Returns | Description |
|---|---|---|
metrics(prefix) | MetricBuilder | Get builder with prefix |
metrics.log(**data) | MetricBuilder | Log data point |
metrics("p").log(**data) | MetricBuilder | Log with prefix |
metrics("p").buffer(**data) | None | Buffer for summary |
metrics.buffer.log_summary(*aggs) | None | Log aggregated summary |
metrics.flush() | None | Flush pending writes |
metrics("p").read(start_index, limit) | dict | Read data points |
metrics("p").stats() | dict | Get statistics |
Files
Upload, download, and manage experiment files. Access via exp.files. See /files for patterns.
exp.files(**kwargs)
Create a FileBuilder.
Parameters:
| Parameter | Type | Description |
|---|---|---|
path | str | Logical path/prefix (positional, e.g. "models", "configs") |
description | str | File description |
tags | List[str] | File tags |
bindrs | List[str] | File bindrs |
metadata | dict | File metadata |
file_id | str | File ID (for download/update/delete) |
dest_path | str | Destination path (for download) |
save(local_path, **kwargs)
Upload a file from local disk.
Returns: dict
save_json(content, to)
Serialize a Python object as JSON and upload.
Parameters:
| Parameter | Type | Description |
|---|---|---|
content | Any | JSON-serializable object |
to | str | Target filename |
Returns: dict
save_torch(model, to)
Save a PyTorch model (or state dict) via torch.save.
Parameters:
| Parameter | Type | Description |
|---|---|---|
model | Any | nn.Module or state dict |
to | str | Target filename |
Returns: dict
save_pkl(content, to)
Serialize a Python object via pickle and upload.
Parameters:
| Parameter | Type | Description |
|---|---|---|
content | Any | Picklable object |
to | str | Target filename |
Returns: dict
save_fig(fig=None, to, **kwargs)
Save a matplotlib figure.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
fig | Optional[Any] | None | Figure (uses current via plt.gcf() if None) |
to | str | required | Target filename |
**kwargs | any | — | Passed to fig.savefig (e.g. dpi, bbox_inches) |
Returns: dict
save_video(frames, to, fps=20, **kwargs)
Encode a list/array of frames as MP4 or GIF.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
frames | Union[List, Any] | required | Frames (grayscale or RGB ndarray, or list of frames) |
to | str | required | Target filename (.mp4, .gif) |
fps | int | 20 | Frames per second |
codec | str | — | Codec name (e.g. "libx264") |
quality | int | — | Quality setting |
Returns: dict
list()
List files for the current builder filters.
Returns: List[dict]
download(dest_path=None)
Download a file (requires file_id).
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
dest_path | Optional[str] | None | Target local path; if None, uses original filename |
Returns: str — local path of the downloaded file
update()
Update file metadata (requires file_id).
Returns: dict
delete()
Soft-delete a file (requires file_id).
Returns: dict
Method Summary
| Method | Parameters | Returns | Description |
|---|---|---|---|
files(**kwargs) | see above | FileBuilder | Create builder |
save(local_path, **kwargs) | str, kwargs | dict | Upload file |
save_json(content, to) | Any, str | dict | Save JSON |
save_torch(model, to) | Any, str | dict | Save PyTorch model |
save_pkl(content, to) | Any, str | dict | Save pickle |
save_fig(fig, to, **kwargs) | Optional[Any], str, kwargs | dict | Save matplotlib figure |
save_video(frames, to, fps, **kwargs) | Union[List, Any], str, int, kwargs | dict | Save video |
list() | — | List[dict] | List files |
download(dest_path) | Optional[str] | str | Download |
update() | — | dict | Update metadata |
delete() | — | dict | Soft delete |
Auto-Start
The ml_dash.auto_start module exposes dxp, a pre-configured, auto-started Experiment singleton for quick prototyping and notebooks.
Behavior
- Pre-configured: name
"dxp", project"scratch", local storage at.dash - Auto-started: ready to use on import; no
.run.start()needed - Auto-completed: closed on Python exit via
atexit - Full API: supports all
Experimentmethods
Fixed Configuration
| Property | Value | Mutable |
|---|---|---|
| Name | "dxp" | No |
| Project | "scratch" | No |
| Storage Mode | Local (.dash) | No |
| Local Path | ".dash" | No |
| Parameters | empty initially | Yes |
| Tags | empty | No |
| Readme | None | No |
Usage
Manual Lifecycle
The standard run methods still work:
Regular Experiment vs. dxp
| Feature | Experiment | dxp |
|---|---|---|
| Import | from ml_dash import Experiment | from ml_dash.auto_start import dxp |
| Configuration | User-defined | Fixed |
| Lifecycle | Manual / context manager / decorator | Auto-started, auto-completed |
| Storage | Local or remote | Local only |
| Instances | Many | Single global |
| Use case | Production / multi-run | Prototyping / notebooks |