Contributing to openretina
We welcome contributions to openretina
! This guide will help you get started with contributing to the project, whether you're fixing bugs, adding features, improving documentation, or adding new models and datasets.
How to Contribute
Types of Contributions
We appreciate the following types of contributions:
- Bug reports: Report issues you encounter
- Feature requests: Suggest new features or improvements
- Documentation improvements: Fix typos, add examples, or improve explanations
- New models: Implement new neural network architectures
- New datasets: Add support for additional retinal datasets
- Code improvements: Optimize performance, improve code quality
- Tests: Add or improve test coverage
Getting Started
- Fork the repository on GitHub
- Clone your fork to your local machine:
git clone git@github.com:yourusername/open-retina.git cd open-retina
- Create a new branch for your contribution:
git checkout -b feature/your-feature-name
Development Environment Setup
- Install the package in development mode:
This installs
pip install -e ".[dev]"
openretina
with all development dependencies including: ruff
for linting and formattingmypy
for type checkingpytest
for testing-
jupyterlab
for notebook development -
For model development, also install:
pip install -e ".[devmodels]"
Development Workflow
Before submitting any changes, please follow this workflow:
-
Make your changes following our code style guidelines
-
Run the development checks:
# Fix code formatting make fix-formatting # Run all tests (type checks, code style, unit tests) make test-all
-
Test your changes thoroughly:
- Ensure existing tests pass
- Add new tests for new functionality, if possible
-
Test with different datasets if applicable
-
Update documentation if needed:
- Update docstrings for new functions/classes
- Update user-facing documentation
- Add examples for new features
Submitting Changes
-
Commit your changes with descriptive commit messages:
git add . git commit -m "Add feature: brief description of what you added"
-
Push to your fork:
git push origin feature/your-feature-name
-
Create a Pull Request on GitHub with:
- A clear title and description
- Reference to any related issues
- List of changes made
- Any breaking changes highlighted
Guidelines for Specific Contributions
Adding New Models
When contributing new model architectures:
- Follow the existing structure:
- Implement models in
openretina/models/
- Use PyTorch Lightning for training logic
-
Follow naming conventions for consistency
-
Include comprehensive documentation, if you can:
- Docstrings for all classes and methods
- Example usage in documentation
-
Reference to original paper where the method is coming from, if applicable
-
Add tests:
- Unit tests for model components
- Integration tests for training/inference
Adding New Datasets
When adding support for new datasets:
- Implement in
openretina/data_io/
: - Create a new subdirectory for your dataset
- Implement data loaders following the base classes
-
Include stimulus and response handling
-
Follow data conventions:
- Use consistent data formats across datasets
-
Include proper metadata handling
-
Provide examples:
- Add example usage in documentation
- Include data format specifications
- Provide download instructions if data is publicly available, or add it to our HuggingFace
Documentation Guidelines
When contributing to documentation:
- Use clear, concise language
- Include code examples where applicable
- Follow the existing documentation structure
- Update the navigation in
mkdocs.yml
if adding new pages - Test documentation builds locally before submitting
For detailed documentation standards, see our documentation writing guidelines below.
Testing
Running Tests
# Run all tests
make test-all
# Run specific test categories
make test-types # Type checking with mypy
make test-codestyle # Code style with ruff
make test-formatting # Code formatting with ruff
make test-unittests # Unit tests with pytest
# Test notebooks
make test-notebooks
Writing Tests
- Write unit tests for all new functions and classes
- Use
pytest
for test framework - Place tests in the
tests/
directory - Follow existing test structure and naming conventions
- Include both positive and negative test cases
- Test edge cases and error conditions
Documentation Writing Guidelines
When writing or updating documentation:
General Principles
- Be accurate: Always reflect the actual code behavior
- Be complete: Provide all necessary information for users
- Be clear: Use simple, direct language
- Be consistent: Follow established patterns and terminology
- Include examples: Show don't just tell
Docstring Standards
Use Google-style docstrings for all public functions and classes:
def example_function(param1: int, param2: str = "default") -> bool:
"""Brief description of what the function does.
Longer description if needed. Explain the purpose, behavior,
and any important details.
Args:
param1: Description of the first parameter.
param2: Description of the second parameter with default value.
Returns:
Description of what the function returns.
Raises:
ValueError: When and why this exception is raised.
Example:
>>> result = example_function(42, "test")
>>> print(result)
True
"""
API Documentation
For API reference pages:
- Use mkdocstrings for automatic documentation generation
- Include module-level documentation explaining the purpose
- Group related functions/classes logically
- Provide usage examples for complex APIs
Tutorial Documentation
For tutorials and guides:
- Start with clear objectives: What will the user learn?
- Provide complete, runnable examples
- Explain each step and why it's necessary
- Include expected outputs where helpful
- Address common issues and troubleshooting
Code Examples
- Always test code examples to ensure they work
- Use realistic data in examples when possible
- Show imports and setup required
- Keep examples focused on the specific concept being demonstrated
Code Review Process
- All contributions require review before merging
- Address all feedback before expecting merge
- Maintain backwards compatibility unless explicitly breaking changes
- Update version numbers appropriately for significant changes
Getting Help
If you need help with contributing:
- Check existing documentation first
- Open an issue on GitHub for bugs or feature requests
- Join discussions in existing issues and pull requests
- Contact maintainers if you have questions about the contribution process
Recognition
Contributors are recognized in:
- The project's contributor list, and Zenodo's software reference.
- Release notes for significant contributions
- Academic publications when appropriate
Thank you for contributing to openretina
!