Skip to content

Commit 914266f

Browse files
authored
Merge branch 'main' into feat/change-default-urls-to-serverless
2 parents 9d405a4 + 998d94b commit 914266f

File tree

54 files changed

+5997
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+5997
-198
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"dockerComposeFile": "./docker-compose.yaml",
44
"service": "devcontainer-roboflow-python",
55
"workspaceFolder": "/roboflow-python",
6+
"initializeCommand": "sh -lc 'mkdir -p .devcontainer/certs; if command -v mkcert >/dev/null 2>&1; then CAROOT=\"$(mkcert -CAROOT)\"; if [ -f \"$CAROOT/rootCA.pem\" ]; then cp \"$CAROOT/rootCA.pem\" .devcontainer/certs/mkcert-rootCA.crt; else echo \"[devcontainer] mkcert CA not found at $CAROOT/rootCA.pem; skipping\"; fi; else echo \"[devcontainer] mkcert not installed; skipping CA copy\"; fi'",
67
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
78
"customizations": {
89
"vscode": {

.devcontainer/docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ services:
55
context: ..
66
dockerfile: Dockerfile.dev
77
image: devcontainer-roboflow-python
8+
extra_hosts:
9+
- "localhost.roboflow.one:host-gateway"
810
volumes:
911
- ..:/roboflow-python
1012
command: sleep infinity

.github/workflows/test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: ubuntu-latest
1211
strategy:
1312
matrix:
14-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
13+
os: ["ubuntu-latest", "windows-latest"]
14+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
15+
runs-on: ${{ matrix.os }}
16+
env:
17+
PYTHONUTF8: 1
1518

1619
steps:
1720
- name: 🛎️ Checkout

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ __pycache__/
88
.idea
99
# C extensions
1010
*.so
11+
.devcontainer/certs/
1112

1213
# Distribution / packaging
1314
.Python
@@ -154,3 +155,4 @@ tests/manual/data
154155
README.roboflow.txt
155156
*.zip
156157
.DS_Store
158+
.claude

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ci:
66

77
repos:
88
- repo: https://github.com/pre-commit/pre-commit-hooks
9-
rev: v4.6.0
9+
rev: v5.0.0
1010
hooks:
1111
- id: check-added-large-files
1212
- id: check-case-conflict
@@ -24,14 +24,14 @@ repos:
2424
- id: trailing-whitespace
2525

2626
- repo: https://github.com/PyCQA/bandit
27-
rev: 1.7.9
27+
rev: 1.8.3
2828
hooks:
2929
- id: bandit
3030
args: ["-c", "pyproject.toml"]
3131
additional_dependencies: ["bandit[toml]"]
3232

3333
- repo: https://github.com/astral-sh/ruff-pre-commit
34-
rev: v0.6.4
34+
rev: v0.11.12
3535
hooks:
3636
- id: ruff-format
3737
- id: ruff

CLAUDE.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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`

Dockerfile.dev

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1-
FROM python:3.8
2-
RUN apt-get update && apt-get install -y make libgl1-mesa-glx && rm -rf /var/lib/apt/lists/*
1+
FROM python:3.10
2+
RUN apt-get update && apt-get install -y make curl libgl1-mesa-glx ca-certificates && rm -rf /var/lib/apt/lists/*
3+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
4+
ENV PATH="/root/.local/bin:${PATH}"
5+
6+
37
WORKDIR /roboflow-python
48
COPY .devcontainer/bashrc_ext /root/bashrc_ext
59
RUN echo "source /root/bashrc_ext" >> ~/.bashrc
6-
COPY ./setup.py ./pyproject.toml ./README.md ./requirements.txt ./
10+
11+
# Trust any custom CAs provided in build context (e.g., mkcert)
12+
COPY .devcontainer/certs/ /usr/local/share/ca-certificates/
13+
RUN update-ca-certificates || true
14+
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
15+
ENV REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
16+
17+
18+
COPY ./requirements.txt ./
19+
RUN uv pip install --system -r requirements.txt
20+
21+
COPY ./setup.py ./pyproject.toml ./README.md ./
722
COPY roboflow/__init__.py ./roboflow/__init__.py
8-
RUN pip install -e ".[dev]"
23+
RUN uv pip install --system -e ".[dev]"
24+
925
COPY . .

pyproject.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ target = ["test", "roboflow"]
77
tests = ["B201", "B301"]
88

99
[tool.ruff]
10-
target-version = "py38"
10+
target-version = "py39"
1111
line-length = 120
1212

1313
[tool.ruff.lint]
@@ -32,6 +32,7 @@ ignore = [
3232
"N",
3333
"PERF",
3434
"PIE",
35+
"PLC0415", # `import` should be at the top-level of a file
3536
"PLR",
3637
"PLW",
3738
"PT",
@@ -44,6 +45,7 @@ ignore = [
4445
"T",
4546
"TD",
4647
"TRY",
48+
"UP",
4749
]
4850

4951
# Exclude a variety of commonly ignored directories.
@@ -99,7 +101,7 @@ banned-module-level-imports = [
99101
]
100102

101103
[tool.mypy]
102-
python_version = "3.8"
104+
python_version = "3.9"
103105
exclude = ["^build/"]
104106

105107
[[tool.mypy.overrides]]
@@ -110,9 +112,6 @@ module = [
110112
"IPython.display.*",
111113
# ipywidgets is an optional dependency
112114
"ipywidgets.*",
113-
# matplotlib typing is not available for Python 3.8
114-
# remove this when we stop supporting Python 3.8
115-
"matplotlib.*",
116115
"requests_toolbelt.*",
117116
"torch.*",
118117
"ultralytics.*",

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ matplotlib
66
numpy>=1.18.5
77
opencv-python-headless==4.10.0.84
88
Pillow>=7.1.2
9-
pillow-heif>=0.18.0
9+
# https://github.com/roboflow/roboflow-python/issues/390
10+
pi-heif<2
11+
pillow-avif-plugin<2
1012
python-dateutil
1113
python-dotenv
1214
requests

roboflow/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from roboflow.models import CLIPModel, GazeModel # noqa: F401
1616
from roboflow.util.general import write_line
1717

18-
__version__ = "1.1.61"
18+
__version__ = "1.2.9"
1919

2020

2121
def check_key(api_key, model, notebook, num_retries=0):

0 commit comments

Comments
 (0)