fix(ci): test document extraction with its pinned Python runtime
This commit is contained in:
@@ -93,26 +93,45 @@ jobs:
|
||||
# The Debian runner omits pip and python3-venv. Use pip's official
|
||||
# zipapp and install into the checkout so CI remains isolated without
|
||||
# sudo or a mutable runner-global Python environment.
|
||||
curl -fsSLo /tmp/pip.pyz https://bootstrap.pypa.io/pip/pip.pyz
|
||||
install_parser_dependencies() {
|
||||
rm -rf .python-ci
|
||||
parser_pip_cache="$(mktemp -d)"
|
||||
PIP_CACHE_DIR="$parser_pip_cache" python3 /tmp/pip.pyz install --target .python-ci --require-hashes \
|
||||
--extra-index-url https://download.pytorch.org/whl/cpu \
|
||||
-r requirements-linux.lock
|
||||
python_tmp="$(mktemp -d)"
|
||||
trap 'rm -rf -- "$python_tmp"' EXIT
|
||||
curl -fsSLo "$python_tmp/pip.pyz" https://bootstrap.pypa.io/pip/pip.pyz
|
||||
install_locked() {
|
||||
local interpreter="$1" destination="$2" attempt scratch
|
||||
shift 2
|
||||
for attempt in 1 2 3; do
|
||||
scratch="$(mktemp -d "$python_tmp/install.XXXXXX")"
|
||||
if PIP_CACHE_DIR="$scratch/cache" "$interpreter" "$python_tmp/pip.pyz" install \
|
||||
--target "$scratch/site" --require-hashes "$@"; then
|
||||
mv "$scratch/site" "$destination"
|
||||
return
|
||||
fi
|
||||
echo "Locked Python dependency install attempt $attempt failed."
|
||||
done
|
||||
return 1
|
||||
}
|
||||
parser_install_succeeded=false
|
||||
for attempt in 1 2 3; do
|
||||
if install_parser_dependencies; then
|
||||
parser_install_succeeded=true
|
||||
break
|
||||
fi
|
||||
echo "Parser dependency install attempt $attempt failed — retrying with a fresh isolated cache..."
|
||||
done
|
||||
test "$parser_install_succeeded" = true
|
||||
PIP_CACHE_DIR="$parser_pip_cache" python3 /tmp/pip.pyz install --upgrade --target .python-ci pytest==8.3.5 httpx2==2.12.0
|
||||
python3 --version
|
||||
PYTHONFAULTHANDLER=1 PYTHONPATH="$PWD/.python-ci" AI_SERVICE_SKIP_MODEL_LOAD=1 python3 -m pytest -q
|
||||
install_locked python3 "$python_tmp/sidecar" --extra-index-url https://download.pytorch.org/whl/cpu \
|
||||
-r requirements-dev-linux.lock
|
||||
PYTHONFAULTHANDLER=1 PYTHONPATH="$python_tmp/sidecar" AI_SERVICE_SKIP_MODEL_LOAD=1 \
|
||||
python3 -m pytest -q --ignore=tests/test_document_extractor.py
|
||||
|
||||
# The CV parser uses a separate dependency set. Its lock already pins
|
||||
# pluggy and pygments; add the remaining hashed pytest requirements.
|
||||
# The Docling lock targets Python 3.12, while the Debian runner uses 3.11.
|
||||
cv_archive="$python_tmp/cv-python.tar.gz"
|
||||
curl -fsSL --retry 2 -o "$cv_archive" \
|
||||
'https://github.com/astral-sh/python-build-standalone/releases/download/20250517/cpython-3.12.10%2B20250517-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz'
|
||||
echo "0356bd1db292781a20e011d789f0c41ea5ec04731c8236c8185b53a54faf2871 $cv_archive" | sha256sum -c -
|
||||
tar -xzf "$cv_archive" -C "$python_tmp"
|
||||
cv_python="$python_tmp/python/bin/python3"
|
||||
"$cv_python" --version
|
||||
awk '/^[^[:space:]#]/ { include = /^(iniconfig|packaging|pytest)==/ }
|
||||
include && !/^[[:space:]]*#/ { print }' requirements-dev-linux.lock > "$python_tmp/cv-test-tools.lock"
|
||||
test "$(grep -Ec '^(iniconfig|packaging|pytest)==' "$python_tmp/cv-test-tools.lock")" -eq 3
|
||||
install_locked "$cv_python" "$python_tmp/cv-parser" -r requirements-cv-import.lock -r "$python_tmp/cv-test-tools.lock"
|
||||
PYTHONFAULTHANDLER=1 PYTHONPATH="$python_tmp/cv-parser" OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 \
|
||||
"$cv_python" -m pytest -q tests/test_document_extractor.py
|
||||
|
||||
- name: Restore backend
|
||||
# The runner/proxy has occasionally supplied checksum-invalid NuGet cache entries (NU3008).
|
||||
|
||||
Reference in New Issue
Block a user