Skip to main content

Rich CLI progress monitoring for machine learning training loops

Project description

trainpit

Quality Pytest Linux Pytest macOS Pytest Windows Coverage

trainpit is a Python package for rich CLI progress monitoring in machine learning training loops.

The goal is to make long-running training jobs easier to inspect from a terminal, with progress output that is useful during development, debugging, and experiment runs.

Status

trainpit is in early development. The public train tracker API is available, and the Textual dashboard demo can display progress, metrics, learning curves, timing, events, custom panels, and configurable graph renderers. Renderer integration around the public tracker API is still evolving.

Requirements

  • Python 3.13 or later
  • uv for local development

Installation

Install the latest published release:

pip install trainpit

In a uv-managed project:

uv add trainpit

Or install into the active virtual environment with uv:

uv pip install trainpit

Install from a local checkout for development:

uv sync --locked

For development, include the development dependency group:

uv sync --locked --all-extras --dev

Install Git hooks for local quality checks:

uv run pre-commit install --install-hooks

Usage

Wrap a training loop with the train tracker:

from trainpit import train

with train(total_epochs=3, total_steps=5, label="demo-run") as progress:
    for epoch in range(1, 4):
        progress.epoch(epoch)

        for step in range(1, 6):
            loss = 1.0 / (epoch * step)
            progress.step(
                step,
                loss=loss,
                metrics={"acc": step / 5},
                learning_rate=0.0001,
            )

See the documentation tutorial for a fuller walkthrough.

A runnable notebook version is available at examples/train_tutorial.ipynb.

To run a small PyTorch neural network example:

uv run --group examples python examples/torch_nn.py

This opens the Textual dashboard and updates progress, metrics, and learning curves while the model trains. Press q to close the dashboard after inspecting the final state.

For non-interactive output:

uv run --group examples python examples/torch_nn.py --plain

To preview the Textual dashboard demo:

uv run python examples/textual_dashboard.py

To preview user-defined dashboard panels:

uv run python examples/custom_panels.py

Development

Run the test suite:

uv run pytest

Run tests with coverage:

uv run pytest --cov=trainpit --cov-report=term-missing --cov-report=xml

Run the configured pre-commit checks manually:

uv run pre-commit run --all-files
uv run pre-commit run --hook-stage pre-push --all-files

Check formatting:

uv run ruff format --check .

Run lint checks:

uv run ruff check .

Build distribution artifacts:

uv build

Publish releases by merging the repository's develop branch into main with a pull request. The Publish workflow reads the version from pyproject.toml, creates a GitHub release tagged as v<version>, builds the source distribution and wheel, then uploads them to PyPI with Trusted Publishing.

If a release for that version already exists, the workflow skips publishing so the same package version is not uploaded twice. Publishing a GitHub release manually also triggers the PyPI upload path.

Before the first release, configure a PyPI Trusted Publisher for:

  • owner: Moriyuki-S
  • repository: trainpit
  • workflow: publish.yml
  • environment: pypi

Before opening a pull request, run:

uv lock --check
uv run ruff format --check .
uv run ruff check .
uv run pytest
uv run pytest --cov=trainpit --cov-report=term-missing --cov-report=xml
uv build

CI

GitHub Actions checks the following:

  • lockfile validation
  • formatting and linting with ruff
  • Python file compilation
  • package build
  • wheel installation in a temporary environment
  • pytest on Linux, macOS, and Windows
  • coverage on Linux with coverage.xml uploaded as an artifact
  • documentation builds with zensical

On pull requests, each CI workflow updates a dedicated conversation comment with the overall job status, run link, commit, and step-level outcomes.

Dependabot is configured for GitHub Actions, uv, and devcontainer updates.

Contributing

Issues and pull requests are welcome while the project is taking shape.

For code changes, please keep the scope focused and include tests when the change affects behavior. For larger changes, open an issue first so the approach can be discussed before implementation.

License

MIT License.

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

trainpit-0.1.0.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

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

trainpit-0.1.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file trainpit-0.1.0.tar.gz.

File metadata

  • Download URL: trainpit-0.1.0.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for trainpit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 338aa7e25994c354d42b041f871ab1922e7d54b94cbfd7d485e7328615f3431b
MD5 c6b6b8ef47c7f18478084780d8788811
BLAKE2b-256 1998130e6f9f7434ed7cae3818acdc66a87d0fe5b3627366d7a1acdf23d137a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for trainpit-0.1.0.tar.gz:

Publisher: publish.yml on Moriyuki-S/trainpit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trainpit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: trainpit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for trainpit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ab9a2a618612eca52574d02bbcb392c7e89317285a785edfb8c3b9fbe372c18
MD5 85cd1dadd30df420ddb83a5773babb33
BLAKE2b-256 c4814ad2c86a892b89a7bd1c389a0b8eb8a096478364a091dbde3d2bebf2aec7

See more details on using hashes here.

Provenance

The following attestation bundles were made for trainpit-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Moriyuki-S/trainpit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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