Coverage for src/qdrant_loader_mcp_server/search/enhanced/cdi/extractors/graph.py: 57%
14 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-08 06:06 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-08 06:06 +0000
1from __future__ import annotations
3from ..interfaces import GraphBuilder
6class DefaultGraphBuilder(GraphBuilder):
7 """Adapter to legacy graph building via CitationNetworkAnalyzer."""
9 def build(self, results): # type: ignore[override]
10 # Prefer local CDI citations analyzer; fall back to legacy path. Raise clear error if both fail.
11 try:
12 from ..citations import CitationNetworkAnalyzer # type: ignore[misc]
13 except (ImportError, ModuleNotFoundError) as first_import_exc:
14 try:
15 from ..cross_document_intelligence import (
16 CitationNetworkAnalyzer, # type: ignore[misc]
17 )
18 except (ImportError, ModuleNotFoundError) as fallback_import_exc:
19 # Raise a clear error with both original exceptions chained for debugging context
20 message = (
21 "Unable to import CitationNetworkAnalyzer from CDI citations or fallback cross_document_intelligence. "
22 "Attempted imports: 'from ..citations' and 'from ..cross_document_intelligence'."
23 )
24 raise ImportError(message) from ExceptionGroup(
25 "CitationNetworkAnalyzer import failures",
26 [first_import_exc, fallback_import_exc],
27 )
29 analyzer = CitationNetworkAnalyzer()
30 return analyzer.build_citation_network(results)