Skip to content

fix(deps): move tqdm, pyyaml, numpy from heavy extras into core#118

Merged
andylizf merged 1 commit into
mainfrom
fix/light-deps-to-core
Jul 16, 2026
Merged

fix(deps): move tqdm, pyyaml, numpy from heavy extras into core#118
andylizf merged 1 commit into
mainfrom
fix/light-deps-to-core

Conversation

@andylizf

Copy link
Copy Markdown
Contributor

Problem

Several PRs fail CI's Tests job at import/collection time with ModuleNotFoundError (tqdm, yaml, numpy) — not on any assertion. The suite is deliberately torch-free (no test imports torch/faiss/transformers), and it runs on uv sync --extra dev (core + pytest only).

Root cause: three light, pure-Python utilities are gated behind the heavy embed/index extras, even though modules that are meant to run without torch import them at module load:

  • embed/chunk.py — pure image slicing (stdlib + PIL), uses tqdm
  • index/config.py — config parsing, uses yaml
  • embed/embed.pydeliberately lazy-imports torch inside functions, but imports numpy/tqdm at the top

So pixelrag chunk / pixelrag index --help and these tests can't import on a core-only install without dragging in torch/faiss.

Fix

Move tqdm, pyyaml, numpy into core dependencies; drop the now-redundant copies from the embed/serve/index/eval extras. No CI changes, no pytest.skip workarounds — the light stages simply become importable light again.

"Core stays light — no torch" still holds: these are not torch/GPU/heavy-ML deps. uv lock --locked confirms the lock is consistent (no re-resolution; no version changes — pure regrouping).

Unblocks (once merged, these go genuinely green — no skips)

tqdm, pyyaml and numpy are light, pure-Python utilities that the umbrella
CLI (`pixelrag chunk`, `pixelrag index`) and the torch-free stage code
import at module load: chunk.py, index/config.py, and embed.py (which
deliberately lazy-imports torch but imports numpy/tqdm at the top).

Gating them behind the heavy `embed`/`index` extras forced a torch install
for light operations and made those modules fail to import on a core-only
install — which is why the test suite (deliberately torch-free; no test
imports torch/faiss/transformers) hit ModuleNotFoundError at collection
time on `uv sync --extra dev`.

Move the three into core dependencies and drop the now-redundant copies
from the embed/serve/index/eval extras. "Core stays light (no torch)"
still holds — these are not torch/GPU deps — and the suite now imports
cleanly with no skips or CI changes.
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web Ready Ready Preview, Comment Jul 16, 2026 8:54am

@andylizf
andylizf merged commit 7af960e into main Jul 16, 2026
6 checks passed
@andylizf
andylizf deleted the fix/light-deps-to-core branch July 16, 2026 08:57
andylizf added a commit to Anush008/PixelRAG that referenced this pull request Jul 16, 2026
… contract tests

Conflict resolution against main (StarTrail-org#115/StarTrail-org#118/StarTrail-org#119 landed since this PR
branched):
- Department filtering moved into the backend interface: raw_search now
  takes article_ids (+ filter_cache_key). FaissBackend implements it as
  the same IDSelectorBatch/SearchParametersIVF pre-filter main used, with
  the positions scan cached per key; QdrantBackend as a payload
  MatchAny(article_id) filter. api.py keeps only the backend-agnostic
  department -> article-ids lookup.
- PIXELRAG_INDEX_MMAP support (added on main) ported into
  FaissBackend.__init__.
- pyproject: qdrant extra layered onto main's post-StarTrail-org#118 extras.

Fixes found while testing:
- FaissBackend assumed IndexIVF: `.nprobe` access and make_direct_map()
  crash on flat indexes. nprobe is now a no-op/0 on flat indexes and
  reconstruct only builds a direct map when the index has one.

tests/test_serve_backends.py runs the SAME contract suite against both
backends (FAISS on a synthetic index; Qdrant fully in-process via
QdrantClient(":memory:")): hit shape/ranking, article_ids pre-filter,
k-guarantee within a filtered set, filter-position caching, reconstruct
round-trip. Skips cleanly when the optional heavy extras are absent.
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