Skip to main content

A Python toolkit for ML experiment management based on SwanLab and Lark

Project description

OwLab logo

OwLab

ML experiments, tracked & notified.

A Python toolkit for the full lifecycle of machine learning experiments — experiment tracking with SwanLab, notifications & data management with Lark (Feishu), and local storage.

PyPI swanlab Static Badge License Python 3.9+


✨ Features

📈 Experiment tracking — Metrics and runs with SwanLab
📊 Experiment data management — Results in Feishu spreadsheets
📢 Message notifications — Start/end alerts via Lark webhook
💾 Multi-backend backup — Local output + Lark; logs, results, and models saved

🚀 Quick Start

Install from PyPI:

pip install owlab
# or: uv pip install owlab
from owlab import OwLab

owlab = OwLab()
owlab.init(project="my_project", experiment_name="run_1", config={"lr": 0.01, "epochs": 10})

for step in range(10):
    owlab.log({"loss": 1.0 - step * 0.1, "acc": step * 0.1}, step=step)

owlab.finish(results=[{"method": "baseline", "dataset1": {"measure": "MCM", "accuracy": 0.95}}])

Without any config, OwLab runs in local-only mode: results go to ./output/ and no Lark/SwanLab calls are made.


📦 Installation

Method Command
PyPI (recommended) pip install owlabDownload on PyPI
uv uv pip install owlab
From source git clone https://github.com/Lounwb/OwLab.git && cd OwLab && pip install -e .

⚙️ Configuration

To enable Lark (Feishu) and SwanLab, put your credentials in one of:

  • File: ~/.owlab/config.json or ./.owlab/config.json
  • Environment: OWLAB_LARK__WEBHOOK__WEBHOOK_URL, OWLAB_LARK__API__APP_ID, etc.

Example config file (use .owlab/config.json.example as a template):

{
  "lark": {
    "webhook": {
      "webhook_url": "https://open.feishu.cn/open-apis/bot/v2/hook/...",
      "signature": "your_signature"
    },
    "api": {
      "app_id": "your_app_id",
      "app_secret": "your_app_secret",
      "root_folder_token": "your_root_folder_token"
    }
  },
  "swanlab": {
    "api_key": "your_swanlab_api_key"
  },
  "storage": {
    "local_path": "./output"
  }
}

Environment variables follow the pattern OWLAB_<SECTION>__<KEY>__<SUBKEY> (e.g. OWLAB_LARK__WEBHOOK__WEBHOOK_URL).


📖 Usage

1. Initialize

from owlab import OwLab

owlab = OwLab()
owlab.init(
    project="my_project",           # Required
    experiment_name="exp_001",      # Optional; defaults to project
    description="Short description",
    type="baseline",                # e.g. baseline / debug / ablation — used for folder naming
    version="1.0",                 # Experiment version
    tags=["baseline"],             # Optional tags
    config={
        "methods": [...],          # Method definitions for result tables
        "datasets": [...],
        "metrics": [...],
        "measures": [...],
        "experiment_params": {"learning_rate": 0.01, "batch_size": 32},
        "seed": 42,
    },
)

2. Log metrics during training

for epoch in range(100):
    owlab.log({"loss": loss, "accuracy": acc}, step=epoch)

3. Finish and save results

Call finish(results=...) with a list of result rows. Each row can include method, dataset, measure, and metric values. These are written to local files and, when configured, to Feishu spreadsheets.

owlab.finish(results=[
    {
        "method": "method1",
        "dataset1": {"measure": "MCM", "accuracy": 0.95, "loss": 0.05},
        "dataset2": {"measure": "MCM", "accuracy": 0.92, "loss": 0.08},
        "Average": {"measure": "MCM", "accuracy": 0.935, "loss": 0.065},
    },
    # ...
])

4. Output layout

  • Local: ./output/<type>/<experiment_name>_<timestamp>/
    • results.csv, results.json, owlab.log, model/
  • Lark: Notifications via webhook; result tables written to Feishu via API (when configured).
  • SwanLab: Metrics and runs visible in your SwanLab project (when api_key is set).

📄 License & Links


🙏 Acknowledgments

⭐ Star History

Star History Chart

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

owlab-0.1.1.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

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

owlab-0.1.1-py3-none-any.whl (34.8 kB view details)

Uploaded Python 3

File details

Details for the file owlab-0.1.1.tar.gz.

File metadata

  • Download URL: owlab-0.1.1.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for owlab-0.1.1.tar.gz
Algorithm Hash digest
SHA256 55ce2acb1024848f9ebc300fd8302aea6113e7ce4e81a77ce4dd41d5cbbaf173
MD5 70433a27577083059f537d893300f90e
BLAKE2b-256 5a9c3d77b7fb0b978f0634ca7971ae27a0e551aedb2053586b4a58cfa91a0f10

See more details on using hashes here.

File details

Details for the file owlab-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: owlab-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 34.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for owlab-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6df1c816740e060e6d80696381632352969dffacf90a5867f5658697ba7bba6f
MD5 b1e84615b999de849b7cff497bfcd998
BLAKE2b-256 64e519b1913ae015071eeb6e2843b3d15bc2cb9b1e052f45866a6636b5040672

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