Skip to content

Commit f3bf294

Browse files
committed
fix: PaddleOCR model downloads failing silently in CI
Remove continue-on-error from model download steps so failures are visible. Add retry logic with exponential backoff (3 attempts), increase curl timeouts (30s connect, 600s max), bump cache key to v2, and fail the verify step when no models are found. Also remove unused cache-binding-artifact action.
1 parent c2f4670 commit f3bf294

File tree

2 files changed

+54
-172
lines changed

2 files changed

+54
-172
lines changed

.github/actions/cache-binding-artifact/action.yml

Lines changed: 0 additions & 145 deletions
This file was deleted.

.github/actions/setup-paddle-ocr-models/action.yml

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ runs:
4141
id: cache-models
4242
with:
4343
path: ~/.cache/kreuzberg/paddle-ocr
44-
key: ${{ inputs.cache-key-suffix }}-${{ runner.os }}-${{ runner.arch }}-v1
44+
key: ${{ inputs.cache-key-suffix }}-${{ runner.os }}-${{ runner.arch }}-v2
4545
restore-keys: |
4646
${{ inputs.cache-key-suffix }}-${{ runner.os }}-${{ runner.arch }}-
4747
${{ inputs.cache-key-suffix }}-${{ runner.os }}-
@@ -50,7 +50,6 @@ runs:
5050
- name: Download detection model (det)
5151
if: contains(inputs.models, 'det') && steps.cache-models.outputs.cache-hit != 'true'
5252
shell: bash
53-
continue-on-error: true
5453
run: |
5554
MODEL_URL="https://huggingface.co/Kreuzberg/paddleocr-onnx-models/resolve/main/ch_PP-OCRv4_det_infer.onnx"
5655
CACHE_DIR="$HOME/.cache/kreuzberg/paddle-ocr"
@@ -60,18 +59,27 @@ runs:
6059
echo "Downloading detection model from $MODEL_URL"
6160
mkdir -p "$MODEL_DIR"
6261
63-
if curl -f -L --progress-bar --connect-timeout 10 --max-time 300 \
64-
-o "$MODEL_FILE" "$MODEL_URL"; then
65-
echo "Detection model downloaded successfully ($(du -h "$MODEL_FILE" | cut -f1))"
66-
else
67-
echo "Warning: Failed to download detection model, CI will continue without it"
68-
rm -f "$MODEL_FILE"
69-
fi
62+
for attempt in 1 2 3; do
63+
if [ $attempt -gt 1 ]; then
64+
backoff=$((5 * 3 ** (attempt - 2)))
65+
echo "Retry attempt $attempt/$3 after ${backoff}s backoff..."
66+
sleep $backoff
67+
fi
68+
69+
if curl -f -L --progress-bar --connect-timeout 30 --max-time 600 \
70+
-o "$MODEL_FILE" "$MODEL_URL"; then
71+
echo "Detection model downloaded successfully ($(du -h "$MODEL_FILE" | cut -f1))"
72+
exit 0
73+
fi
74+
done
75+
76+
echo "ERROR: Failed to download detection model after 3 attempts"
77+
rm -f "$MODEL_FILE"
78+
exit 1
7079
7180
- name: Download classification model (cls)
7281
if: contains(inputs.models, 'cls') && steps.cache-models.outputs.cache-hit != 'true'
7382
shell: bash
74-
continue-on-error: true
7583
run: |
7684
MODEL_URL="https://huggingface.co/Kreuzberg/paddleocr-onnx-models/resolve/main/ch_ppocr_mobile_v2.0_cls_infer.onnx"
7785
CACHE_DIR="$HOME/.cache/kreuzberg/paddle-ocr"
@@ -81,18 +89,27 @@ runs:
8189
echo "Downloading classification model from $MODEL_URL"
8290
mkdir -p "$MODEL_DIR"
8391
84-
if curl -f -L --progress-bar --connect-timeout 10 --max-time 300 \
85-
-o "$MODEL_FILE" "$MODEL_URL"; then
86-
echo "Classification model downloaded successfully ($(du -h "$MODEL_FILE" | cut -f1))"
87-
else
88-
echo "Warning: Failed to download classification model, CI will continue without it"
89-
rm -f "$MODEL_FILE"
90-
fi
92+
for attempt in 1 2 3; do
93+
if [ $attempt -gt 1 ]; then
94+
backoff=$((5 * 3 ** (attempt - 2)))
95+
echo "Retry attempt $attempt/$3 after ${backoff}s backoff..."
96+
sleep $backoff
97+
fi
98+
99+
if curl -f -L --progress-bar --connect-timeout 30 --max-time 600 \
100+
-o "$MODEL_FILE" "$MODEL_URL"; then
101+
echo "Classification model downloaded successfully ($(du -h "$MODEL_FILE" | cut -f1))"
102+
exit 0
103+
fi
104+
done
105+
106+
echo "ERROR: Failed to download classification model after 3 attempts"
107+
rm -f "$MODEL_FILE"
108+
exit 1
91109
92110
- name: Download recognition model (rec)
93111
if: contains(inputs.models, 'rec') && steps.cache-models.outputs.cache-hit != 'true'
94112
shell: bash
95-
continue-on-error: true
96113
run: |
97114
MODEL_URL="https://huggingface.co/Kreuzberg/paddleocr-onnx-models/resolve/main/en_PP-OCRv4_rec_infer.onnx"
98115
CACHE_DIR="$HOME/.cache/kreuzberg/paddle-ocr"
@@ -102,13 +119,23 @@ runs:
102119
echo "Downloading recognition model from $MODEL_URL"
103120
mkdir -p "$MODEL_DIR"
104121
105-
if curl -f -L --progress-bar --connect-timeout 10 --max-time 300 \
106-
-o "$MODEL_FILE" "$MODEL_URL"; then
107-
echo "Recognition model downloaded successfully ($(du -h "$MODEL_FILE" | cut -f1))"
108-
else
109-
echo "Warning: Failed to download recognition model, CI will continue without it"
110-
rm -f "$MODEL_FILE"
111-
fi
122+
for attempt in 1 2 3; do
123+
if [ $attempt -gt 1 ]; then
124+
backoff=$((5 * 3 ** (attempt - 2)))
125+
echo "Retry attempt $attempt/$3 after ${backoff}s backoff..."
126+
sleep $backoff
127+
fi
128+
129+
if curl -f -L --progress-bar --connect-timeout 30 --max-time 600 \
130+
-o "$MODEL_FILE" "$MODEL_URL"; then
131+
echo "Recognition model downloaded successfully ($(du -h "$MODEL_FILE" | cut -f1))"
132+
exit 0
133+
fi
134+
done
135+
136+
echo "ERROR: Failed to download recognition model after 3 attempts"
137+
rm -f "$MODEL_FILE"
138+
exit 1
112139
113140
- name: Verify downloaded models
114141
id: verify-models
@@ -142,9 +169,9 @@ runs:
142169
fi
143170
144171
if [ ${#AVAILABLE_MODELS[@]} -eq 0 ]; then
145-
echo " No models found in cache directory"
172+
echo "ERROR: No models found in cache directory after download"
146173
echo "available-models=" >> $GITHUB_OUTPUT
147-
exit 0
174+
exit 1
148175
fi
149176
150177
AVAILABLE_MODELS_STR=$(IFS=, ; echo "${AVAILABLE_MODELS[*]}")

0 commit comments

Comments
 (0)