Thank you for your interest in contributing to LineamentLearning! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Testing
- Pull Request Process
- Style Guide
This project adheres to a code of conduct that all contributors are expected to follow:
- Be respectful and inclusive
- Welcome newcomers
- Focus on constructive feedback
- Respect differing viewpoints
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR-USERNAME/LineamentLearning.git cd LineamentLearning - Add upstream remote:
git remote add upstream https://github.com/RichardScottOZ/LineamentLearning.git
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode with dev dependencies
pip install -e ".[dev,full,modern-ui]"
# Verify installation
python -c "import tensorflow as tf; print(tf.__version__)"We use several tools to maintain code quality:
- Black: Code formatting
- Flake8: Linting
- MyPy: Type checking
- Pytest: Testing
Install pre-commit hooks:
pip install pre-commit
pre-commit installgit checkout -b feature/my-new-feature
# or
git checkout -b fix/issue-123Branch naming conventions:
feature/- New featuresfix/- Bug fixesdocs/- Documentation changesrefactor/- Code refactoringtest/- Adding tests
- Write clean, readable code
- Follow the style guide (see below)
- Add type hints to new functions
- Update documentation as needed
- Add tests for new functionality
Write clear, descriptive commit messages:
git add .
git commit -m "Add U-Net architecture with attention mechanism
- Implement spatial and channel attention
- Add configuration options for attention
- Update documentation
- Add unit tests
Fixes #123"Commit message format:
- First line: Short summary (50 chars or less)
- Blank line
- Detailed description (wrap at 72 chars)
- Reference issues and PRs
# Run all tests
pytest
# Run with coverage
pytest --cov=. --cov-report=html
# Run specific test file
pytest tests/test_model.py
# Run specific test
pytest tests/test_model.py::test_build_unetExample test structure:
import pytest
from config import Config
from model_modern import build_model
class TestModelBuilding:
"""Test model building functionality."""
def test_build_rotatenet(self):
"""Test RotateNet architecture creation."""
config = Config()
config.model.architecture = 'RotateNet'
model = build_model(config)
assert model is not None
assert model.input_shape[1:] == (45, 45, 8)
assert model.output_shape[1] == 1
def test_build_unet(self):
"""Test U-Net architecture creation."""
config = Config()
config.model.architecture = 'UNet'
model = build_model(config)
assert model is not None
assert model.name == 'UNet'Aim for:
- 90%+ coverage for new code
- 100% coverage for critical paths
- Tests for edge cases and error conditions
-
Update your branch with upstream:
git fetch upstream git rebase upstream/main
-
Run tests:
pytest
-
Check code quality:
black . flake8 . mypy .
-
Update documentation:
- Update README.md if needed
- Update CHANGELOG.md
- Add docstrings to new functions
-
Push to your fork:
git push origin feature/my-new-feature
-
Create Pull Request on GitHub
-
Fill out PR template:
- Clear description of changes
- Link to related issues
- Screenshots for UI changes
- Test results
-
Request review from maintainers
- Code follows style guide
- Tests added and passing
- Documentation updated
- CHANGELOG.md updated
- No merge conflicts
- CI/CD checks passing
Follow PEP 8 with these specifics:
# Standard library
import os
import sys
from pathlib import Path
# Third-party
import numpy as np
import tensorflow as tf
from tensorflow import keras
# Local
from config import Config
from model_modern import build_modelfrom typing import List, Optional, Tuple
def train_model(
config: Config,
data_path: str,
epochs: Optional[int] = None
) -> keras.Model:
"""Train a model with given configuration.
Args:
config: Configuration object
data_path: Path to training data
epochs: Number of epochs (uses config if None)
Returns:
Trained Keras model
"""
passUse Google style:
def function_with_docstring(param1: int, param2: str) -> bool:
"""Short description.
Longer description if needed. Can span multiple lines
and include examples.
Args:
param1: Description of param1
param2: Description of param2
Returns:
Description of return value
Raises:
ValueError: When param1 is negative
Example:
>>> function_with_docstring(5, "test")
True
"""
pass- Classes:
PascalCase(e.g.,ModelTrainer) - Functions/Methods:
snake_case(e.g.,build_model) - Constants:
UPPER_SNAKE_CASE(e.g.,MAX_EPOCHS) - Private:
_leading_underscore(e.g.,_internal_method)
- Maximum 88 characters (Black default)
- Maximum 72 for docstrings/comments
# 1. Module docstring
"""Module for model training."""
# 2. Imports
import tensorflow as tf
# 3. Constants
MAX_EPOCHS = 100
# 4. Classes and functions
class ModelTrainer:
pass
def train_model():
pass
# 5. Main execution guard
if __name__ == '__main__':
main()Use consistent formatting:
{
"model": {
"architecture": "UNet",
"window_size": 64
}
}- Use Markdown for documentation files
- Keep lines under 80 characters
- Use code blocks with language tags
- Include examples where helpful
- Add comprehensive test suite
- Create Jupyter notebook examples
- Implement Gradio/Streamlit dashboard
- Add data loading pipeline (see DATA_LOADING_ROTATION_IMPROVEMENTS.md)
- Implement rotation augmentation integration (see DATA_LOADING_ROTATION_IMPROVEMENTS.md)
- Docker containerization
- Add more model architectures
- Implement additional data augmentation options
- Add model export (ONNX, TFLite)
- Create API server
- Add visualization tools
- Improve documentation
- Add type hints to legacy code
- Write unit tests
- Fix small bugs
- Add examples
For data loading and rotation augmentation improvements, we have detailed specifications:
- 📖 DATA_LOADING_ROTATION_IMPROVEMENTS.md - Complete implementation guide
- 📖 PIPELINE_COVERAGE.md - Current state analysis
These documents provide:
- Technical requirements and API designs
- Implementation roadmap with time estimates
- Code examples and test strategies
- Success criteria
- Open an issue for bugs or feature requests
- Start a discussion for questions or ideas
- Contact maintainers via GitHub
By contributing, you agree that your contributions will be licensed under the same license as the project (MIT License).
Contributors will be recognized in:
- README.md Contributors section
- Release notes
- CHANGELOG.md
Thank you for contributing to LineamentLearning! 🎉