Skip to content

RAG upload CI: install Pillow, and check every harness import is installed - #18381

Merged
danielhanchen merged 1 commit into
mainfrom
ci/rag-upload-venv-pillow
Nov 18, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci/rag-upload-venv-pillow

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

The Uploads job (tests/studio/rag_upload_ci.py) fails on ubuntu-latest and windows-latest because studio/backend/tests/test_rag_extract_text.py cannot be collected:

studio/backend/tests/test_rag_extract_text.py:129: in <module>
    ("shot.webp", _image("WEBP", (40, 30)), (40, 30)),
studio/backend/tests/test_rag_extract_text.py:119: in _image
    from PIL import Image
E   ModuleNotFoundError: No module named 'PIL'

Seen on the staging run for #18375, on current main.

Cause

#18293 added image uploads to the knowledge-base path. routes/rag.py _image_png decodes them with Pillow, and test_rag_extract_text.py builds its WebP / JPEG / TIFF fixtures with Pillow inside a parametrize list, so at collection time. Pillow is a Studio runtime dependency (no-torch-runtime.txt pins pillow==13.0.0 for Python 3.11+), so the route is correct.

The Uploads job builds its venv only from tests/studio/rag_upload_requirements.txt, which had no Pillow. test_rag_upload_requirements_cover_ci_imports.py exists to catch this kind of gap, but it only read imports placed under an if ... "CI" ... block, so a function-level from PIL import Image went unseen.

Fix

  • Pin pillow==13.0.0 in rag_upload_requirements.txt, the runtime version for the job's Python 3.12. It resolves with the rest of the file on both x86_64-manylinux_2_28 and x86_64-pc-windows-msvc.
  • Widen the guard with a new check. Every third-party import in the files the harness runs (test_rag_*.py plus test_conversation_archive.py, as rag_upload_ci.py lists them) must be installed by the requirements file. The check covers module level and inside functions.
    • Imports inside try: ... except ImportError stay optional.
    • Local modules (studio/backend, studio/backend/tests, tests/_shared) are skipped.
    • Import names map to their wheel name where they differ (PIL to pillow, fitz to pymupdf, docx to python-docx, and so on).
  • A control test asserts that the scan sees the function-level PIL import.

Every other third-party import in those files was already pinned, so the widened check adds no further requirements.

Verification

rag_upload_requirements.txt test_rag_upload_requirements_cover_ci_imports.py
without the Pillow pin (main) not in rag_upload_requirements.txt: ['test_rag_extract_text.py: PIL']
this branch 4 passed

ruff is clean.

…alled

#18293 converts uploaded images to PNG with PIL (routes/rag.py
_image_png) and test_rag_extract_text.py builds its WebP / JPEG / TIFF
fixtures with PIL while the module is collected. The Uploads job builds
its venv only from rag_upload_requirements.txt, which had no Pillow, so
the file fails to collect on ubuntu-latest and windows-latest. Pin
pillow at the Studio runtime version.

The existing guard only read imports under an if-CI block. Also check
every third-party import (module level or in a function, outside
try/except ImportError) in the files the harness runs.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T19:00:14.749789Z 345faad Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 345faad7d0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 1f8e5b6 into main Nov 18, 2026
@danielhanchen
danielhanchen deleted the ci/rag-upload-venv-pillow branch November 18, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant