Skip to content

Latest commit

 

History

History
55 lines (46 loc) · 2.93 KB

File metadata and controls

55 lines (46 loc) · 2.93 KB

MEL Codebase Guidelines

Build/Test Commands

  • Install dev dependencies first: uv pip install -e '.[dev]' (required for pytest and other dev tools)
  • Run all tests: ./meta/unit_tests.sh (uses uv run pytest --doctest-modules)
  • Run single test: uv run pytest tests/path/to/test_file.py::test_function_name
  • Run static analysis: ./meta/static_tests.sh
  • Fix formatting: ./meta/autofix.sh

Optional Type Checking

  • Run type checking: ty check (checks entire codebase)
  • Run type checking on specific files: ty check path/to/file.py
  • Run type checking on directory: ty check path/to/directory/
  • Note: Install dev dependencies first with uv pip install -e '.[dev]'

Pre-commit Checklist

  • Fix formatting
  • Fix all tests

Code Style

  • Formatting: ruff format
  • Imports: Standard lib first, third-party second, project modules last (alphabetically sorted in groups)
  • Naming: snake_case for functions/variables, PascalCase for classes, UPPER_CASE for constants
  • Types: Type hints for function parameters and return values where applicable
  • Documentation: Google-style docstrings with Args/Returns sections for complex functions
  • Error handling: Explicit exceptions with descriptive messages, exception chaining with raise X from Y
  • Indentation: 4 spaces
  • Linting: ruff check, vulture

Development Environment

  • Python 3.13+
  • Install uv: pip install uv or curl -LsSf https://astral.sh/uv/install.sh | sh
  • Install dev dependencies: uv venv && uv pip install -e '.[dev]'
  • Always use uv run pytest (not bare pytest) to ensure the project venv is used

Rotomap File System Structure

  • Mole files: {image}.jpg.json - JSON arrays with mole coordinates and metadata
  • Mask files: {image}.jpg.mask.png - Binary masks defining body regions
  • Meta files: {image}.jpg.meta.json - Ellipse geometry data for coordinate transformation
  • Extra stem files: {image}.jpg.{stem}.json - Additional mole data with specific stems

Image Operations

  • Use mel.lib.image.save_image() instead of cv2.imwrite() directly
  • This function respects file permissions and prevents overwriting read-only files
  • For JSON operations, use mel.rotomap.moles.save_json() for consistent formatting

Command Structure

  • Rotomap commands follow pattern: mel rotomap {action} [options] FILES...
  • Add new commands to mel/cmd/rotomap{action}.py with setup_parser() and process_args() functions
  • Register commands in mel/cmd/mel.py by importing module and adding to COMMANDS["rotomap"] dict

Copyright and Generation

  • Copyright and license notices live at the bottom of each file, in the existing license block (above the END-OF-FILE line). Do not add copyright lines near the top of the file.
  • In changed files, update the copyright year range in the bottom license block to include the current year.
  • Ensure "Generated with assistance from Claude Code." appears under the copyright line in the bottom license block.