Troubleshooting¶
This guide covers common issues you might encounter when working on gwmock-noise and how to resolve them.
Setup Issues¶
Pre-commit Hook Installation Fails¶
Problem: pre-commit install returns an error or hooks don't run on commit.
Solutions:
- Ensure you're in the project root directory
- Verify Python virtual environment is activated
-
Reinstall pre-commit:
pip uninstall pre-commit pip install pre-commit pre-commit install -
Check if
.gitdirectory exists (must be a git repository) - Try running manually:
pre-commit run --all-files
Commit message conventions¶
Pre-commit here runs on staged files, not on the commit message. Still follow Conventional Commits for commits and PR titles; see Contributing.
Virtual Environment Issues¶
Problem: Packages can't be found or dependencies conflict.
Solutions:
-
Create a fresh virtual environment:
rm -rf .venv python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate -
Upgrade pip:
python -m pip install --upgrade pip -
Install dependencies (dev and docs tooling live in uv dependency groups, not
[project.optional-dependencies]; see Installation):uv sync --group dev --group docs -
Verify installation:
python -c "import gwmock_noise; print(gwmock_noise.__version__)"
Python Version Mismatch¶
Problem: python -m venv .venv fails or tests don't run with wrong Python
version.
Solutions:
-
Check your Python version:
python --version -
Ensure Python 3.12 or higher is installed (the package targets 3.12–3.14; see
requires-pythoninpyproject.toml) -
Use a supported Python version when creating the venv:
python3.12 -m venv .venv -
Or use uv for version management:
uv venv --python 3.12 source .venv/bin/activate
Testing Issues¶
Pytest Fails to Collect Tests¶
Problem: pytest returns "no tests collected" or import errors.
Solutions:
- Verify test file naming: Must be
test_*.pyor*_test.py - Verify test function naming: Must start with
test_ - Run from the repository root;
pyproject.tomlsetstestpaths = "tests"andpythonpath = ["src"]for discovery -
Run pytest with verbose output:
uv run pytest -vv -
Check test discovery:
uv run pytest --collect-only
Import Errors in Tests¶
Problem: Tests can't import gwmock_noise or its submodules.
Solutions:
-
Install the project and dev dependencies (editable install is implied by
uv syncfrom the repo root):uv sync --group dev -
Verify package layout: Python sources live under
src/gwmock_noise/ - Check
pyproject.tomlhas correctpackagesconfiguration - Run from project root directory
- Verify
__init__.pyexists in package directory
Coverage Report Issues¶
Problem: Coverage report shows 0% or missing files.
Solutions:
-
Run pytest with coverage:
uv run pytest --cov=src --cov-report=html -
Check
[tool.coverage.*]and[tool.pytest.ini_options]inpyproject.toml - Ensure source files have proper imports
- Verify test files import from
src/layout correctly
Pre-commit Hook Issues¶
Hooks Running Too Slowly¶
Problem: Pre-commit takes a very long time or times out.
Solutions:
-
Check which hooks are slow:
pre-commit run --all-files --verbose -
Consider excluding large files:
exclude: | (?x)^( large_data_file.csv| node_modules/ )$ -
Run specific hooks:
pre-commit run ruff --all-files # Just ruff
Formatting Changes After Commit¶
Problem: Pre-commit auto-fixes files, but you didn't expect it.
Solutions:
- This is normal behavior - review the changes
-
Stage the new changes:
git add . git commit -m "feat: restage after pre-commit" # Use a valid Conventional Commit title -
Modify tool settings if behavior is unwanted (in
pyproject.toml) -
Disable specific hooks temporarily:
SKIP=ruff pre-commit run --all-files
"Unstaged Changes" After Running Hooks¶
Problem: Pre-commit modified files but they're not staged.
Solutions:
-
This is expected - review changes:
git diff -
Stage the changes:
git add . -
Try committing again
- Or use
git add -Ato stage all changes before commit
CI/CD Issues¶
CI Workflow Fails on Push¶
Problem: GitHub Actions workflow fails unexpectedly.
Solutions:
- Check the Actions tab in GitHub for error details
-
Run tests locally first:
uv run pytest pre-commit run --all-files -
Common causes:
- Dependency installation failed: Compare with CI (
uv sync --group dev --frozenin.github/workflows/ci.yml) - Python version mismatch: Verify Python versions in workflow matrix
- Missing dependencies: Add to
pyproject.toml - Pre-commit failures: Fix locally first
- Dependency installation failed: Compare with CI (
-
Re-run failed jobs from GitHub Actions UI
CodeQL Analysis Takes Too Long¶
Problem: CI is slow due to CodeQL analysis.
Solutions:
- This is normal (~2-3 minutes per run)
- To disable CodeQL:
- Remove or edit the workflow in
.github/workflows/codeql.yml - Keep Bandit in pre-commit for basic security
- Remove or edit the workflow in
- Or assess whether CodeQL is worth the CI time for this repository
- CodeQL provides value for security-critical projects
Release Workflow Fails¶
Problem: Release or publish workflow doesn't work.
Solutions:
- Verify tag format matches pattern:
v[0-9]+.[0-9]+.[0-9]+*- Good:
v1.0.0,v1.2.3-alpha - Bad:
1.0.0,release-1.0.0
- Good:
- Check CI workflow passed first (required by release workflow)
- Verify git-cliff configuration in
cliff.toml - For publishing:
- The publish workflow uses OIDC (
id-token: write); configure a trusted publisher on PyPI for this GitHub repo, or verify secrets if you use token-based publishing - Inspect
.github/workflows/publish.ymlfor the exact steps
- The publish workflow uses OIDC (
Documentation Issues¶
Zensical Site Won't Build¶
Problem: uv run zensical serve or uv run zensical build fails.
Solutions:
-
Verify Zensical and doc dependencies are installed:
uv sync --group docs -
Check
zensical.tomlsyntax (must be valid TOML) - Verify markdown files exist and paths are correct
- Check for circular includes or missing includes
-
Run with verbose output:
uv run zensical build --verbose
Documentation Not Updating on GitHub Pages¶
Problem: You pushed changes but the docs aren't updated online.
Solutions:
- Verify GitHub Pages is enabled:
- Go to repository Settings → Pages
- Under "Build and deployment", select "GitHub Actions" as the source
- This allows the documentation workflow to deploy directly
- Check documentation workflow ran successfully:
- Go to Actions tab
- Look for the Documentation workflow
(
.github/workflows/documentation.yml)
- Verify changes were pushed to the correct branch
- Wait 1-2 minutes for Pages to build
- Hard refresh browser (Ctrl+Shift+R or Cmd+Shift+R)
- Check browser cache isn't serving old version
API Documentation Not Generating¶
Problem: API reference pages are empty or show errors.
Solutions:
-
Verify docstrings are present on public APIs under
src/gwmock_noise/ -
Ensure the docs dependency group is installed (includes
mkdocstrings-python):uv sync --group docs -
Verify navigation in
zensical.tomlincludes the API section and thatdocs/api/index.mduses mkdocstrings directives (for examplegwmock_noise) -
Rebuild the site locally:
uv run zensical build --verbose -
Ensure re-exported symbols in
src/gwmock_noise/__init__.pymatch what you expect in the API reference
Dependencies & Package Issues¶
"ModuleNotFoundError" When Running CLI¶
Problem: Running gwmock-noise --help fails with module not found.
Solutions:
-
Install the package in development mode from the repo root:
uv sync --group dev -
Verify entry points in
pyproject.toml:[project.scripts] gwmock-noise = "gwmock_noise.cli.main:app" -
Check the specified Typer app exists and is callable
-
Remember PyPI distribution name vs import path:
- Distribution / CLI script name:
gwmock-noise(hyphen;[project]nameand[project.scripts]key) - Import package:
gwmock_noise(underscore; directory undersrc/)
- Distribution / CLI script name:
Dependency Conflicts¶
Problem: pip install fails with conflict messages.
Solutions:
-
Check Python version:
python --version -
Create fresh virtual environment:
rm -rf .venv && python -m venv .venv source .venv/bin/activate -
Upgrade pip:
python -m pip install --upgrade pip -
Install with verbose output to see conflict:
uv sync --group dev --group docs --verbose -
Check
pyproject.tomlfor overly restrictive version constraints
Newer Version of Tool Breaks Things¶
Problem: Pre-commit hooks or tools updated and now fail.
Solutions:
-
Check what changed:
pre-commit autoupdate --dry-run -
Update individual tool:
pre-commit autoupdate --repo https://github.com/pre-commit/pre-commit-hooks -
Test changes:
pre-commit run --all-files -
Pin to known-good version in
.pre-commit-config.yaml:rev: v1.0.0 # Specific version instead of latest
Getting Help¶
If you encounter issues not listed here:
- Check existing issues: Search gwmock-noise issues
- Review logs carefully: Error messages usually point to the root cause
- Search documentation: Published docs are at https://leuven-gravity-institute.github.io/gwmock-noise/
- Try minimal reproduction: Isolate the problem to a single file/command
- Ask for help: Open an
issue with:
- Your environment (Python version, OS)
- Steps to reproduce
- Full error message/logs
- What you've already tried