Developing torch-mentor
This page covers everything needed to work on the mentor codebase itself: cloning, installing dev dependencies, running the test suite, building docs, and publishing a release to PyPI.
Clone and install
git clone https://github.com/anguelos/torch_mentor
cd torch_mentor
Create and activate a virtual environment, then install the package in editable mode with all development dependencies:
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
To also install documentation dependencies:
pip install -e ".[dev,docs]"
Running the test suite
Run the full test suite (unit + integration + CLI tests):
make test
# equivalent to:
pytest tests/ -q
Run only unit tests with a coverage report:
make unittest
# equivalent to:
pytest tests/unit_testing/ -q --cov=mentor --cov-report=term-missing
Run a specific test file or test function:
pytest tests/unit_testing/test_mentee.py -v
pytest tests/unit_testing/test_mentee.py::test_create_train_objects -v
Test layout
Directory |
What it covers |
|---|---|
|
Individual classes and functions in isolation |
|
Checkpoint save / resume round-trips |
|
End-to-end training loops |
|
|
Building the docs locally
make docs
# opens at docs/_build/html/index.html
Build a single-page HTML version:
make docs_single
Build a PDF (requires a LaTeX installation):
make docs_pdf
Code style
The project uses ruff for linting, configured
in pyproject.toml with a 160-character line limit. It is installed with
.[dev].
Check for issues without touching any files:
make testlint
# equivalent to: ruff check mentor/ tests/
Auto-fix everything ruff can fix safely (unused imports, import order, etc.):
make autolint
# equivalent to: ruff check --fix mentor/ tests/
Type checking:
mypy mentor/
Versioning
The version string lives in two places — keep them in sync before a release:
setup.py->version=mentor/__init__.py->__version__
Publishing to PyPI
Build source and wheel distributions:
pip install build twine
python -m build
Check the distributions before uploading:
twine check dist/*
Upload to PyPI (you need a PyPI account and an API token):
twine upload dist/*
Or upload to TestPyPI first to verify everything looks right:
twine upload --repository testpypi dist/*
pip install --index-url https://test.pypi.org/simple/ torch-mentor
The package is published at https://pypi.org/project/torch-mentor/.