Developer’s Guide
Welcome to the Granny Developer’s Guide! This guide is designed for Python developers who want to extend Granny by creating new analysis modules or user interfaces.
Overview
Granny follows a Model-View-Controller (MVC) architectural pattern, making it highly extensible through a pluggable module system. The framework provides:
Analysis modules - Pluggable rating algorithms for different fruit quality assessments
Interface modules - Multiple ways for users to interact with Granny (CLI, GUI, mobile)
Value system - Type-safe parameter handling with automatic CLI argument generation
Scheduler - Dependency management for chaining analyses together
Image I/O - Consistent handling of images and metadata
Key Extension Points
There are two primary ways to extend Granny:
Adding New Analysis Modules
Create new fruit quality assessment algorithms by inheriting from the
Analysisbase class. Your analysis will automatically integrate with all Granny interfaces and benefit from the parameter system, metadata tracking, and result storage.Examples: StarchArea, BlushColor, PeelColor, SuperficialScald, Segmentation
Adding New Interfaces
Create new ways for users to interact with Granny by inheriting from the
GrannyUIbase class. Your interface can leverage any existing analysis module and will automatically receive their parameters.Examples: GrannyCLI (command-line), GrannyPyQt (desktop GUI), Mobile interface (future)
Documentation Structure
Getting Started
For adding a new analysis module:
Read Adding a New Analysis Module for step-by-step instructions
Review Complete Example Analysis for a complete working example
Refer to API Reference for detailed API documentation
For adding a new interface:
Read Adding a New Interface for step-by-step instructions
Study
Granny/Interfaces/UI/GrannyCLI.pyas a reference implementationRefer to API Reference for detailed API documentation
Development Prerequisites
Python >= 3.9
Familiarity with object-oriented programming
Understanding of abstract base classes
Experience with NumPy and OpenCV (for analysis modules)
Knowledge of argparse or PyQt (for interface modules)
Installation for Development
Clone the repository and install in editable mode:
git clone https://github.com/SystemsGenetics/granny.git
cd granny
pip install -e .
This allows you to modify the code and see changes immediately without reinstalling.
Testing Your Extensions
Granny uses pytest for testing. After adding your module:
Create test files in
tests/matching your module structureRun tests:
python -m pytestTest specific modules:
python -m pytest tests/test_Analyses/test_YourAnalysis.py
Contributing
If you create a useful analysis module or interface, consider contributing it back to the project:
Ensure your code follows the existing patterns
Add comprehensive docstrings
Include tests for your module
Update documentation as needed
Submit a pull request on GitHub
Support
For questions about extending Granny:
Review the existing analysis modules in
Granny/Analyses/Check the API reference documentation
Open an issue on GitHub: https://github.com/SystemsGenetics/granny/issues