Metadata-Version: 2.5
Name: trainbay
Version: 0.0.1
Summary: Log training metrics to a local SQLite file and watch them live in your IDE.
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# trainbay

Log training metrics to a local SQLite file and watch them live in your IDE with the Trainbay extension.
No account, no server, no browser.

```python
import trainbay

trainbay.init(name="mnist-baseline", config={"lr": 3e-4, "batch_size": 64})  # optional
for step in range(1000):
    loss = train_step()
    trainbay.log({"train/loss": loss}, step=step)
trainbay.finish()  # optional, runs automatically when the script exits
```

## How it works

- `log()` only puts values in memory. A background thread writes them in batches (every 50 values or 0.5 s).
- Data goes to `.trainbay/trainbay.db` in the project root: the first folder that has `.trainbay`, `.git` or `pyproject.toml`, walking up from the script's folder, then from the working directory.
  Set `TRAINBAY_DIR` to use another folder.
- The `.trainbay/` folder ignores itself in git.
- On a network path (UNC, `\\wsl$`, mapped network drive), SQLite cannot share the file safely, so the database goes to `%LOCALAPPDATA%\Trainbay\<project>-<hash>` and a warning is printed.
- The run is `finished` when the script exits normally, `stopped` on Ctrl+C and `failed` on any other uncaught exception.
  A run killed hard (Task Manager, `taskkill /F`, SIGKILL) stays `running` with a stale heartbeat; the IDE shows it as stopped.
  Up to `flush_interval` seconds of the newest values are lost in that case; call `trainbay.flush()` to write everything now.
- With `torchrun`, only the process with `RANK=0` writes.
- Values must be numbers (Python numbers, NumPy scalars, 0-d tensors). NaN is stored as empty.

Requires Python 3.11+. No dependencies besides the standard library.

## Development

```powershell
uv run pytest
```
