-
Notifications
You must be signed in to change notification settings - Fork 3.8k
453 lines (374 loc) · 15.8 KB
/
checks.yml
File metadata and controls
453 lines (374 loc) · 15.8 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
on:
workflow_call:
inputs:
push_coverage:
type: boolean
description: "If true, the coverage results are pushed to codecov.io."
default: true
secrets:
CODECOV_TOKEN:
required: false
env:
HF_HUB_DOWNLOAD_TIMEOUT: "90"
HF_HUB_ETAG_TIMEOUT: "90"
UV_FROZEN: "1"
PYTEST_ML: |-
tests/test_e2e_conversion.py
tests/test_e2e_ocr_conversion.py
tests/test_backend_webp.py
tests/test_asr_pipeline.py
tests/test_threaded_pipeline.py
PYTEST_TO_SKIP: |-
EXAMPLES_TO_SKIP: '^(batch_convert|compare_vlm_models|minimal|minimal_vlm_pipeline|minimal_asr_pipeline|export_multimodal|custom_convert|develop_picture_enrichment|rapidocr_with_custom_models|suryaocr_with_custom_models|offline_convert|pictures_description|pictures_description_api|vlm_pipeline_api_model|granitedocling_repetition_stopping|mlx_whisper_example|gpu_standard_pipeline|gpu_vlm_pipeline|demo_layout_vlm|post_process_ocr_with_vlm)\.py$|xbrl_conversion\.ipynb$'
jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v6
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
- name: Set pre-commit cache key
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> "$GITHUB_ENV"
- name: Cache pre-commit environments
uses: actions/cache@v5
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit|${{ env.PY }}|
- name: Install Python Dependencies
run: uv sync --frozen --all-extras --no-extra nemotron-ocr
- name: Check style
run: |
echo "--- Running pre-commit style checks ---"
uv run pre-commit run --all-files
run-tests-1:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- name: Grant permissions to APT cache directory # allows restore
run: sudo chown -R $USER:$USER /var/cache/apt/archives
- name: Cache APT packages
id: apt-cache
uses: actions/cache@v5
with:
path: /var/cache/apt/archives
key: apt-packages-${{ runner.os }}-${{ hashFiles('.github/workflows/checks.yml') }}
restore-keys: |
apt-packages-${{ runner.os }}-
- name: Install System Dependencies
run: |
sudo apt-get -qq update
sudo apt-get -qq install -y ffmpeg tesseract-ocr tesseract-ocr-eng tesseract-ocr-fra tesseract-ocr-deu tesseract-ocr-spa tesseract-ocr-script-latn libleptonica-dev libtesseract-dev libreoffice pkg-config
- name: Set TESSDATA_PREFIX
run: echo "TESSDATA_PREFIX=$(dpkg -L tesseract-ocr-eng | grep tessdata$)" >> "$GITHUB_ENV"
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: uv sync --frozen --all-extras --no-extra nemotron-ocr
- name: Cache Models
uses: actions/cache@v5
with:
path: |
~/.cache/huggingface
~/.cache/modelscope
~/.EasyOCR/
key: models-cache
- name: Pre-download Models
run: uv run python -c "import easyocr; reader = easyocr.Reader(['en', 'fr', 'de', 'es'])"
- name: Run tests for GROUP1
run: |
echo "--- Running tests ---"
GROUP1=$(echo "$PYTEST_ML" | sed -e 's/^/--ignore=/' | tr '\n' ' ')
echo "Running tests for GROUP1"
uv run pytest -v --durations=0 --cov=docling --cov-report=xml --cov-context=test $GROUP1
- name: Upload coverage to Codecov
if: inputs.push_coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: run-tests-1
- name: Grant permissions to APT cache directory # allows backup
run: sudo chown -R $USER:$USER /var/cache/apt/archives
run-tests-2:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- name: Grant permissions to APT cache directory # allows restore
run: sudo chown -R $USER:$USER /var/cache/apt/archives
- name: Cache APT packages
id: apt-cache
uses: actions/cache@v5
with:
path: /var/cache/apt/archives
key: apt-packages-${{ runner.os }}-${{ hashFiles('.github/workflows/checks.yml') }}
restore-keys: |
apt-packages-${{ runner.os }}-
- name: Install System Dependencies
run: |
sudo apt-get -qq update
sudo apt-get -qq install -y ffmpeg tesseract-ocr tesseract-ocr-eng tesseract-ocr-fra tesseract-ocr-deu tesseract-ocr-spa tesseract-ocr-script-latn libleptonica-dev libtesseract-dev libreoffice pkg-config
- name: Set TESSDATA_PREFIX
run: echo "TESSDATA_PREFIX=$(dpkg -L tesseract-ocr-eng | grep tessdata$)" >> "$GITHUB_ENV"
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: uv sync --frozen --all-extras --no-extra nemotron-ocr
- name: Cache Models
uses: actions/cache@v5
with:
path: |
~/.cache/huggingface
~/.cache/modelscope
~/.EasyOCR/
key: models-cache
- name: Pre-download Models
run: uv run python -c "import easyocr; reader = easyocr.Reader(['en', 'fr', 'de', 'es'])"
- name: Run tests for GROUP2
run: |
echo "--- Running tests ---"
GROUP2=$(echo "$PYTEST_ML" | tr '\n' ' ')
echo "Running tests for GROUP2"
DESELECT_OPT=""
if [ -n "$PYTEST_TO_SKIP" ]; then
DESELECT_OPT="--deselect $PYTEST_TO_SKIP"
fi
echo "Running tests for GROUP2"
uv run pytest -v --durations=0 --cov=docling --cov-report=xml --cov-context=test $GROUP2 $DESELECT_OPT
- name: Upload coverage to Codecov
if: inputs.push_coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: run-tests-2
- name: Grant permissions to APT cache directory # allows backup
run: sudo chown -R $USER:$USER /var/cache/apt/archives
run-examples:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- name: Grant permissions to APT cache directory # allows restore
run: sudo chown -R $USER:$USER /var/cache/apt/archives
- name: Cache APT packages
id: apt-cache
uses: actions/cache@v5
with:
path: /var/cache/apt/archives
key: apt-packages-${{ runner.os }}-${{ hashFiles('.github/workflows/checks.yml') }}
restore-keys: |
apt-packages-${{ runner.os }}-
- name: Install System Dependencies
run: |
sudo apt-get -qq update
sudo apt-get -qq install -y ffmpeg tesseract-ocr tesseract-ocr-eng tesseract-ocr-fra tesseract-ocr-deu tesseract-ocr-spa tesseract-ocr-script-latn libleptonica-dev libtesseract-dev libreoffice pkg-config
- name: Set TESSDATA_PREFIX
run: echo "TESSDATA_PREFIX=$(dpkg -L tesseract-ocr-eng | grep tessdata$)" >> "$GITHUB_ENV"
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
run: uv sync --frozen --all-extras --no-extra nemotron-ocr
- name: Cache Models
uses: actions/cache@v5
with:
path: |
~/.cache/huggingface
~/.cache/modelscope
~/.EasyOCR/
key: models-cache
- name: Free up disk space
run: |
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo apt-get clean
df -h
- name: Run examples
run: |
echo "--- Creating output directory ---"
mkdir -p scratch
echo "--- Running examples ---"
summary_file="runtime_summary.log"
echo "--- Example Runtimes ---" > "$summary_file"
for file in docs/examples/*.py; do
if [[ "$(basename "$file")" =~ ${EXAMPLES_TO_SKIP} ]]; then
echo "Skipping example: $(basename "$file")"
else
echo "--- Running example $(basename "$file") ---"
start_time=$SECONDS
uv run --no-sync python "$file" || exit 1
duration=$((SECONDS - start_time))
echo "Finished in ${duration}s."
echo "$(basename "$file"): ${duration}s" >> "$summary_file"
fi
done
echo
echo "==================================="
echo " Final Runtime Summary "
echo "==================================="
cat "$summary_file"
echo "==================================="
- name: Grant permissions to APT cache directory # allows backup
run: sudo chown -R $USER:$USER /var/cache/apt/archives
test-pip-install-no-lock:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Test pip install across Python versions
run: |
for py_version in 3.10 3.11 3.12 3.13 3.14; do
echo "=========================================="
echo "Testing Python $py_version"
echo "=========================================="
# Create virtual environment with uv
uv venv /tmp/venv-${py_version} --python=${py_version}
source /tmp/venv-${py_version}/bin/activate
# Install package with pip (no lock file)
uv pip install --torch-backend=cpu -e .[easyocr,tesserocr,vlm,rapidocr,asr]
# Run basic import test
python -c "import docling; from docling.document_converter import DocumentConverter; print('Import successful for Python ${py_version}')"
# Cleanup
deactivate
rm -rf /tmp/venv-${py_version}
echo "Python $py_version: PASSED"
echo ""
done
test-pip-install-no-dev-headers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Test pip install without dev headers across Python versions
run: |
for py_version in 3.10 3.11 3.12 3.13 3.14; do
echo "=========================================="
echo "Testing Python $py_version (no dev headers)"
echo "=========================================="
# Create virtual environment with uv
uv venv /tmp/venv-nodev-${py_version} --python=${py_version}
source /tmp/venv-nodev-${py_version}/bin/activate
# Find and remove Python.h from the Python installation
echo "Removing Python development headers from Python installation..."
python_include_dir=$(python -c "import sysconfig; print(sysconfig.get_path('include'))")
echo "Python include directory: $python_include_dir"
if [ -f "$python_include_dir/Python.h" ]; then
echo "Found Python.h, removing it and other headers..."
# Use sudo if the directory is system-owned
if [ -w "$python_include_dir" ]; then
rm -rf "$python_include_dir"/*
else
sudo rm -rf "$python_include_dir"/*
fi
echo "✓ Headers removed"
else
echo "Warning: Python.h not found at expected location"
fi
# Verify that compilation fails without dev headers
# Try to install numpy from source (sdist) - this should fail
echo "Verifying compilation fails without dev headers..."
set +e # Temporarily allow command to fail
uv pip install --no-binary=:all: numpy==1.26.4 > /tmp/numpy-install-${py_version}.log 2>&1
numpy_exit_code=$?
set -e # Re-enable exit on error
if [ $numpy_exit_code -eq 0 ]; then
echo "ERROR: numpy installation from source succeeded, but it should have failed without dev headers!"
cat /tmp/numpy-install-${py_version}.log
exit 1
else
echo "✓ Compilation correctly failed without dev headers (expected behavior)"
# Check that the error mentions missing Python.h or similar
if grep -qi "Python.h\|fatal error.*\.h" /tmp/numpy-install-${py_version}.log; then
echo "✓ Error message confirms missing development headers"
else
echo "Warning: Error message doesn't explicitly mention missing headers, but compilation failed as expected"
fi
fi
# Install package with pip (no lock file, no compilation)
# Install without extras that require compilation (tesserocr requires dev headers)
# Note: Not using --only-binary since some packages are sdist-only but don't require compilation
uv pip install --torch-backend=cpu -e .[easyocr,vlm,rapidocr,asr]
# Run basic import test
python -c "import docling; from docling.document_converter import DocumentConverter; print('Import successful for Python ${py_version} without dev headers')"
# Cleanup
deactivate
rm -rf /tmp/venv-nodev-${py_version}
echo "Python $py_version (no dev headers): PASSED"
echo ""
done
build-package:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v6
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
- name: Install dependencies
run: uv sync --all-extras --no-extra nemotron-ocr
- name: Build package
run: uv build
- name: Check content of wheel
run: unzip -l dist/*.whl
- name: Store the distribution packages
uses: actions/upload-artifact@v6
with:
name: python-package-distributions
path: dist/
test-package:
needs:
- build-package
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- name: Download all the dists
uses: actions/download-artifact@v7
with:
name: python-package-distributions
path: dist/
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
activate-environment: true
enable-cache: false
- name: Install package
run: |
uv pip install dist/*.whl
- name: Run docling
run: uv run docling --help