Thank you for your interest in contributing to AlphaPy Pro! This guide will help you get started with development.
- Python 3.10+ (3.10, 3.11, or 3.12)
- Git
- pip
-
Fork and clone the repository:
git clone https://github.com/your-username/alphapy-pro.git cd alphapy-pro -
Install in development mode:
# Install with all development dependencies pip install -e .[dev] -
Install pre-commit hooks:
pre-commit install
-
Set up configuration:
cd config cp alphapy.yml.template alphapy.yml cp sources.yml.template sources.yml # Edit these files with your local settings
-
Verify installation:
python -c "import alphapy; print(alphapy.__version__)" pytest tests/test_version.py -v
For the complete Git workflow guide, see docs/git-workflow.md.
- Create an issue describing your feature or bug fix
- Create a branch from
develop:git checkout develop git pull origin develop git checkout -b feature/issue-123-description
- Make your changes following the code quality standards below
- Create a Pull Request to merge back to
develop - Address review feedback and get approval
- Squash and merge when ready
This project maintains high code quality standards using automated tools:
# Format all code with black
black .
# Sort imports with isort
isort .# Check code style with flake8
flake8 .
# Run type checking (optional but recommended)
mypy alphapy/All code quality checks run automatically before commits:
# Run all pre-commit hooks manually
pre-commit run --all-files# Run all tests
pytest
# Run tests with coverage
pytest --cov=alphapy --cov-report=html
# Run specific test files
pytest tests/test_utilities.py -v
# Run tests matching a pattern
pytest -k "test_version" -v- Place tests in the
tests/directory - Follow the naming convention:
test_*.py - Use descriptive test names and docstrings
- Test both success and failure cases
- Use pytest fixtures for common setup
Example test structure:
"""Test description module."""
import pytest
from alphapy.utilities import some_function
class TestSomeFunction:
"""Test suite for some_function."""
def test_some_function_with_valid_input(self):
"""Test some_function with valid input."""
result = some_function("valid_input")
assert result == "expected_output"
def test_some_function_with_invalid_input(self):
"""Test some_function raises error with invalid input."""
with pytest.raises(ValueError):
some_function("invalid_input")-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes:
- Follow the existing code style
- Add tests for new functionality
- Update documentation if needed
-
Run tests and quality checks:
# Run tests pytest # Run code quality checks black . isort . flake8 . # Or let pre-commit handle it pre-commit run --all-files
-
Commit your changes:
git add . git commit -m "Add: brief description of your changes"
-
Push and create a pull request:
git push origin feature/your-feature-name
Use clear, descriptive commit messages:
- Add: New features or functionality
- Fix: Bug fixes
- Update: Improvements to existing features
- Remove: Deletion of code or features
- Docs: Documentation changes
- Test: Test additions or modifications
Examples:
Add: version management system with semantic versioning
Fix: handle edge case in valid_date function
Update: modernize packaging with pyproject.toml
Test: add comprehensive tests for utilities module
- Follow PEP 8 (enforced by flake8)
- Use black for code formatting (line length: 88 characters)
- Use isort for import sorting
- Add type hints where possible
- Write descriptive docstrings for public functions and classes
- Use Google-style docstrings
- Include type information in docstrings
- Provide examples for complex functions
- Keep documentation up to date with code changes
Example docstring:
def process_data(data: pd.DataFrame, target: str) -> tuple[pd.DataFrame, pd.Series]:
"""Process input data for machine learning.
Args:
data: Input DataFrame containing features and target
target: Name of the target column
Returns:
A tuple containing (features, target) where features is a DataFrame
and target is a Series.
Raises:
ValueError: If target column is not found in data.
Example:
>>> df = pd.DataFrame({'x': [1, 2], 'y': [3, 4]})
>>> features, target = process_data(df, 'y')
>>> len(features.columns)
1
"""Understanding the project structure helps with navigation:
AlphaPy/
├── alphapy/ # Main package
│ ├── __init__.py # Package initialization with version
│ ├── alphapy_main.py # Main pipeline entry point
│ ├── mflow_main.py # Market flow pipeline
│ ├── model.py # Model management
│ ├── features.py # Feature engineering
│ ├── utilities.py # Utility functions
│ └── ...
├── tests/ # Test suite
│ ├── __init__.py
│ ├── conftest.py # Pytest configuration and fixtures
│ ├── test_version.py # Version tests
│ ├── test_utilities.py # Utility function tests
│ └── ...
├── config/ # Configuration files
│ ├── alphapy.yml.template # Main configuration template
│ ├── sources.yml.template # API keys template
│ └── ...
├── docs/ # Documentation
├── scripts/ # Utility scripts
│ └── bump_version.py # Version management
├── .github/workflows/ # CI/CD pipelines
├── pyproject.toml # Modern Python packaging configuration
├── setup.py # Legacy setup (maintained for compatibility)
└── README.md # Project overview
This project uses semantic versioning (MAJOR.MINOR.PATCH):
- MAJOR: Incompatible API changes
- MINOR: Backward-compatible functionality additions
- PATCH: Backward-compatible bug fixes
-
Update version:
python scripts/bump_version.py [major|minor|patch]
-
Update CHANGELOG.md with release notes
-
Commit and tag:
git commit -am "Bump version to X.Y.Z" git tag -a vX.Y.Z -m "Release version X.Y.Z"
-
Push changes:
git push origin main --tags
-
GitHub Actions will automatically publish to PyPI
- Issues: Open an issue on GitHub for bug reports or feature requests
- Discussions: Use GitHub Discussions for questions and general discussion
- Documentation: Check the
docs/directory for comprehensive guides - Code Review: Pull requests receive thorough code review and feedback
- Never commit API keys or sensitive information
- Use the template files for configuration
- Report security vulnerabilities privately through GitHub Security Advisories
Thank you for contributing to AlphaPy! 🚀