flowerfy / DEVELOPMENT.md
Toy
Add modern Python development toolchain with Ruff, MyPy, and pre-commit
25bcd98
|
raw
history blame
3.21 kB

πŸš€ Flowerfy Development Guide

Modern Development Setup (2025)

This project uses modern Python development tools for code quality and consistency.

πŸ› οΈ Development Tools

Ruff - The Modern Python Linter & Formatter

  • Ultra-fast linting and formatting (written in Rust)
  • Replaces multiple tools: flake8, black, isort, pyupgrade
  • Industry standard for Python development in 2025

MyPy - Static Type Checking

  • Gradual typing support
  • Catches type-related bugs early

Pre-commit - Automated Code Quality

  • Runs checks automatically before commits
  • Ensures consistent code quality

πŸ”§ Quick Start

  1. Install development dependencies:

    uv add --dev ruff mypy pre-commit
    
  2. Setup pre-commit hooks:

    uv run pre-commit install
    
  3. Format and lint code:

    # Format all Python files
    uv run ruff format .
    
    # Lint and fix issues  
    uv run ruff check --fix .
    
    # Type checking
    uv run mypy .
    

πŸ“‹ Code Quality Commands

Use the Makefile or direct commands:

# Using Makefile (recommended)
make format          # Format code
make lint           # Lint and fix
make quality        # All checks

# Or direct commands
uv run ruff format .
uv run ruff check --fix .

βš™οΈ Configuration

All tool configurations are in pyproject.toml:

  • Ruff: Modern linting rules, import sorting, code formatting
  • MyPy: Type checking with gradual typing
  • Pre-commit: Automated hooks for code quality

🎯 Code Standards

  • Line length: 88 characters (Black compatibility)
  • Import sorting: Automatic with ruff
  • String quotes: Double quotes preferred
  • Python version: 3.13+ with modern features
  • Type hints: Gradual adoption encouraged

πŸ”„ Workflow

  1. Write code with your favorite editor
  2. Pre-commit hooks run automatically on commit
  3. CI/CD can run the same tools for consistency
  4. Manual checks available via provided scripts

πŸš€ Benefits

  • 10-100x faster than traditional tools (flake8, black)
  • Single tool replaces multiple dependencies
  • Modern Python features and best practices
  • Consistent formatting across the entire codebase
  • Automated quality checks prevent issues

πŸ“š Resources


🌸 Project Architecture

FLUX.1 Image Generation

  • Model: black-forest-labs/FLUX.1-schnell
  • Quality: Superior to SDXL-Turbo
  • Features: Better text rendering, improved accuracy

ConvNeXt Classification

  • Model: facebook/convnext-tiny-224
  • Fallback: openai/clip-vit-base-patch32
  • Performance: Optimized for flower identification

Modular Structure

src/
β”œβ”€β”€ core/          # Configuration and constants
β”œβ”€β”€ services/      # Business logic (models, training)
β”œβ”€β”€ ui/           # Gradio interface components  
β”œβ”€β”€ utils/        # Utility functions
└── training/     # Training implementations

Happy coding! 🎨