|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Development Commands |
| 6 | + |
| 7 | +### Running Tests |
| 8 | +```bash |
| 9 | +python -m unittest |
| 10 | +``` |
| 11 | + |
| 12 | +### Linting and Code Quality |
| 13 | +```bash |
| 14 | +# Format code with ruff |
| 15 | +make style |
| 16 | + |
| 17 | +# Check code quality (includes ruff and mypy) |
| 18 | +make check_code_quality |
| 19 | + |
| 20 | +# Individual commands |
| 21 | +ruff format roboflow |
| 22 | +ruff check roboflow --fix |
| 23 | +mypy roboflow |
| 24 | +``` |
| 25 | + |
| 26 | +### Building Documentation |
| 27 | +```bash |
| 28 | +# Install documentation dependencies |
| 29 | +python -m pip install mkdocs mkdocs-material mkdocstrings mkdocstrings[python] |
| 30 | + |
| 31 | +# Serve documentation locally |
| 32 | +mkdocs serve |
| 33 | +``` |
| 34 | + |
| 35 | +### Installing Development Environment |
| 36 | +```bash |
| 37 | +# Create virtual environment |
| 38 | +python3 -m venv env |
| 39 | +source env/bin/activate |
| 40 | + |
| 41 | +# Install in editable mode with dev dependencies |
| 42 | +pip install -e ".[dev]" |
| 43 | + |
| 44 | +# Install pre-commit hooks |
| 45 | +pip install pre-commit |
| 46 | +pre-commit install |
| 47 | +``` |
| 48 | + |
| 49 | +## Architecture Overview |
| 50 | + |
| 51 | +The Roboflow Python SDK follows a hierarchical object model that mirrors the Roboflow platform structure: |
| 52 | + |
| 53 | +### Core Components |
| 54 | + |
| 55 | +1. **Roboflow** (`roboflow/__init__.py`) - Entry point and authentication |
| 56 | + - Handles API key management and workspace initialization |
| 57 | + - Provides `login()` for CLI authentication |
| 58 | + - Creates workspace connections |
| 59 | + |
| 60 | +2. **Workspace** (`roboflow/core/workspace.py`) - Manages Roboflow workspaces |
| 61 | + - Lists and accesses projects |
| 62 | + - Handles dataset uploads and model deployments |
| 63 | + - Manages workspace-level operations |
| 64 | + |
| 65 | +3. **Project** (`roboflow/core/project.py`) - Represents a computer vision project |
| 66 | + - Manages project metadata and versions |
| 67 | + - Handles image/annotation uploads |
| 68 | + - Supports different project types (object-detection, classification, etc.) |
| 69 | + |
| 70 | +4. **Version** (`roboflow/core/version.py`) - Dataset version management |
| 71 | + - Downloads datasets in various formats |
| 72 | + - Deploys models |
| 73 | + - Provides access to trained models for inference |
| 74 | + |
| 75 | +5. **Model Classes** (`roboflow/models/`) - Type-specific inference models |
| 76 | + - `ObjectDetectionModel` - Bounding box predictions |
| 77 | + - `ClassificationModel` - Image classification |
| 78 | + - `InstanceSegmentationModel` - Pixel-level segmentation |
| 79 | + - `SemanticSegmentationModel` - Class-based segmentation |
| 80 | + - `KeypointDetectionModel` - Keypoint predictions |
| 81 | + |
| 82 | +### API Adapters |
| 83 | + |
| 84 | +- **rfapi** (`roboflow/adapters/rfapi.py`) - Low-level API communication |
| 85 | +- **deploymentapi** (`roboflow/adapters/deploymentapi.py`) - Model deployment operations |
| 86 | + |
| 87 | +### CLI Interface |
| 88 | + |
| 89 | +The `roboflow` command line tool (`roboflow/roboflowpy.py`) provides: |
| 90 | +- Authentication: `roboflow login` |
| 91 | +- Dataset operations: `roboflow download`, `roboflow upload`, `roboflow import` |
| 92 | +- Inference: `roboflow infer` |
| 93 | +- Project/workspace management: `roboflow project`, `roboflow workspace` |
| 94 | + |
| 95 | +### Key Design Patterns |
| 96 | + |
| 97 | +1. **Hierarchical Access**: Always access objects through their parent (Workspace → Project → Version → Model) |
| 98 | +2. **API Key Flow**: API key is passed down through the object hierarchy |
| 99 | +3. **Format Flexibility**: Supports multiple dataset formats (YOLO, COCO, Pascal VOC, etc.) |
| 100 | +4. **Batch Operations**: Upload and download operations support concurrent processing |
| 101 | + |
| 102 | +## Project Configuration |
| 103 | + |
| 104 | +- **Python Version**: 3.8+ |
| 105 | +- **Main Dependencies**: See `requirements.txt` |
| 106 | +- **Entry Point**: `roboflow=roboflow.roboflowpy:main` |
| 107 | +- **Code Style**: Enforced by ruff with Google docstring convention |
| 108 | +- **Type Checking**: mypy configured for Python 3.8 |
| 109 | + |
| 110 | +## Important Notes |
| 111 | + |
| 112 | +- API keys are stored in `~/.config/roboflow/config.json` (Unix) or `~/roboflow/config.json` (Windows) |
| 113 | +- The SDK supports both hosted inference (Roboflow platform) and local inference (via Roboflow Inference) |
| 114 | +- Pre-commit hooks automatically run formatting and linting checks |
| 115 | +- Test files intentionally excluded from linting: `tests/manual/debugme.py` |
0 commit comments