Skip to content

Contributing

  • Python 3.10+
  • Git
  • A local LLM provider for testing (LM Studio or Ollama recommended)
Terminal window
git clone https://github.com/kevinjobin1/model-lens.git
cd model-lens
pip install -r requirements.txt
pip install ".[dev]"
pre-commit install

The [dev] extra in pyproject.toml installs:

  • ruff — linting and formatting
  • mypy — type checking
  • pytest and pytest-cov — testing
  • pre-commit — git hook management

On every commit, the following checks run automatically:

HookWhat it checks
trailing-whitespaceNo trailing whitespace
end-of-file-fixerFiles end with a newline
check-yaml / check-json / check-tomlValid config files
check-added-large-filesNo files > 500KB
ruff check --fixLinting with auto-fixes
ruff formatConsistent code formatting
mypyType checking (MYPYPATH=packages)

To run manually:

Terminal window
pre-commit run --all-files

These are enforced on every push via CI (.github/workflows/ci.yml):

Terminal window
# Lint
ruff check packages/ apps/cli/ tests/
# Format
ruff format --check --diff packages/ apps/cli/ tests/
# Type check
MYPYPATH=packages mypy packages/ apps/cli/
# Test
pytest tests/ -v

The CI is strict — any failure blocks the build. No || echo fallbacks.

  • Events package is self-contained — never import from core, providers, or benchmarks into packages/events/
  • Providers never import core — each client depends only on base.py
  • Core never imports benchmarks — imports flow the other direction
  • Dual-authority benchmarksbenchmark.py and bench_apple_silicon_v2.py are intentionally separate; do not merge them

Use urllib.parse.urljoin() and helpers from packages/providers/base.py:

from providers.base import normalize_base_url, get_root_url, url_join

Banned patterns: .rstrip("/"), .removesuffix("/v1"), f"{base}/{path}" string concatenation.

from packages.logging import get_logger
logger = get_logger(__name__)
logger.info("message", key="value")

No print() for observability data — only for CLI user-facing output.

Never use bare except: or except Exception:. Catch specific types:

try:
...
except (requests.ConnectionError, requests.Timeout):
...

Providers emit TokenGeneratedEvent per streaming token and CompletionEvent after response. Benchmarks emit RunLifecycleEvent (started/completed/failed) and MetricEvent per result. Always use the thread-safe EventBus.

Terminal window
# Full suite
pytest tests/ -v
# Specific test files
pytest tests/test_provider_clients.py -v
# With coverage
pytest tests/ -v --cov=packages --cov-report=term
  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run pre-commit checks: pre-commit run --all-files
  5. Run tests: pytest tests/ -v
  6. Submit a PR with a clear description

The docs site lives at apps/docs/ (Starlight). To preview:

Terminal window
cd apps/docs
bun install
bun run dev # → http://localhost:4321