omarsol Claude Opus 4.8 (1M context) commited on
Commit
e1e4a09
·
1 Parent(s): 37dd9db

build(graphrag): make graphrag an eval-only optional extra (keep prod image lean)

Browse files

F28 concluded GraphRAG is not worth adopting, so the retriever never runs in
prod. Its deps (graphrag + lancedb/litellm/pandas) are imported lazily and only
by app/graph_rag.py, and nothing else in the app uses them — so move graphrag
out of the default dependencies into [project.optional-dependencies].graphrag.

- Prod / CI `uv sync` no longer installs graphrag/lancedb/litellm (verified
absent); the Spaces image stays lean. Default runtime behavior is unchanged
(the import path is never hit unless retriever=graphrag is selected).
- tests/test_graph_rag.py guards with pytest.importorskip("graphrag") so the
default suite collects clean (5 tests skip without the extra, run + pass with
`uv sync --extra graphrag`).
- evals_graphrag.md documents the `uv sync --extra graphrag` reproduce step.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files changed (4) hide show
  1. evals_graphrag.md +14 -0
  2. pyproject.toml +7 -1
  3. tests/test_graph_rag.py +7 -0
  4. uv.lock +0 -0
evals_graphrag.md CHANGED
@@ -49,6 +49,20 @@ question). Both arms run on those 41 cases, both restricted to that source
49
  Measured course-content indexing rate: **~$88 / 1M corpus tokens** (vs ~$255 for
50
  dense API-reference docs). full_stack = 486k tokens -> **~$43** to index.
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  ## Build the graph DB
53
 
54
  Local-only; never uploaded to the HF vector-db bundle (the `data/graphrag/`
 
49
  Measured course-content indexing rate: **~$88 / 1M corpus tokens** (vs ~$255 for
50
  dense API-reference docs). full_stack = 486k tokens -> **~$43** to index.
51
 
52
+ ## Setup (optional extra)
53
+
54
+ `graphrag` (and its `lancedb`/`litellm`/`pandas` deps) is an **eval-only optional
55
+ extra** — it is imported lazily and only by the opt-in `graphrag` retriever, never
56
+ on the production path, so it is kept out of the default install to keep the prod
57
+ image lean. Install it to build/run this experiment:
58
+
59
+ ```bash
60
+ uv sync --extra graphrag
61
+ ```
62
+
63
+ A default `uv sync` (prod, CI) omits it; `tests/test_graph_rag.py` skips itself
64
+ when the extra is absent.
65
+
66
  ## Build the graph DB
67
 
68
  Local-only; never uploaded to the HF vector-db bundle (the `data/graphrag/`
pyproject.toml CHANGED
@@ -10,7 +10,6 @@ dependencies = [
10
  "cohere",
11
  "fastapi",
12
  "google-genai",
13
- "graphrag>=3.1.0",
14
  "hf-xet",
15
  "huggingface-hub",
16
  "langchain",
@@ -28,6 +27,13 @@ dependencies = [
28
  "uvicorn",
29
  ]
30
 
 
 
 
 
 
 
 
31
  [dependency-groups]
32
  dev = [
33
  "httpx",
 
10
  "cohere",
11
  "fastapi",
12
  "google-genai",
 
13
  "hf-xet",
14
  "huggingface-hub",
15
  "langchain",
 
27
  "uvicorn",
28
  ]
29
 
30
+ [project.optional-dependencies]
31
+ # Eval-only: the GraphRAG-vs-RAG experiment (F28). Pulls graphrag + lancedb/litellm/
32
+ # pandas, all imported lazily and only by the opt-in `graphrag` retriever — never on
33
+ # the production path. Kept out of the default install so the Spaces image stays lean.
34
+ # Reproduce the experiment with: uv sync --extra graphrag (see evals_graphrag.md).
35
+ graphrag = ["graphrag>=3.1.0"]
36
+
37
  [dependency-groups]
38
  dev = [
39
  "httpx",
tests/test_graph_rag.py CHANGED
@@ -4,6 +4,13 @@ import tempfile
4
  import unittest
5
  from pathlib import Path
6
 
 
 
 
 
 
 
 
7
  import pandas as pd
8
 
9
  from app.chat_types import ChatRequest
 
4
  import unittest
5
  from pathlib import Path
6
 
7
+ import pytest
8
+
9
+ # The GraphRAG retriever is an optional eval-only extra (see pyproject
10
+ # [project.optional-dependencies].graphrag). Skip this module unless it is
11
+ # installed, so a default/prod `uv sync` (which omits it) still collects clean.
12
+ pytest.importorskip("graphrag", reason="install the optional 'graphrag' extra to run")
13
+
14
  import pandas as pd
15
 
16
  from app.chat_types import ChatRequest
uv.lock CHANGED
The diff for this file is too large to render. See raw diff