Skip to content

Switch to AIPCC base image and enable fully hermetic builds#245

Open
ckhordiasma wants to merge 17 commits into
red-hat-data-services:mainfrom
ckhordiasma:hermeto-prefetch-aipcc
Open

Switch to AIPCC base image and enable fully hermetic builds#245
ckhordiasma wants to merge 17 commits into
red-hat-data-services:mainfrom
ckhordiasma:hermeto-prefetch-aipcc

Conversation

@ckhordiasma

@ckhordiasma ckhordiasma commented May 15, 2026

Copy link
Copy Markdown

Summary

  • Switch Dockerfile.konflux from UBI9 python-312 to AIPCC CPU base image (quay.io/aipcc/base-images/cpu:3.5.0-ea.1) with pre-installed system libraries and pre-configured Python index
  • Compile requirements.txt against the AIPCC index using uv pip compile with --default-index, --prerelease=if-necessary, and --no-strip-markers for multi-arch compatibility
  • Add requirements-build.txt generated via pip-compile --build-deps-for=wheel --only-build-deps for the poetry-core build backend
  • Add hermetic model prefetch — replace the runtime pre_download_required_models.py network download with prefetched artifacts via the Konflux generic fetcher, enabling full --network none builds
  • Enable hermetic: true in the PR pipeline

Hermetic model prefetch

The previous approach downloaded ML models from HuggingFace/GitHub at build time, which was the last network dependency blocking hermetic builds. This PR replaces it with:

  • artifacts.lock.yaml — generic fetcher lockfile with download URLs and checksums for all model files, generated by scripts/generate_model_lockfile.py
  • scripts/setup_prefetched_models.sh — reconstructs HF cache directory structures from the flat prefetched files during Docker build
  • requirements-models.txt — spacy en-core-web-lg model as a pip URL dependency (handled by the pip prefetcher)

Models prefetched:

Model Type Source
sentence-transformers/all-MiniLM-L6-v2 Sentence Transformers (PyTorch) HuggingFace Hub
qdrant/all-MiniLM-L6-v2-onnx FastEmbed (ONNX) HuggingFace Hub
en-core-web-lg 3.8.0 SpaCy GitHub releases (pip)
punkt NLTK tokenizer GitHub nltk_data

To regenerate the lockfile when models change:

uv run --with pyyaml --with fastembed scripts/generate_model_lockfile.py

Multi-arch verification

Hermetic builds (--network none) tested and model loading validated on all four target architectures:

Arch Host Build Models
aarch64 local (Apple Silicon) ✅ Pass ✅ All 4 load offline
x86_64 Beaker VM ✅ Pass ✅ All 4 load offline
s390x Beaker VM ✅ Pass ✅ All 4 load offline
ppc64le Beaker VM ✅ Pass ✅ All 4 load offline

Key decisions

  • hermetic: true — all dependencies (pip wheels, spacy model, HuggingFace models, NLTK data) are now prefetched. No network access needed during build.
  • Generic fetcher for HF models — each model file is listed individually in artifacts.lock.yaml with SHA256 checksums. The setup script reconstructs the HF Hub cache structure (models--org--repo/snapshots/{commit}/) at build time.
  • Separate pip install for requirements-models.txt — the spacy model URL dependency includes a --hash, which triggers pip's --require-hashes mode. Installing it separately prevents hash-mode from propagating to the main requirements.txt.
  • Profile-gated setup — both generate_model_lockfile.py and setup_prefetched_models.sh accept GUARDRAILS_PROFILE and fail with a clear error for unsupported profiles (only opensource is implemented).
  • --prerelease=if-necessary instead of --prerelease=allow — avoids picking RC versions that may lack wheels on some architectures
  • --no-strip-markers — preserves platform markers so arch-specific deps like triton are skipped where not needed

Test plan

  • Hermetic build passes on all 4 architectures (aarch64, x86_64, s390x, ppc64le)
  • All models load offline (Sentence Transformers, FastEmbed, SpaCy, NLTK) on all 4 architectures
  • Verify prefetched dependencies match what's installed in the image
  • PR pipeline builds successfully on all 4 architectures
  • Container starts and serves the guardrails API on port 8000

🤖 Generated with Claude Code

@codecov-commenter

codecov-commenter commented May 15, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.91%. Comparing base (618be51) to head (5a45d93).
⚠️ Report is 24 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #245   +/-   ##
=======================================
  Coverage   76.91%   76.91%           
