-
Notifications
You must be signed in to change notification settings - Fork 780
160 lines (150 loc) · 6.22 KB
/
Copy pathci.yml
File metadata and controls
160 lines (150 loc) · 6.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: "CI"
on:
push:
branches: [main]
paths-ignore:
- "**.md"
- "**.ipynb"
- "**.cff"
- "docs/**"
- "demo/**"
- "context7.json"
- "zensical.toml"
- "zensical.tr.toml"
- "zensical.zh.toml"
pull_request:
branches: [main]
paths-ignore:
- "**.md"
- "**.ipynb"
- "**.cff"
- "docs/**"
- "demo/**"
- "context7.json"
- "zensical.toml"
- "zensical.tr.toml"
- "zensical.zh.toml"
schedule:
- cron: "0 0 * * *" # Runs at 00:00 UTC every day
workflow_dispatch: # allow running sync via github ui button
jobs:
ci:
name: "Tests (OS: ${{ matrix.os }}, Python: ${{ matrix.python-version }})"
if:
github.event_name != 'schedule' && github.event_name !=
'workflow_dispatch'
runs-on: ${{ matrix.os }}
env:
# Cache HuggingFace downloads in the workspace so actions/cache can persist them
HF_HOME: ${{ github.workspace }}/.cache/huggingface
# Give flaky HF Hub downloads more headroom before timing out (default is 10s)
HF_HUB_DOWNLOAD_TIMEOUT: "60"
# The runners have no GPU, so take the CPU wheels rather than detecting
UV_TORCH_BACKEND: cpu
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
include:
- os: macos-latest
python-version: "3.12"
- os: windows-latest
python-version: "3.12"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup uv python package manager
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
prune-cache: false
activate-environment: true
cache-dependency-glob: |
**/pyproject.toml
- name: Cache model weights
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: tests/data/models
key:
${{ runner.os }}-models-${{ hashFiles('sahi/utils/yolov5.py',
'sahi/utils/ultralytics.py', 'sahi/utils/rtdetr.py',
'sahi/utils/torchvision.py') }}
restore-keys: |
${{ runner.os }}-models-
- name: Cache HuggingFace Hub downloads
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ github.workspace }}/.cache/huggingface
key:
${{ runner.os }}-hf-${{ hashFiles('tests/utils/huggingface.py') }}
restore-keys: |
${{ runner.os }}-hf-
- name: Install dependencies
run: uv sync --group dev --extra ci
- name: List installed packages
run: |
echo "=== Installed Python packages ==="
uv pip list
echo ""
echo "=== Python version ==="
python --version
echo ""
echo "=== uv version ==="
uv --version
- name: Test with python ${{ matrix.python-version }}
run: |
# MMDet tests self-skip via pytest.importorskip when mmcv/mmdet are absent.
# Retry transient network failures (e.g. HuggingFace Hub connection/timeout errors)
# instead of failing the whole run. Single line so it works on both bash and Windows PowerShell.
uv run pytest --capture=no -n auto --reruns 3 --reruns-delay 10 --only-rerun "(?i)(connect|connection|timed? *out|timeout|HTTPError|couldn't connect|We couldn't connect|max retries|temporarily unavailable|ConnectionError|ReadTimeout)"
- name: Test SAHI CLI (without MMDet)
run: |
uv run sahi predict --no_sliced_prediction --model_type ultralytics --source tests/data/coco_utils/terrain1.jpg --novisual --model_path tests/data/models/ultralytics/yolo11n.pt --image_size 320
uv run sahi predict --model_type ultralytics --source tests/data/ --novisual --model_path tests/data/models/ultralytics/yolo11n.pt --image_size 320
uv run sahi predict --model_type ultralytics --source tests/data/coco_utils/terrain1.jpg --export_pickle --export_crop --model_path tests/data/models/ultralytics/yolo11n.pt --image_size 320
uv run sahi predict --model_type ultralytics --source tests/data/coco_utils/ --novisual --dataset_json_path tests/data/coco_utils/combined_coco.json --model_path tests/data/models/ultralytics/yolo11n.pt --image_size 320
# coco yolov5
uv run sahi coco yolov5 --image_dir tests/data/coco_utils/ --dataset_json_path tests/data/coco_utils/combined_coco.json --train_split 0.9
# coco evaluate
uv run sahi coco evaluate --dataset_json_path tests/data/coco_evaluate/dataset.json --result_json_path tests/data/coco_evaluate/result.json
# coco analyse
uv run sahi coco analyse --dataset_json_path tests/data/coco_evaluate/dataset.json --result_json_path tests/data/coco_evaluate/result.json --out_dir tests/data/coco_evaluate/
schedule-test:
name:
"Schedule/PyPI check (OS: ${{ matrix.os }}, Python: ${{
matrix.python-version }})"
if:
github.event_name == 'schedule' || github.event_name ==
'workflow_dispatch'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
include:
- os: macos-latest
python-version: "3.12"
- os: windows-latest
python-version: "3.12"
steps:
- name: Setup uv python package manager
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
prune-cache: false
activate-environment: true
- name: List installed packages
run: |
echo "=== Python version ==="
python --version
echo ""
echo "=== uv version ==="
uv --version
- name: Install sahi from PyPI
run: |
uv pip install sahi
uv pip show sahi
uv run python -c "import sahi; print(sahi.__version__)"