Lightweight training awareness system for machine learning workflows.
Project description
TrainWatch
A lightweight training awareness system for machine learning workflows.
TrainWatch notifies developers when ML training completes or fails and provides a minimal run summary. It is designed to be easy to integrate, framework-agnostic, and reliable.
Install
pip install trainwatch-notify
Note: the PyPI distribution name is trainwatch-notify, but the import package remains trainwatch.
Quickstart
from trainwatch import monitor
monitor.start()
try:
# Your training loop here.
monitor.log(epoch=1, loss=0.42, val_acc=0.81)
monitor.end()
except Exception as exc:
monitor.fail(exc)
raise
Convenience context manager:
from trainwatch import monitor
with monitor.watch():
# Your training loop here.
pass
Configuration
TrainWatch reads configuration from trainwatch_config.yaml by default. You can also set TRAINWATCH_CONFIG to an absolute path or pass a config dict to monitor.end(config=...) and monitor.fail(config=...).
Example config (YAML):
notifications:
email: true
telegram: false
email:
host: smtp.example.com
port: 587
username: user@example.com
password: app_password
sender: user@example.com
recipient: user@example.com
use_tls: true
subject: TrainWatch Notification
logging:
enabled: true
path: trainwatch_run.json
An example config is available at examples/trainwatch_config.yaml.
Cloud Notifications (Resend + Cloudflare)
If you want users to receive email without SMTP setup, use the TrainWatch Cloud backend.
- Deploy the Cloudflare Worker in
cloudflare/and setRESEND_API_KEYandRESEND_FROM. - Set the backend URL locally:
export TRAINWATCH_BASE_URL="https://your-worker.workers.dev"
- Register an email once:
from trainwatch import add_email
add_email("you@example.com")
After that, monitor.end() and monitor.fail() will send notifications automatically if credentials exist.
Cloud backend enforces a default limit of 10 emails per user per day.
To remove the email:
from trainwatch import delete_email
delete_email()
CLI
You can also register/delete emails via the CLI:
trainwatch add-email you@example.com
trainwatch delete-email
trainwatch help
Mid-Run Notifications
Manual milestone:
from trainwatch import monitor
monitor.notify("Model loaded on GPU")
Time-based heartbeat:
monitor.heartbeat(interval_seconds=900) # every 15 minutes
# ...
monitor.stop_heartbeat()
Step-based pings:
for epoch in range(100):
train()
monitor.step(notify_every=10)
Configure defaults once:
monitor.configure(
heartbeat_interval=900,
step_notify_every=10,
heartbeat_message="Training still running",
)
Optional per-channel minimum intervals:
limits:
email_min_interval_seconds: 1800
telegram_min_interval_seconds: 300
cloud_min_interval_seconds: 1800
Environment Variables
These environment variables override config values when set.
TRAINWATCH_CONFIGTRAINWATCH_BASE_URLTRAINWATCH_API_KEYTRAINWATCH_CREDENTIALS_PATHTRAINWATCH_DISABLE_PROXYTRAINWATCH_NOTIFICATIONS_EMAILTRAINWATCH_NOTIFICATIONS_TELEGRAMTRAINWATCH_EMAIL_HOSTTRAINWATCH_EMAIL_PORTTRAINWATCH_EMAIL_USERNAMETRAINWATCH_EMAIL_PASSWORDTRAINWATCH_EMAIL_SENDERTRAINWATCH_EMAIL_RECIPIENTTRAINWATCH_EMAIL_USE_TLSTRAINWATCH_EMAIL_SUBJECTTRAINWATCH_TELEGRAM_BOT_TOKENTRAINWATCH_TELEGRAM_CHAT_IDTRAINWATCH_LOGGING_ENABLEDTRAINWATCH_LOGGING_PATH
Logging
Set logging.enabled: true in the config to write a run summary JSON file. The default path is trainwatch_run.json relative to the config file location.
Testing
Install dev dependencies and run tests:
pip install -e .[dev]
pytest
Vision
TrainWatch aims to become an intelligent training awareness layer that lets developers manage and monitor long-running training processes without constant supervision. The long-term goal is an intelligent training companion that integrates into broader ML tooling ecosystems and improves developer productivity.
Mission
Provide a lightweight, reliable, easy-to-integrate system that captures training lifecycle events and delivers concise summaries through notification channels such as email or messaging services. The mission prioritizes:
- Simplicity of integration
- Reliability of notifications
- Minimal disruption to existing workflows
Problem Statement
Long-running ML training jobs often require repeated manual checks for completion or failure. This interrupts workflow and delays awareness of errors. Existing enterprise platforms are too heavy for many developers, and there is a gap for a simple, developer-friendly tool focused on basic training awareness.
Value Proposition
TrainWatch allows developers to step away during training without losing awareness of outcomes. Minimal integration and reliable notifications reduce monitoring fatigue and improve experimentation efficiency.
License
Licensed under the GNU Lesser General Public License v3.0 (LGPL-3.0). See LICENSE.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trainwatch_notify-0.1.0.tar.gz.
File metadata
- Download URL: trainwatch_notify-0.1.0.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1075a657fca418fdb937c70a2023516781c0cd4e1f032d35c53e5e16ebd5cb41
|
|
| MD5 |
939aaa44e4f69e8da5e5c244a7389f45
|
|
| BLAKE2b-256 |
f96bff2177cea0d8dfa16e32265a29cdb5a7a265a8bdf64946a8946169cbf11c
|
File details
Details for the file trainwatch_notify-0.1.0-py3-none-any.whl.
File metadata
- Download URL: trainwatch_notify-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6cdafe49e21222587e453504bf3c399f3c7b3f0659ae622676a56bdd7b968c7
|
|
| MD5 |
d9076774205d429e8cdc1d665550caad
|
|
| BLAKE2b-256 |
63ba83a2fae7d113cf0402ba63eefc3222174708d6e42885207250064ff82487
|