=======================================
  Files         200      200           
  Lines       20473    20473           
=======================================
  Hits        15747    15747           
  Misses       4726     4726           
Flag Coverage Δ
python 76.91% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ckhordiasma ckhordiasma changed the title Switch to AIPCC base image and enable hermeto prefetching Switch to AIPCC base image and enable pip prefetching May 15, 2026
@satyamg1620

satyamg1620 commented May 18, 2026

Copy link
Copy Markdown

@ckhordiasma for s390x, loading spacy models causing endianess issue. for that thinc package has to be build from source and have to patch the fix. @modassarrana89-new do you want to add something?

Comment thread Dockerfile.konflux Outdated
Comment thread requirements.txt Outdated

@m-misiura m-misiura left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AIPCC base image seems to have a different naming convention for the certificates inside /etc/pki/tls i.e. they are called ca-certificates.crt but Python ssl library expects them to be called ca-bundle.crt

I think we may need a symlink in the Dockerfile.konflux

@ckhordiasma ckhordiasma changed the title Switch to AIPCC base image and enable pip prefetching Switch to AIPCC base image and enable fully hermetic builds May 28, 2026
@ckhordiasma ckhordiasma force-pushed the hermeto-prefetch-aipcc branch from daba7db to a6fbf5e Compare June 12, 2026 17:24
@ckhordiasma

Copy link
Copy Markdown
Author

removed s390x as a build target due to endianness issue in upstream thinc package. Awaiting explosion/thinc#970

@satyamg1620

Copy link
Copy Markdown

ckhordiasma and others added 13 commits July 6, 2026 07:41
Replace the UBI9 + source-build approach with AIPCC base images for both
build and runtime stages. This eliminates ppc64le/s390x source builds,
RPM-based toolchain installs, and separate torch requirements by using
prebuilt AIPCC wheels for all architectures.

- Rewrite Dockerfile.konflux from Dockerfile.server using
  quay.io/aipcc/base-images/cpu:3.5.0-ea.1
- Recompile requirements.txt against AIPCC 3.5-EA1 CPU index
- Add requirements-build.txt for poetry-core build backend

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use --prerelease=if-necessary instead of --prerelease=allow to avoid
  RC versions with incomplete arch coverage (safetensors 0.8.0rc0 → 0.7.0)
- Use --no-strip-markers to preserve platform markers (triton excluded
  on s390x via platform_machine marker)
- Use --default-index instead of --index for correct --emit-index-url output

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace generic prefetch placeholder with pip config pointing at
  AIPCC requirements and build requirements files
- Add linux/s390x to build-platforms
- Keep hermetic: false (model download step needs network)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Generated with `uv run --with pip-tools pip-compile` using
--build-deps-for=wheel --only-build-deps to extract build backend
requirements from pyproject.toml, replacing hand-maintained file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the runtime model download step (pre_download_required_models.py)
with prefetched artifacts via the Konflux generic fetcher, enabling full
hermetic builds with --network none.

- Add scripts/generate_model_lockfile.py to discover required models and
  generate artifacts.lock.yaml with HuggingFace download URLs + checksums
- Add scripts/setup_prefetched_models.sh to reconstruct HF cache
  directories from prefetched generic artifacts during Docker build
- Add requirements-models.txt for spacy en-core-web-lg model (pip prefetch)
- Update hermeto.json with generic fetcher entry
- Update Dockerfile.konflux to use setup script instead of Python downloader

Models prefetched: sentence-transformers/all-MiniLM-L6-v2 (PyTorch),
qdrant/all-MiniLM-L6-v2-onnx (FastEmbed ONNX), en-core-web-lg (SpaCy),
punkt (NLTK). Validated on x86_64, aarch64, ppc64le, and s390x.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove hermeto.json (local testing only) and inline the prefetch config
into the PR pipeline's prefetch-input parameter. Adds the generic
fetcher entry for model artifacts and requirements-models.txt for the
spacy model. Sets hermetic: true now that all four architectures have
been validated with --network none.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
left requirements-build on EA1 because poetry-core doesn't appear to be on EA2 yet
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
due to endianness issue in thinc package
@ckhordiasma ckhordiasma force-pushed the hermeto-prefetch-aipcc branch 2 times, most recently from 67fd39d to 9523209 Compare July 6, 2026 12:22
@ckhordiasma ckhordiasma force-pushed the hermeto-prefetch-aipcc branch from 9523209 to 03bb333 Compare July 6, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants