Commit Best Practices Guide¶
Summary¶
This guide walks through best practices for committing the v2.0.0 changes to fennel.
Current Status¶
Test Results¶
✅ 109 tests passing (89%)
⚠️ 8 tests failing - These are old tests that reference deprecated internal methods (log_profile_func). These need updating but don't affect the v2 API.
⏭️ 6 tests skipped - JAX tests (optional dependency)
Git Status¶
- Branch:
master - Modified files: Documentation, config, pre-commit hooks, example notebooks (outputs stripped)
- Files changed: 9 (README.md, COMMIT_GUIDE.md, .gitignore, .pre-commit-config.yaml, example.ipynb, seed/examples/.ipynb)
- Recent updates:
- All Jupyter notebooks cleaned (outputs stripped via nbstripout)
- .gitignore updated to ignore venv patterns (venv/, .venv/)
- README.md expanded with v2 installation sections (from source, from GitHub)
- .pre-commit-config.yaml migrated to latest format (fixed deprecation warnings)
- COMMIT_GUIDE.md updated with notebook cleaning docs
Pre-Commit Checklist¶
1. Run Tests Locally ✅¶
2. Fix Test Failures (Optional for this commit)¶
The 8 failing tests are in old test files that need updating for internal API changes. You can: - Option A: Fix them now before committing - Option B: Commit v2 API first, then fix tests in a follow-up commit - Option C: Mark old tests as deprecated and add to TODO
3. Install Pre-commit Hooks¶
# Install pre-commit (if not already installed)
pip install pre-commit
# Install the git hooks
pre-commit install
# Run hooks on all files to see what needs fixing
pre-commit run --all-files
4. Review Changes¶
# See what's changed
git diff fennel/
# Review specific files
git diff fennel/fennel.py
git diff fennel/results.py
Commit Strategy¶
Current Session: Documentation & Tooling Updates¶
This session adds developer tooling and installation documentation for v2 API:
Stage all modified files:
# Documentation and installation
git add README.md
# Configuration and tooling
git add .gitignore
git add .pre-commit-config.yaml
git add COMMIT_GUIDE.md
# Cleaned notebooks (outputs stripped)
git add notebooks/example.ipynb
git add notebooks/example_jax.ipynb
git add notebooks/example_v2.ipynb
git add seed/examples/plot_generator.ipynb
git add seed/examples/pyface_fennel.ipynb
# Commit
git commit -m "docs: Add v2 installation docs, pre-commit hooks, and notebook output cleaning
Changes:
- README.md: Added v2 installation sections (from source, from GitHub direct URL)
- README.md: Clarified that current PyPI v1.3.4; master contains v2.0
- .gitignore: Added patterns for virtualenv directories (venv*/, .venv*/)
- .pre-commit-config.yaml: Added nbstripout hook for automatic notebook cleaning
- .pre-commit-config.yaml: Migrated to latest format (fixed deprecation warnings)
- COMMIT_GUIDE.md: Documented notebook stripping in pre-commit section
- All notebooks: Stripped outputs via nbstripout (outputs removed, metadata normalized)
Impact:
- Users can now install v2 from source or directly from GitHub
- Developers can clone and install with pre-commit hooks enabled
- Jupyter notebooks stay clean in version control (no cell outputs)
- All pre-commit warnings resolved; ready for future updates
BREAKING: None - documentation and tooling only
"
Recommended: Single Feature Commit¶
For a coherent feature release like v2.0, a single comprehensive commit often makes sense:
# Stage all new v2 API files
git add fennel/results.py
git add fennel/validation.py
git add tests/test_v2_api.py
# Stage modified core files
git add fennel/__init__.py
git add fennel/fennel.py
git add fennel/config.py
# Stage documentation
git add CHANGELOG.md
git add UPGRADE_GUIDE_V2.md
git add README.md
git add notebooks/example_v2.ipynb
# Stage CI/CD and tooling
git add .pre-commit-config.yaml
git add .github/workflows/tests.yml
git add pytest.ini
git add pyproject.toml
git add Makefile
# Commit with descriptive message
git commit -m "feat: Add v2.0 API with result containers and validation
Major Features:
- Result container classes (TrackYieldResult, EMYieldResult, HadronYieldResult)
- New *_v2() methods returning structured results
- Convenience methods (quick_track, quick_cascade, calculate)
- Comprehensive input validation with ValidationError
- 100% backward compatible with v1.x API
New Modules:
- fennel.results: Result container classes with pretty printing
- fennel.validation: Input validation and error handling
Documentation:
- UPGRADE_GUIDE_V2.md with migration examples
- example_v2.ipynb notebook demonstrating new API
- Updated README with quick start
- CHANGELOG.md tracking all changes
Testing:
- 123 tests total (109 passing)
- Full test coverage for v2 API
- Backward compatibility tests
- CI/CD via GitHub Actions
BREAKING: None - fully backward compatible
Fixes: Improved error messages and input validation
Refs: #issue_number (if applicable)"
Alternative: Atomic Commits¶
If you prefer smaller, focused commits:
# Commit 1: Core validation module
git add fennel/validation.py
git commit -m "feat: Add validation module with comprehensive input checks"
# Commit 2: Result containers
git add fennel/results.py
git commit -m "feat: Add result container classes for structured API responses"
# Commit 3: v2 API methods
git add fennel/fennel.py fennel/__init__.py
git commit -m "feat: Add *_v2() methods returning result containers"
# Commit 4: Convenience methods
git add fennel/fennel.py
git commit -m "feat: Add convenience methods (quick_track, calculate)"
# Commit 5: Tests
git add tests/test_v2_api.py pytest.ini
git commit -m "test: Add comprehensive v2 API test coverage"
# Commit 6: Documentation
git add CHANGELOG.md UPGRADE_GUIDE_V2.md README.md notebooks/example_v2.ipynb
git commit -m "docs: Add v2.0 documentation and upgrade guide"
# Commit 7: CI/CD
git add .pre-commit-config.yaml .github/workflows/tests.yml
git commit -m "ci: Add pre-commit hooks and enhanced GitHub Actions"
GitHub Actions¶
Once pushed, GitHub Actions will automatically: 1. ✅ Run tests on Python 3.8-3.12 2. ✅ Test on Ubuntu, macOS, Windows 3. ✅ Check code formatting (black, isort) 4. ✅ Run linting (flake8) 5. ✅ Upload coverage to Codecov
Post-Commit Tasks¶
1. Push to GitHub¶
# Push to your feature branch
git push origin smb/version_2_0
# Watch CI run at: https://github.com/MeighenBergerS/fennel/actions
2. Create Pull Request¶
- Title: "feat: v2.0 API with result containers and validation"
- Description: Reference UPGRADE_GUIDE_V2.md
- Labels: enhancement, major-version
- Checklist: Tests pass, docs updated, backward compatible
3. Tag Release (After Merge)¶
# After PR is merged to master
git checkout master
git pull
# Create annotated tag
git tag -a v2.0.0 -m "Release v2.0.0: Result containers and validation API
Major Features:
- Structured result containers
- Comprehensive validation
- Convenience methods
- 100% backward compatible
See CHANGELOG.md for full details."
# Push tag
git push origin v2.0.0
4. Create GitHub Release¶
- Go to Releases → Draft a new release
- Choose tag:
v2.0.0 - Title: "fennel v2.0.0 - Result Containers & Validation"
- Description: Copy from CHANGELOG.md
- Attach: Built distributions (wheels, sdist)
5. Publish to PyPI (Optional)¶
Changelog Maintenance¶
Update CHANGELOG.md with every significant change: - Added: New features - Changed: Changes in existing functionality - Deprecated: Soon-to-be removed features - Removed: Removed features - Fixed: Bug fixes - Security: Vulnerability fixes
Pre-commit Hooks¶
The .pre-commit-config.yaml will automatically: - Remove trailing whitespace - Fix end-of-file - Format code with black - Sort imports with isort - Lint with flake8 - Check YAML/JSON/TOML syntax - Strip outputs from Jupyter notebooks (.ipynb)
Run manually anytime:
pre-commit run --all-files
# Only strip notebook outputs across the repo
pre-commit run nbstripout --all-files
Version Bumping¶
fennel uses Semantic Versioning: - MAJOR (v2.0.0): Breaking changes (though we're backward compatible!) - MINOR (v2.1.0): New features, backward compatible - PATCH (v2.0.1): Bug fixes, backward compatible
Update version in:
- fennel/__init__.py
- pyproject.toml
- setup.py (if present)
Questions?¶
- Should I fix the 8 failing tests first?
-
Optional. They're testing deprecated internal methods. You can fix them in a follow-up PR.
-
Should I squash commits before merging?
-
If you made multiple commits, GitHub can squash them when merging the PR.
-
What about the JAX tests?
-
They're optional. CI will skip them if JAX isn't installed.
-
Do I need to update the docs site?
- MkDocs is already configured. Run
mkdocs gh-deployto update the site.
Ready to Commit?¶
If you're satisfied with the changes, use the commit command from "Commit Strategy" above!