We welcome contributions to CellMap-Data! This guide will help you get started with contributing to the project.
- Getting Started
- Development Setup
- Code Style and Standards
- Testing Requirements
- Documentation Expectations
- Pull Request Process
- Issue Guidelines
- Development Workflow
- Release Process
- Python 3.11 or higher
- Git
- Basic understanding of PyTorch and biological imaging data
-
Fork the repository on GitHub
-
Clone your fork locally:
git clone https://github.com/your-username/cellmap-data.git cd cellmap-data -
Add the upstream remote:
git remote add upstream https://github.com/janelia-cellmap/cellmap-data.git
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install development dependencies:
pip install -e .[dev]
-
Install pre-commit hooks:
pre-commit install
cellmap-data/
├── src/cellmap_data/ # Main package source
│ ├── transforms/ # Data transformation modules
│ ├── utils/ # Utility functions
│ ├── validation/ # Data validation
│ └── device/ # Device management
├── tests/ # Test suite
├── docs/ # Documentation
├── .github/ # GitHub workflows and templates
└── pyproject.toml # Project configuration
We use several tools to maintain code quality:
- Black: Automatic Python code formatting
- Ruff: Fast Python linter for code quality
Run formatting tools:
black src tests
ruff check src tests --fix- Follow PEP 8 Python style guidelines
- Use type hints for all function parameters and return values
- Write clear, descriptive variable and function names
- Keep functions focused and reasonably sized (< 50 lines when possible)
- Use docstrings for all public functions, classes, and modules
We use NumPy-style docstrings:
def process_data(data: np.ndarray, scale: float = 1.0) -> np.ndarray:
"""Process input data with optional scaling.
Parameters
----------
data : np.ndarray
Input array to process.
scale : float, optional
Scaling factor to apply, by default 1.0.
Returns
-------
np.ndarray
Processed data array.
Raises
------
ValueError
If data is empty or scale is negative.
"""
if data.size == 0:
raise ValueError("Data array cannot be empty")
return data * scale- Tests are located in the
tests/directory - Test files should be named
test_*.py - Use descriptive test function names:
test_feature_under_specific_condition
- Unit Tests: Test individual functions and methods
- Integration Tests: Test component interactions
- Performance Tests: Verify performance optimizations work
- Coverage: Aim for >90% test coverage
# Run all tests
pytest
# Run with coverage
pytest --cov=cellmap_data --cov-report=html
# Run specific test file
pytest tests/test_dataset.py
# Run tests matching pattern
pytest -k "transform"- Each test should be independent and idempotent
- Use fixtures for common test setup
- Mock external dependencies (file systems, networks)
- Include edge cases and error conditions
- Test performance-critical code paths
Example test structure:
import pytest
from cellmap_data import CellMapDataset
class TestCellMapDataset:
def test_dataset_creation_success(self):
"""Test successful dataset creation with valid parameters."""
# Test implementation
def test_dataset_creation_invalid_path(self):
"""Test dataset creation fails with invalid path."""
with pytest.raises(FileNotFoundError):
# Test implementation- All public APIs must have comprehensive docstrings
- Include parameter types, return types, and descriptions
- Document exceptions that may be raised
- Provide usage examples for complex functions
- Update README.md for new features
- Add examples to demonstrate usage
- Update API documentation in
docs/ - Include performance considerations where relevant
cd docs
make html-
Sync with upstream:
git fetch upstream git checkout main git merge upstream/main
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes:
- Follow code style guidelines
- Add/update tests
- Update documentation
-
Run quality checks:
# Format code black src tests ruff check src tests --fix # Run tests pytest --cov=cellmap_data # Build docs cd docs && make html
-
Commit Guidelines:
- Use clear, descriptive commit messages
- Consider using conventional commits:
feat:,fix:,docs:, etc. - Keep commits focused on single changes
-
Push and Create PR:
git push origin feature/your-feature-name
-
PR Description:
- Clearly describe what the PR does
- Reference related issues
- Include testing notes
- Add screenshots for UI changes
## Description
Brief description of changes
## Related Issues
Fixes #123
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Tests added/updated
- [ ] All tests pass
- [ ] Manual testing completed
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] No breaking changes (or clearly documented)Include:
- Python version
- CellMap-Data version
- Operating system
- Minimal code example
- Error messages/stack traces
- Expected vs actual behavior
Include:
- Clear description of the feature
- Use cases and motivation
- Proposed API (if applicable)
- Willingness to implement
bug: Something isn't workingenhancement: New feature or improvementdocumentation: Documentation updatesgood first issue: Good for newcomershelp wanted: Community help needed
main: Stable release branchdevelop: Integration branch for featuresfeature/*: Feature development brancheshotfix/*: Critical bug fixes
- Create feature branch from
main - Develop and test locally
- Submit PR to
main - Code review and CI checks
- Merge after approval
- Profile performance-critical code
- Consider memory usage for large datasets
- Test with realistic data sizes
- Document performance characteristics
Releases are automated through GitHub Actions:
- Version Tagging: Automatic date-based versioning on main branch
- PyPI Publishing: Automatic publication to PyPI
- Release Notes: Auto-generated from commit messages
# Update version
hatch version patch # or minor, major
# Build distribution
hatch build
# Upload to PyPI
twine upload dist/*- Be respectful and inclusive
- Focus on constructive feedback
- Help newcomers learn and contribute
- Maintain professionalism in all interactions
Contributors are recognized in:
- Release notes
- Repository contributors list
- Documentation acknowledgments
If you have questions about contributing, please:
- Check existing documentation and issues
- Start a discussion on GitHub
- Reach out to maintainers
Thank you for contributing to CellMap-Data! 🎉