|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This guide governs the entire repository. If a subfolder provides its own |
| 4 | +`AGENTS.md`, instructions there override this file for that subtree. |
| 5 | + |
| 6 | +## Overview |
| 7 | +Roboflow Inference is a set of Python packages that run computer vision models |
| 8 | +locally and expose them via an HTTP API and command line interface. The repo |
| 9 | +contains the core library, CLI, SDK, and Dockerfiles for building CPU or GPU |
| 10 | +images. Target Python version is 3.10 (minimum 3.8). |
| 11 | + |
| 12 | +## Project Structure |
| 13 | +- `inference/` – core library with model loading and streaming utilities. |
| 14 | +- `inference_cli/` – command line tools and server entry points. |
| 15 | +- `inference_sdk/` – Python SDK for interacting with a running inference server. |
| 16 | +- `docker/` – Dockerfiles used to build CPU and GPU images. |
| 17 | +- `tests/` – unit and integration tests for all packages. |
| 18 | +- `docs/` – mkdocs documentation source. |
| 19 | + |
| 20 | +## Setup / Environment |
| 21 | +Create a Python environment and install the repo in editable mode: |
| 22 | + |
| 23 | +```bash |
| 24 | +conda create -n inference-development python=3.10 |
| 25 | +conda activate inference-development |
| 26 | +pip install -e . |
| 27 | +# optional models |
| 28 | +pip install -e ".[sam]" |
| 29 | +``` |
| 30 | + |
| 31 | +Important environment variables (see `inference/core/env.py` for all): |
| 32 | +| Variable | Default | Purpose | |
| 33 | +|--------------------|--------------------|-----------------------------------| |
| 34 | +| `PROJECT` | `roboflow-platform`| Selects prod or staging behavior | |
| 35 | +| `ROBOFLOW_API_KEY` | `""` | Enables authenticated requests | |
| 36 | +| `MODEL_CACHE_DIR` | `/tmp/cache` | Stores downloaded models | |
| 37 | +| `PORT` | `9001` | API port when running locally | |
| 38 | +| `NUM_WORKERS` | `1` | Number of server worker threads | |
| 39 | + |
| 40 | +Defaults above mirror the Dockerfiles in `docker/dockerfiles/`. |
| 41 | + |
| 42 | +## Build & Running |
| 43 | +Build a development image and start the server from the repository root: |
| 44 | + |
| 45 | +```bash |
| 46 | +docker build -t roboflow/roboflow-inference-server-cpu:dev \ |
| 47 | + -f docker/dockerfiles/Dockerfile.onnx.cpu.dev . |
| 48 | +docker run -p 9001:9001 \ |
| 49 | + -v ./inference:/app/inference \ |
| 50 | + roboflow/roboflow-inference-server-cpu:dev |
| 51 | +``` |
| 52 | + |
| 53 | +## Testing |
| 54 | +Unit tests live in package specific folders. Run them individually with: |
| 55 | + |
| 56 | +```bash |
| 57 | +pytest tests/inference/unit_tests/ |
| 58 | +pytest tests/inference_cli/unit_tests/ |
| 59 | +pytest tests/inference_sdk/unit_tests/ |
| 60 | +pytest tests/workflows/unit_tests/ |
| 61 | +``` |
| 62 | + |
| 63 | +To run the entire suite while skipping slow tests: |
| 64 | + |
| 65 | +```bash |
| 66 | +pytest -m "not slow" tests/ |
| 67 | +``` |
| 68 | + |
| 69 | +## Code Style |
| 70 | +Format code with: |
| 71 | + |
| 72 | +```bash |
| 73 | +make style |
| 74 | +``` |
| 75 | + |
| 76 | +Check linting and formatting with: |
| 77 | + |
| 78 | +```bash |
| 79 | +make check_code_quality |
| 80 | +``` |
| 81 | + |
| 82 | +The repository follows PEP 8 and uses Black (88 characters), isort and flake8. |
| 83 | + |
| 84 | +## Contribution / PR Guidelines |
| 85 | +- Ensure all relevant tests pass before opening a pull request. |
| 86 | +- Keep commit messages concise and in the present tense, e.g. "Add model loader". |
| 87 | +- PR descriptions should explain what changed and why, list test commands run, |
| 88 | + and follow the templates in `.github`. |
| 89 | +- Update documentation when applicable. |
0 commit comments