Adam Cseresznye commited on
Commit ·
cc37b0c
1
Parent(s): 1901a0e
tests: clear legacy tests after cleanup
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- monitoring/health.py +0 -1
- prompts/analysis_prompts.py +0 -1
- rag/chunking.py +0 -1
- rag/embeddings.py +0 -1
- retrieval/hybrid_retriever.py +0 -1
- retrieval/reranker.py +0 -1
- tests/conftest.py +0 -1
- tests/end_to_end/test_analysis_e2e.py +0 -69
- tests/fixtures.py +0 -1
- tests/fixtures/analysis_fixtures.py +0 -469
- tests/integration/test_analysis_integration.py +0 -75
- tests/integration/test_processing_ab_comparison.py +0 -431
- tests/integration/test_processing_integration.py +0 -309
- tests/performance/test_analysis_performance.py +0 -52
- tests/symbols.pdf +0 -3
- tests/test_acquisition_agent.py +0 -1
- tests/test_acquisition_agent_v2.py +0 -1
- tests/test_advanced_acquisition.py +0 -1
- tests/test_advanced_chunking.py +0 -1
- tests/test_analysis.py +0 -1
- tests/test_analysis_error_handling.py +0 -1
- tests/test_analysis_langgraph_integration.py +0 -1
- tests/test_analysis_param.py +0 -1
- tests/test_deduplication_agent.py +0 -1
- tests/test_embedding_manager.py +0 -1
- tests/test_end_to_end_pipeline.py +0 -1
- tests/test_error_scenarios.py +0 -1
- tests/test_filtering_agent.py +0 -1
- tests/test_hybrid_retrieval.py +0 -1
- tests/test_hybrid_retriever.py +0 -1
- tests/test_llm_client.py +0 -1
- tests/test_logging_behavior.py +0 -1
- tests/test_memory_usage.py +0 -1
- tests/test_new_processing_agent.py +0 -1
- tests/test_openalex_client.py +0 -1
- tests/test_paper_diversity.py +0 -1
- tests/test_pdf_text_extractor.py +0 -1
- tests/test_performance.py +0 -1
- tests/test_processing_ab_comparison.py +0 -1
- tests/test_processing_agent.py +0 -1
- tests/test_processing_integration.py +0 -1
- tests/test_query_optimization_agent.py +0 -1
- tests/test_reranker.py +0 -1
- tests/test_scihub_fallback.py +0 -1
- tests/test_search_agent.py +0 -1
- tests/test_section_detector.py +0 -1
- tests/test_startup.py +0 -1
- tests/test_state_model.py +0 -1
- tests/test_synthesis_agent.py +0 -1
- tests/test_week2_performance.py +0 -1
monitoring/health.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
prompts/analysis_prompts.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
rag/chunking.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
rag/embeddings.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
retrieval/hybrid_retriever.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
retrieval/reranker.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/conftest.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/end_to_end/test_analysis_e2e.py
DELETED
|
@@ -1,69 +0,0 @@
|
|
| 1 |
-
import pytest
|
| 2 |
-
import asyncio
|
| 3 |
-
import time
|
| 4 |
-
from unittest.mock import AsyncMock, Mock, patch
|
| 5 |
-
from loguru import logger
|
| 6 |
-
|
| 7 |
-
from agents.analysis import AnalysisAgent
|
| 8 |
-
|
| 9 |
-
pytestmark = pytest.mark.e2e
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
@pytest.mark.asyncio
|
| 13 |
-
async def test_analysis_agent_end_to_end_success(
|
| 14 |
-
langgraph_state_factory,
|
| 15 |
-
high_cred_paper,
|
| 16 |
-
contradictory_passages,
|
| 17 |
-
valid_llm_response_json,
|
| 18 |
-
):
|
| 19 |
-
agent = AnalysisAgent()
|
| 20 |
-
|
| 21 |
-
# Create a state with one paper and passages
|
| 22 |
-
state = langgraph_state_factory(
|
| 23 |
-
filtered_papers=[high_cred_paper], relevant_passages=contradictory_passages
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
# Patch contradiction detector LLM call to return a valid JSON string
|
| 27 |
-
agent.contradiction_detector._call_llm_with_fallback = AsyncMock(
|
| 28 |
-
return_value=valid_llm_response_json
|
| 29 |
-
)
|
| 30 |
-
|
| 31 |
-
start = time.time()
|
| 32 |
-
result = await agent.analyze(state)
|
| 33 |
-
elapsed = time.time() - start
|
| 34 |
-
|
| 35 |
-
# Basic contract: returns credibility_scores and contradictions
|
| 36 |
-
assert "credibility_scores" in result
|
| 37 |
-
assert "contradictions" in result
|
| 38 |
-
assert len(result["credibility_scores"]) == 1
|
| 39 |
-
# Execution time expected under 8s for e2e test (mocked LLM)
|
| 40 |
-
assert result["execution_times"]["analysis_agent"] < 8.0
|
| 41 |
-
assert elapsed < 8.0
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
@pytest.mark.asyncio
|
| 45 |
-
async def test_analysis_agent_partial_failure_credibility_ok_contradiction_fails(
|
| 46 |
-
langgraph_state_factory, high_cred_paper, contradictory_passages
|
| 47 |
-
):
|
| 48 |
-
agent = AnalysisAgent()
|
| 49 |
-
state = langgraph_state_factory(
|
| 50 |
-
filtered_papers=[high_cred_paper], relevant_passages=contradictory_passages
|
| 51 |
-
)
|
| 52 |
-
|
| 53 |
-
# Make contradiction detection raise to simulate provider failure
|
| 54 |
-
async def raise_err(*args, **kwargs):
|
| 55 |
-
raise RuntimeError("LLM provider down")
|
| 56 |
-
|
| 57 |
-
agent.contradiction_detector.detect_contradictions = AsyncMock(
|
| 58 |
-
side_effect=raise_err
|
| 59 |
-
)
|
| 60 |
-
|
| 61 |
-
# Patch logger.error to capture that an error was logged
|
| 62 |
-
with patch.object(logger, "error", Mock()) as mock_err:
|
| 63 |
-
result = await agent.analyze(state)
|
| 64 |
-
# Credibility should still be present
|
| 65 |
-
assert len(result["credibility_scores"]) == 1
|
| 66 |
-
# Contradictions should be empty list on failure
|
| 67 |
-
assert result["contradictions"] == []
|
| 68 |
-
# Error should have been logged
|
| 69 |
-
assert mock_err.called
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/fixtures.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/fixtures/analysis_fixtures.py
DELETED
|
@@ -1,469 +0,0 @@
|
|
| 1 |
-
import json
|
| 2 |
-
import pytest
|
| 3 |
-
import numpy as np
|
| 4 |
-
from unittest.mock import Mock, MagicMock
|
| 5 |
-
from datetime import datetime
|
| 6 |
-
|
| 7 |
-
from models.state import (
|
| 8 |
-
Paper,
|
| 9 |
-
Passage,
|
| 10 |
-
State,
|
| 11 |
-
ProcessingConfig,
|
| 12 |
-
PDFContent,
|
| 13 |
-
ErrorReport,
|
| 14 |
-
Score,
|
| 15 |
-
)
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
@pytest.fixture
|
| 19 |
-
def high_cred_paper_dict():
|
| 20 |
-
return {
|
| 21 |
-
"paper_id": "nature_2023",
|
| 22 |
-
"citation_count": 250,
|
| 23 |
-
"year": 2023,
|
| 24 |
-
"journal": "Nature",
|
| 25 |
-
}
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
@pytest.fixture
|
| 29 |
-
def medium_cred_paper_dict():
|
| 30 |
-
return {
|
| 31 |
-
"paper_id": "mid_2020",
|
| 32 |
-
"citation_count": 45,
|
| 33 |
-
"year": 2020,
|
| 34 |
-
"journal": "Journal of Testing",
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
@pytest.fixture
|
| 39 |
-
def low_cred_paper_dict():
|
| 40 |
-
return {
|
| 41 |
-
"paper_id": "preprint_2015",
|
| 42 |
-
"citation_count": 3,
|
| 43 |
-
"year": 2015,
|
| 44 |
-
"journal": "arXiv",
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
@pytest.fixture
|
| 49 |
-
def high_cred_paper():
|
| 50 |
-
return Paper(
|
| 51 |
-
paper_id="nature_2023",
|
| 52 |
-
title="Great discovery",
|
| 53 |
-
authors=["A"],
|
| 54 |
-
year=2023,
|
| 55 |
-
journal="Nature",
|
| 56 |
-
citation_count=250,
|
| 57 |
-
pdf_url=None,
|
| 58 |
-
type="article",
|
| 59 |
-
)
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
@pytest.fixture
|
| 63 |
-
def medium_cred_paper():
|
| 64 |
-
return Paper(
|
| 65 |
-
paper_id="mid_2020",
|
| 66 |
-
title="Mid work",
|
| 67 |
-
authors=["B"],
|
| 68 |
-
year=2020,
|
| 69 |
-
journal="Journal of Testing",
|
| 70 |
-
citation_count=45,
|
| 71 |
-
pdf_url=None,
|
| 72 |
-
type="article",
|
| 73 |
-
)
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
@pytest.fixture
|
| 77 |
-
def low_cred_paper():
|
| 78 |
-
return Paper(
|
| 79 |
-
paper_id="preprint_2015",
|
| 80 |
-
title="Early draft",
|
| 81 |
-
authors=["C"],
|
| 82 |
-
year=2015,
|
| 83 |
-
journal="arXiv",
|
| 84 |
-
citation_count=3,
|
| 85 |
-
pdf_url=None,
|
| 86 |
-
type="article",
|
| 87 |
-
)
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
@pytest.fixture
|
| 91 |
-
def contradictory_passages():
|
| 92 |
-
# Two passages with opposing claims
|
| 93 |
-
p1 = Passage(
|
| 94 |
-
content="We found that drug X increases survival by 50%.",
|
| 95 |
-
section="results",
|
| 96 |
-
paper_id="p1",
|
| 97 |
-
retrieval_score=0.95,
|
| 98 |
-
)
|
| 99 |
-
p2 = Passage(
|
| 100 |
-
content="Our analysis shows drug X has no effect on survival.",
|
| 101 |
-
section="results",
|
| 102 |
-
paper_id="p2",
|
| 103 |
-
retrieval_score=0.93,
|
| 104 |
-
)
|
| 105 |
-
return [p1, p2]
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
@pytest.fixture
|
| 109 |
-
def valid_llm_response_json():
|
| 110 |
-
# Minimal valid DetectedContradiction list as JSON string
|
| 111 |
-
data = [
|
| 112 |
-
{
|
| 113 |
-
"topic": "effect_of_drug_x",
|
| 114 |
-
"claim_1": {"paper_id": "p1", "text": "drug X increases survival"},
|
| 115 |
-
"claim_2": {"paper_id": "p2", "text": "drug X has no effect"},
|
| 116 |
-
"severity": "major",
|
| 117 |
-
}
|
| 118 |
-
]
|
| 119 |
-
return json.dumps(data)
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
@pytest.fixture
|
| 123 |
-
def malformed_llm_response():
|
| 124 |
-
return "{this is: not valid json]"
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
@pytest.fixture
|
| 128 |
-
def langgraph_state_factory():
|
| 129 |
-
def _factory(
|
| 130 |
-
filtered_papers=None, relevant_passages=None, query="What about drug X?"
|
| 131 |
-
):
|
| 132 |
-
state = State(original_query=query)
|
| 133 |
-
if filtered_papers:
|
| 134 |
-
state.filtered_papers = filtered_papers
|
| 135 |
-
if relevant_passages:
|
| 136 |
-
state.relevant_passages = relevant_passages
|
| 137 |
-
# Minimal execution_times container
|
| 138 |
-
state.execution_times = {}
|
| 139 |
-
state.config = ProcessingConfig()
|
| 140 |
-
return state
|
| 141 |
-
|
| 142 |
-
return _factory
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
# --- Fixtures migrated from legacy tests/fixtures.py ---
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
@pytest.fixture
|
| 149 |
-
def initial_state() -> State:
|
| 150 |
-
"""Provides a basic State object with a query."""
|
| 151 |
-
return State(original_query="What is the role of autophagy in neurodegeneration?")
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
@pytest.fixture
|
| 155 |
-
def search_state(initial_state: State) -> State:
|
| 156 |
-
"""Provides a State object after the search step."""
|
| 157 |
-
paper1 = Paper(
|
| 158 |
-
paper_id="openalex:p1",
|
| 159 |
-
title="Paper 1 on Autophagy",
|
| 160 |
-
authors=["Author A", "Author B"],
|
| 161 |
-
year=2023,
|
| 162 |
-
journal="Nature",
|
| 163 |
-
citation_count=150,
|
| 164 |
-
doi="10.1038/nature12345",
|
| 165 |
-
pdf_url="http://example.com/p1.pdf",
|
| 166 |
-
type="article",
|
| 167 |
-
)
|
| 168 |
-
paper2 = Paper(
|
| 169 |
-
paper_id="openalex:p2",
|
| 170 |
-
title="Paper 2 on Neurodegeneration",
|
| 171 |
-
authors=["Author C"],
|
| 172 |
-
year=2023,
|
| 173 |
-
journal="Science",
|
| 174 |
-
citation_count=89,
|
| 175 |
-
doi="10.1126/science67890",
|
| 176 |
-
pdf_url="http://example.com/p2.pdf",
|
| 177 |
-
type="review",
|
| 178 |
-
)
|
| 179 |
-
initial_state.papers_metadata = [paper1, paper2]
|
| 180 |
-
initial_state.search_quality = {
|
| 181 |
-
"passed": True,
|
| 182 |
-
"reason": "Found 2 papers with avg_relevance 0.85",
|
| 183 |
-
"paper_count": 2,
|
| 184 |
-
"avg_relevance": 0.85,
|
| 185 |
-
}
|
| 186 |
-
return initial_state
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
@pytest.fixture
|
| 190 |
-
def acquisition_state(search_state: State) -> State:
|
| 191 |
-
"""Provides a State object after the acquisition step."""
|
| 192 |
-
search_state.pdf_contents = [
|
| 193 |
-
PDFContent(
|
| 194 |
-
paper_id="openalex:p1",
|
| 195 |
-
raw_text="Autophagy is a key process for cellular homeostasis.",
|
| 196 |
-
page_count=10,
|
| 197 |
-
char_count=500,
|
| 198 |
-
extraction_time=1.2,
|
| 199 |
-
)
|
| 200 |
-
]
|
| 201 |
-
search_state.download_failures = [
|
| 202 |
-
ErrorReport(
|
| 203 |
-
paper_id="openalex:p2",
|
| 204 |
-
url="http://example.com/p2.pdf",
|
| 205 |
-
error_type="HTTPError",
|
| 206 |
-
message="404 Not Found",
|
| 207 |
-
timestamp=1234567890.0,
|
| 208 |
-
recoverable=True,
|
| 209 |
-
)
|
| 210 |
-
]
|
| 211 |
-
return search_state
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
@pytest.fixture
|
| 215 |
-
def processing_state(acquisition_state: State) -> State:
|
| 216 |
-
"""Provides a State object after the processing step."""
|
| 217 |
-
passage1 = Passage(
|
| 218 |
-
content="Autophagy is a key process for cellular homeostasis.",
|
| 219 |
-
section="results",
|
| 220 |
-
paper_id="openalex:p1",
|
| 221 |
-
retrieval_score=0.95,
|
| 222 |
-
)
|
| 223 |
-
passage2 = Passage(
|
| 224 |
-
content="Dysfunctional autophagy is linked to many neurodegenerative diseases.",
|
| 225 |
-
section="results",
|
| 226 |
-
paper_id="openalex:p1",
|
| 227 |
-
retrieval_score=0.92,
|
| 228 |
-
)
|
| 229 |
-
acquisition_state.passages = [passage1, passage2]
|
| 230 |
-
return acquisition_state
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
@pytest.fixture
|
| 234 |
-
def analysis_state(processing_state: State) -> State:
|
| 235 |
-
"""Provides a State object after the analysis step."""
|
| 236 |
-
score1 = Score(
|
| 237 |
-
score_type="relevance",
|
| 238 |
-
value=0.95,
|
| 239 |
-
justification="Directly addresses the query about autophagy and neurodegeneration.",
|
| 240 |
-
)
|
| 241 |
-
score2 = Score(
|
| 242 |
-
score_type="novelty",
|
| 243 |
-
value=0.80,
|
| 244 |
-
justification="Presents a new perspective on cellular mechanisms.",
|
| 245 |
-
)
|
| 246 |
-
|
| 247 |
-
processing_state.scores = {"relevance": [score1], "novelty": [score2]}
|
| 248 |
-
return processing_state
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
@pytest.fixture
|
| 252 |
-
def mock_fastapi_app(request):
|
| 253 |
-
"""Mock FastAPI app with cached embedding model for ProcessingAgent."""
|
| 254 |
-
app = Mock()
|
| 255 |
-
app.state = Mock()
|
| 256 |
-
|
| 257 |
-
# Provide a lightweight test implementation that subclasses the real
|
| 258 |
-
# SentenceTransformer class so that isinstance checks pass in
|
| 259 |
-
# EmbeddingManager._validate_model. We avoid calling the heavy
|
| 260 |
-
# SentenceTransformer.__init__ to keep this fast and side-effect free.
|
| 261 |
-
# Provide a simple duck-typed model (no heavy initialization). We'll
|
| 262 |
-
# monkeypatch EmbeddingManager._validate_model in tests to return this
|
| 263 |
-
# model so the production isinstance checks are bypassed in the test
|
| 264 |
-
# environment. This keeps tests fast and deterministic.
|
| 265 |
-
class SimpleEmbeddingModel:
|
| 266 |
-
def encode(
|
| 267 |
-
self,
|
| 268 |
-
texts,
|
| 269 |
-
batch_size=None,
|
| 270 |
-
show_progress_bar=False,
|
| 271 |
-
convert_to_numpy=True,
|
| 272 |
-
device="cpu",
|
| 273 |
-
**kwargs,
|
| 274 |
-
):
|
| 275 |
-
if isinstance(texts, str):
|
| 276 |
-
texts = [texts]
|
| 277 |
-
return np.array(
|
| 278 |
-
[[0.1 + i * 0.01] * 384 for i, _ in enumerate(texts)], dtype=np.float32
|
| 279 |
-
)
|
| 280 |
-
|
| 281 |
-
mock_model = SimpleEmbeddingModel()
|
| 282 |
-
|
| 283 |
-
# Monkeypatch EmbeddingManager._validate_model to accept our simple model
|
| 284 |
-
try:
|
| 285 |
-
from utils.embedding_manager import EmbeddingManager
|
| 286 |
-
except Exception:
|
| 287 |
-
EmbeddingManager = None
|
| 288 |
-
|
| 289 |
-
original_validate = None
|
| 290 |
-
if EmbeddingManager is not None:
|
| 291 |
-
original_validate = EmbeddingManager._validate_model
|
| 292 |
-
|
| 293 |
-
def _validate_override(self):
|
| 294 |
-
return mock_model
|
| 295 |
-
|
| 296 |
-
EmbeddingManager._validate_model = _validate_override
|
| 297 |
-
|
| 298 |
-
# Ensure the original method is restored after the test
|
| 299 |
-
def _restore():
|
| 300 |
-
EmbeddingManager._validate_model = original_validate
|
| 301 |
-
|
| 302 |
-
request.addfinalizer(_restore)
|
| 303 |
-
|
| 304 |
-
app.state.embedding_model = mock_model
|
| 305 |
-
return app
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
@pytest.fixture
|
| 309 |
-
def realistic_scientific_papers():
|
| 310 |
-
paper1 = Paper(
|
| 311 |
-
paper_id="openalex:fasting-cardio-1",
|
| 312 |
-
title="Cardiovascular Effects of Intermittent Fasting: A Systematic Review and Meta-Analysis",
|
| 313 |
-
authors=["Zhang J", "Li F", "Wang Y"],
|
| 314 |
-
year=2023,
|
| 315 |
-
journal="Journal of the American College of Cardiology",
|
| 316 |
-
citation_count=245,
|
| 317 |
-
doi="10.1016/j.jacc.2023.02.045",
|
| 318 |
-
pdf_url="https://example.com/fasting-cardio-1.pdf",
|
| 319 |
-
type="article",
|
| 320 |
-
)
|
| 321 |
-
paper2 = Paper(
|
| 322 |
-
paper_id="openalex:fasting-cardio-2",
|
| 323 |
-
title="Time-Restricted Eating and Blood Pressure Control: Results from the TREAT Trial",
|
| 324 |
-
authors=["Harris M", "Garcia S", "Thomas R"],
|
| 325 |
-
year=2023,
|
| 326 |
-
journal="Hypertension",
|
| 327 |
-
citation_count=189,
|
| 328 |
-
doi="10.1161/HYPERTENSIONAHA.122.20880",
|
| 329 |
-
pdf_url="https://example.com/fasting-cardio-2.pdf",
|
| 330 |
-
type="article",
|
| 331 |
-
)
|
| 332 |
-
return [paper1, paper2]
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
@pytest.fixture
|
| 336 |
-
def realistic_pdf_contents():
|
| 337 |
-
content1 = """1. Introduction
|
| 338 |
-
|
| 339 |
-
Cardiovascular disease remains a leading cause of mortality worldwide. Studies report
|
| 340 |
-
changes in blood pressure, systolic and diastolic measures, and links to hypertension
|
| 341 |
-
as key risk factors in cardiovascular outcomes for dietary interventions."""
|
| 342 |
-
|
| 343 |
-
content2 = """INTRODUCTION
|
| 344 |
-
|
| 345 |
-
Time-restricted eating (TRE), a form of intermittent fasting, has shown promise
|
| 346 |
-
for reducing blood pressure and improving cardiovascular biomarkers. Clinical
|
| 347 |
-
trials report modest reductions in systolic and diastolic blood pressure and
|
| 348 |
-
improvements in hypertension-related outcomes in some cohorts."""
|
| 349 |
-
|
| 350 |
-
return [
|
| 351 |
-
PDFContent(
|
| 352 |
-
paper_id="openalex:fasting-cardio-1",
|
| 353 |
-
raw_text=content1,
|
| 354 |
-
page_count=12,
|
| 355 |
-
char_count=len(content1),
|
| 356 |
-
extraction_time=1.2,
|
| 357 |
-
),
|
| 358 |
-
PDFContent(
|
| 359 |
-
paper_id="openalex:fasting-cardio-2",
|
| 360 |
-
raw_text=content2,
|
| 361 |
-
page_count=8,
|
| 362 |
-
char_count=len(content2),
|
| 363 |
-
extraction_time=0.9,
|
| 364 |
-
),
|
| 365 |
-
]
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
@pytest.fixture
|
| 369 |
-
def integration_test_queries():
|
| 370 |
-
return [
|
| 371 |
-
{
|
| 372 |
-
"query": "cardiovascular risks of fasting",
|
| 373 |
-
"expected_terms_in_top5": [
|
| 374 |
-
"cardiovascular",
|
| 375 |
-
"blood pressure",
|
| 376 |
-
"hypertension",
|
| 377 |
-
"risk",
|
| 378 |
-
],
|
| 379 |
-
"min_relevant_passages": 3,
|
| 380 |
-
"description": "Should retrieve passages about cardiovascular effects and risks",
|
| 381 |
-
},
|
| 382 |
-
{
|
| 383 |
-
"query": "intermittent fasting blood pressure effects",
|
| 384 |
-
"expected_terms_in_top5": [
|
| 385 |
-
"blood pressure",
|
| 386 |
-
"systolic",
|
| 387 |
-
"diastolic",
|
| 388 |
-
"hypertension",
|
| 389 |
-
],
|
| 390 |
-
"min_relevant_passages": 4,
|
| 391 |
-
"description": "Should focus on BP effects from both studies",
|
| 392 |
-
},
|
| 393 |
-
{
|
| 394 |
-
"query": "time restricted eating cardiovascular outcomes",
|
| 395 |
-
"expected_terms_in_top5": [
|
| 396 |
-
"time-restricted",
|
| 397 |
-
"blood pressure",
|
| 398 |
-
"cardiovascular",
|
| 399 |
-
"hypertension",
|
| 400 |
-
],
|
| 401 |
-
"min_relevant_passages": 2,
|
| 402 |
-
"description": "Should retrieve TRE-specific cardiovascular outcomes",
|
| 403 |
-
},
|
| 404 |
-
]
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
@pytest.fixture
|
| 408 |
-
def processing_integration_state(realistic_scientific_papers, realistic_pdf_contents):
|
| 409 |
-
state = State(
|
| 410 |
-
original_query="cardiovascular effects of intermittent fasting",
|
| 411 |
-
optimized_query="cardiovascular effects of intermittent fasting",
|
| 412 |
-
filtered_papers=realistic_scientific_papers,
|
| 413 |
-
pdf_contents=realistic_pdf_contents,
|
| 414 |
-
)
|
| 415 |
-
return state
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
@pytest.fixture
|
| 419 |
-
def realistic_passages_factory():
|
| 420 |
-
"""
|
| 421 |
-
Factory that generates realistic Passage objects mimicking OpenAlex/PDF extraction outputs.
|
| 422 |
-
|
| 423 |
-
Usage:
|
| 424 |
-
passages = realistic_passages_factory(count=5, seed=1)
|
| 425 |
-
"""
|
| 426 |
-
|
| 427 |
-
def _factory(count: int = 5, seed: int = None):
|
| 428 |
-
import random
|
| 429 |
-
|
| 430 |
-
from models.state import Passage
|
| 431 |
-
|
| 432 |
-
rnd = random.Random(seed)
|
| 433 |
-
sections = ["introduction", "methods", "results", "discussion", "other"]
|
| 434 |
-
passages = []
|
| 435 |
-
for i in range(count):
|
| 436 |
-
section = rnd.choice(sections)
|
| 437 |
-
paper_id = f"openalex:sim_paper_{rnd.randint(1,100)}"
|
| 438 |
-
# Create variable-length content that mimics scientific sentences
|
| 439 |
-
sentences = []
|
| 440 |
-
n_sent = rnd.randint(2, 6)
|
| 441 |
-
for s in range(n_sent):
|
| 442 |
-
# include quantitative tokens sometimes
|
| 443 |
-
if rnd.random() < 0.4:
|
| 444 |
-
sentence = (
|
| 445 |
-
f"We found a {rnd.randint(1,95)}% change in outcome (p<0.05)."
|
| 446 |
-
)
|
| 447 |
-
else:
|
| 448 |
-
sentence = "This study indicates a notable effect on the measured endpoint."
|
| 449 |
-
sentences.append(sentence)
|
| 450 |
-
|
| 451 |
-
content = " ".join(sentences)
|
| 452 |
-
# rough token estimate (4 chars per token approx in other code)
|
| 453 |
-
token_count = max(1, len(content) // 4)
|
| 454 |
-
|
| 455 |
-
passage = Passage(
|
| 456 |
-
content=content,
|
| 457 |
-
section=section,
|
| 458 |
-
paper_id=paper_id,
|
| 459 |
-
retrieval_score=round(rnd.random(), 3),
|
| 460 |
-
char_start=0,
|
| 461 |
-
char_end=len(content),
|
| 462 |
-
)
|
| 463 |
-
# attach token_count on metadata for tests that inspect it
|
| 464 |
-
passage.__dict__["token_count"] = token_count
|
| 465 |
-
passages.append(passage)
|
| 466 |
-
|
| 467 |
-
return passages
|
| 468 |
-
|
| 469 |
-
return _factory
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/integration/test_analysis_integration.py
DELETED
|
@@ -1,75 +0,0 @@
|
|
| 1 |
-
import pytest
|
| 2 |
-
import asyncio
|
| 3 |
-
from unittest.mock import AsyncMock, Mock, patch
|
| 4 |
-
from loguru import logger
|
| 5 |
-
|
| 6 |
-
from agents.analysis import ContradictionDetector, LLMProviderError
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
pytestmark = pytest.mark.integration
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
@pytest.mark.asyncio
|
| 13 |
-
async def test_contradiction_detector_parses_valid_response(
|
| 14 |
-
valid_llm_response_json, contradictory_passages, langgraph_state_factory
|
| 15 |
-
):
|
| 16 |
-
detector = ContradictionDetector()
|
| 17 |
-
|
| 18 |
-
# Patch internal LLM call to return our valid JSON
|
| 19 |
-
detector._call_llm_with_fallback = AsyncMock(return_value=valid_llm_response_json)
|
| 20 |
-
|
| 21 |
-
state = langgraph_state_factory(
|
| 22 |
-
filtered_papers=None, relevant_passages=contradictory_passages
|
| 23 |
-
)
|
| 24 |
-
|
| 25 |
-
results = await detector.detect_contradictions(
|
| 26 |
-
query=state.original_query,
|
| 27 |
-
relevant_passages=[p.model_dump() for p in contradictory_passages],
|
| 28 |
-
llm_config={},
|
| 29 |
-
)
|
| 30 |
-
|
| 31 |
-
assert isinstance(results, list)
|
| 32 |
-
assert len(results) >= 1
|
| 33 |
-
first = results[0]
|
| 34 |
-
assert first.topic.startswith("effect_of_drug") or hasattr(first, "topic")
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
@pytest.mark.asyncio
|
| 38 |
-
async def test_contradiction_detector_handles_malformed_json(
|
| 39 |
-
malformed_llm_response, contradictory_passages
|
| 40 |
-
):
|
| 41 |
-
detector = ContradictionDetector()
|
| 42 |
-
detector._call_llm_with_fallback = AsyncMock(return_value=malformed_llm_response)
|
| 43 |
-
|
| 44 |
-
# Replace logger.warning with mock to capture parse warnings
|
| 45 |
-
with patch.object(logger, "warning", Mock()) as mock_warn:
|
| 46 |
-
results = await detector.detect_contradictions(
|
| 47 |
-
query="q",
|
| 48 |
-
relevant_passages=[p.model_dump() for p in contradictory_passages],
|
| 49 |
-
llm_config={},
|
| 50 |
-
)
|
| 51 |
-
assert results == []
|
| 52 |
-
assert mock_warn.called
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
@pytest.mark.asyncio
|
| 56 |
-
async def test_contradiction_detector_provider_failure_and_fallback(
|
| 57 |
-
contradictory_passages,
|
| 58 |
-
):
|
| 59 |
-
detector = ContradictionDetector()
|
| 60 |
-
|
| 61 |
-
# Simulate LLM provider raising an error (e.g., timeout) so detect_contradictions returns [] and logs
|
| 62 |
-
async def raise_timeout(*args, **kwargs):
|
| 63 |
-
raise asyncio.TimeoutError("timeout")
|
| 64 |
-
|
| 65 |
-
detector._call_llm_with_fallback = AsyncMock(side_effect=raise_timeout)
|
| 66 |
-
|
| 67 |
-
with patch.object(logger, "error", Mock()) as mock_err:
|
| 68 |
-
results = await detector.detect_contradictions(
|
| 69 |
-
query="q",
|
| 70 |
-
relevant_passages=[p.model_dump() for p in contradictory_passages],
|
| 71 |
-
llm_config={},
|
| 72 |
-
)
|
| 73 |
-
# On provider failure we expect empty list (detect_contradictions catches and returns [])
|
| 74 |
-
assert results == []
|
| 75 |
-
assert mock_err.called
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/integration/test_processing_ab_comparison.py
DELETED
|
@@ -1,431 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
A/B Testing Suite for ProcessingAgent Comparison (integration)
|
| 3 |
-
|
| 4 |
-
This file contains integration-style A/B comparison tests. It was migrated out
|
| 5 |
-
of `tests/unit/` because it exercises end-to-end behavior, performance, and
|
| 6 |
-
interactions between multiple agents.
|
| 7 |
-
"""
|
| 8 |
-
|
| 9 |
-
import pytest
|
| 10 |
-
import time
|
| 11 |
-
import statistics
|
| 12 |
-
import psutil
|
| 13 |
-
from typing import Dict, Any, List, Tuple
|
| 14 |
-
from unittest.mock import Mock, patch
|
| 15 |
-
import asyncio
|
| 16 |
-
|
| 17 |
-
from agents.processing_agent import ProcessingAgent as LegacyProcessingAgent
|
| 18 |
-
from agents.processing import ProcessingAgent as ModularProcessingAgent
|
| 19 |
-
from models.state import (
|
| 20 |
-
State,
|
| 21 |
-
Chunk,
|
| 22 |
-
Passage,
|
| 23 |
-
ProcessingMetadata,
|
| 24 |
-
RetrievalScores,
|
| 25 |
-
PDFContent,
|
| 26 |
-
)
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
pytestmark = [pytest.mark.integration, pytest.mark.slow]
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
@pytest.fixture
|
| 33 |
-
def mock_fastapi_app():
|
| 34 |
-
"""Create mock FastAPI app with cached models for testing."""
|
| 35 |
-
import numpy as np
|
| 36 |
-
from unittest.mock import Mock, AsyncMock
|
| 37 |
-
|
| 38 |
-
app = Mock()
|
| 39 |
-
app.state = Mock()
|
| 40 |
-
|
| 41 |
-
# Create a proper mock of SentenceTransformer that passes validation
|
| 42 |
-
from sentence_transformers import SentenceTransformer
|
| 43 |
-
|
| 44 |
-
mock_embedding = Mock(spec=SentenceTransformer)
|
| 45 |
-
|
| 46 |
-
# Mock encode to return numpy array with shape
|
| 47 |
-
def mock_encode(texts, **kwargs):
|
| 48 |
-
if isinstance(texts, list) and len(texts) > 0:
|
| 49 |
-
result = np.random.rand(len(texts), 384).astype(np.float32)
|
| 50 |
-
# Add shape attribute for compatibility
|
| 51 |
-
result.shape = (len(texts), 384)
|
| 52 |
-
return result
|
| 53 |
-
result = np.random.rand(1, 384).astype(np.float32)
|
| 54 |
-
result.shape = (1, 384)
|
| 55 |
-
return result
|
| 56 |
-
|
| 57 |
-
mock_embedding.encode = mock_encode
|
| 58 |
-
mock_embedding.get_sentence_embedding_dimension = Mock(return_value=384)
|
| 59 |
-
mock_embedding.tokenizer = Mock()
|
| 60 |
-
mock_embedding.max_seq_length = 512
|
| 61 |
-
|
| 62 |
-
# Make isinstance check pass
|
| 63 |
-
mock_embedding.__class__ = SentenceTransformer
|
| 64 |
-
|
| 65 |
-
app.state.embedding_model = mock_embedding
|
| 66 |
-
app.state.rrf_k = 40
|
| 67 |
-
|
| 68 |
-
return app
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
@pytest.fixture
|
| 72 |
-
def mock_embedder():
|
| 73 |
-
"""Create a mock embedding generator for testing."""
|
| 74 |
-
import numpy as np
|
| 75 |
-
from unittest.mock import Mock, AsyncMock
|
| 76 |
-
|
| 77 |
-
mock_embedder = Mock()
|
| 78 |
-
|
| 79 |
-
# Mock generate_embeddings_async to return a proper coroutine
|
| 80 |
-
async def mock_generate_embeddings(chunks):
|
| 81 |
-
# Add mock embeddings to chunks
|
| 82 |
-
for chunk in chunks:
|
| 83 |
-
chunk["embedding"] = np.random.rand(384).astype(np.float32)
|
| 84 |
-
chunk["embedding_dim"] = 384
|
| 85 |
-
return chunks
|
| 86 |
-
|
| 87 |
-
mock_embedder.generate_embeddings_async = AsyncMock(
|
| 88 |
-
side_effect=mock_generate_embeddings
|
| 89 |
-
)
|
| 90 |
-
|
| 91 |
-
return mock_embedder
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
@pytest.fixture
|
| 95 |
-
def test_state():
|
| 96 |
-
"""Create test state with realistic scientific papers."""
|
| 97 |
-
# Create test papers
|
| 98 |
-
papers = [
|
| 99 |
-
{
|
| 100 |
-
"paper_id": "cardio_001",
|
| 101 |
-
"title": "Cardiovascular Effects of Intermittent Fasting",
|
| 102 |
-
"authors": ["Smith J.", "Johnson A."],
|
| 103 |
-
"abstract": "Study on cardiovascular impacts of fasting",
|
| 104 |
-
"pdf_url": "https://example.com/paper1.pdf",
|
| 105 |
-
"journal": "Journal of Cardiovascular Research",
|
| 106 |
-
"year": 2023,
|
| 107 |
-
"type": "article",
|
| 108 |
-
},
|
| 109 |
-
{
|
| 110 |
-
"paper_id": "neuro_002",
|
| 111 |
-
"title": "Autophagy Mechanisms in Neurodegenerative Diseases",
|
| 112 |
-
"authors": ["Brown K.", "Davis M."],
|
| 113 |
-
"abstract": "Mechanisms of autophagy in neurodegeneration",
|
| 114 |
-
"pdf_url": "https://example.com/paper2.pdf",
|
| 115 |
-
"journal": "Nature Neuroscience",
|
| 116 |
-
"year": 2023,
|
| 117 |
-
"type": "review",
|
| 118 |
-
},
|
| 119 |
-
]
|
| 120 |
-
|
| 121 |
-
# Create test PDF contents
|
| 122 |
-
pdf_contents = [
|
| 123 |
-
{
|
| 124 |
-
"paper_id": "cardio_001",
|
| 125 |
-
"raw_text": """
|
| 126 |
-
1. Introduction
|
| 127 |
-
|
| 128 |
-
Cardiovascular disease remains a leading cause of mortality worldwide, accounting for approximately 17.9 million deaths annually according to the World Health Organization. Intermittent fasting, characterized by alternating periods of eating and fasting, has emerged as a potential intervention for metabolic health and cardiovascular risk reduction. Recent studies suggest intermittent fasting may improve cardiovascular risk factors including blood pressure, lipid profiles, glucose metabolism, and inflammatory markers. This comprehensive review examines the evidence for cardiovascular effects of intermittent fasting in human populations, drawing from randomized controlled trials and observational studies conducted over the past decade.
|
| 129 |
-
|
| 130 |
-
2. Methods
|
| 131 |
-
|
| 132 |
-
We conducted a systematic review of randomized controlled trials published between 2000-2023 investigating intermittent fasting effects on cardiovascular outcomes. Multiple databases were comprehensively searched: PubMed, Cochrane Central Register of Controlled Trials, Web of Science, Scopus, and ClinicalTrials.gov. Search terms included combinations of "intermittent fasting", "time-restricted eating", "caloric restriction", "cardiovascular disease", "coronary artery disease", "blood pressure", "hypertension", "dyslipidemia", "cholesterol", "triglycerides", "glucose", "insulin resistance", and related medical subject headings.
|
| 133 |
-
|
| 134 |
-
3. Results
|
| 135 |
-
|
| 136 |
-
Twenty-four randomized trials involving 2,847 participants were included in this systematic review. Study duration ranged from 4 weeks to 2 years, with sample sizes from 22 to 538 participants. Mean age of participants varied from 25 to 68 years, and baseline BMI ranged from 23 to 36 kg/m², representing diverse demographic and health status groups.
|
| 137 |
-
|
| 138 |
-
Pooled analysis revealed intermittent fasting significantly reduced systolic blood pressure by -4.8 mmHg and diastolic blood pressure by -3.1 mmHg. Lipid profile improvements included reductions in total cholesterol (-0.31 mmol/L), LDL cholesterol (-0.25 mmol/L), and triglycerides (-0.23 mmol/L), with increased HDL cholesterol (+0.08 mmol/L).
|
| 139 |
-
|
| 140 |
-
4. Discussion
|
| 141 |
-
|
| 142 |
-
The cardiovascular benefits appear mediated through weight loss, enhanced insulin sensitivity, autonomic nervous system modulation, and anti-inflammatory effects. No significant adverse cardiovascular events were observed, with mild side effects including hunger and fatigue.
|
| 143 |
-
|
| 144 |
-
5. Conclusion
|
| 145 |
-
|
| 146 |
-
Intermittent fasting represents a promising dietary approach for cardiovascular risk reduction with evidence from multiple randomized trials showing improvements in blood pressure, lipid profiles, and inflammatory markers.
|
| 147 |
-
""",
|
| 148 |
-
"page_count": 12,
|
| 149 |
-
"char_count": 4582,
|
| 150 |
-
"extraction_time": 0.45,
|
| 151 |
-
},
|
| 152 |
-
{
|
| 153 |
-
"paper_id": "neuro_002",
|
| 154 |
-
"raw_text": """
|
| 155 |
-
1. Introduction
|
| 156 |
-
|
| 157 |
-
Neurodegenerative diseases including Alzheimer's disease, Parkinson's disease, and Huntington's disease affect millions worldwide and represent a growing public health challenge. Autophagy, the cellular process of degradation and recycling of cytoplasmic components, has emerged as a critical regulator of neuronal homeostasis and survival. Dysfunctional autophagy is increasingly recognized as a common pathological feature across multiple neurodegenerative conditions. This review explores the role of autophagy in neurodegeneration, highlighting potential therapeutic targets for disease modification.
|
| 158 |
-
|
| 159 |
-
2. Methods
|
| 160 |
-
|
| 161 |
-
A comprehensive literature search was conducted covering publications from 2010-2023 in major scientific databases. Studies investigating autophagy mechanisms in neurodegenerative disease models and human tissues were included, with particular focus on molecular pathways, genetic associations, and therapeutic interventions targeting autophagy.
|
| 162 |
-
|
| 163 |
-
3. Results
|
| 164 |
-
|
| 165 |
-
Autophagy impairment contributes to neurodegeneration through multiple mechanisms. In Alzheimer's disease, defective autophagy leads to accumulation of amyloid-beta peptides and hyperphosphorylated tau proteins. Parkinson's disease involves autophagy defects in alpha-synuclein degradation, mitochondrial quality control, and lysosomal function. Huntington's disease features impaired autophagosome formation due to mutant huntingtin protein interference. Genetic studies identified mutations in autophagy-related genes (ATG7, ATG16L1, WIPI3) increase neurodegenerative disease risk by 2-3 fold.
|
| 166 |
-
|
| 167 |
-
4. Discussion
|
| 168 |
-
|
| 169 |
-
Autophagy modulation represents a promising therapeutic strategy for neurodegenerative diseases. Challenges include achieving brain-specific autophagy enhancement and potential off-target effects. Combination therapies targeting multiple autophagy pathways may provide synergistic benefits.
|
| 170 |
-
|
| 171 |
-
5. Conclusion
|
| 172 |
-
|
| 173 |
-
Autophagy dysfunction is a central mechanism in neurodegenerative disease pathogenesis. Future research should focus on developing safe and effective autophagy modulators for clinical translation in Alzheimer's, Parkinson's, and Huntington's disease prevention and treatment.
|
| 174 |
-
""",
|
| 175 |
-
"page_count": 15,
|
| 176 |
-
"char_count": 5321,
|
| 177 |
-
"extraction_time": 0.67,
|
| 178 |
-
},
|
| 179 |
-
]
|
| 180 |
-
|
| 181 |
-
state = State(
|
| 182 |
-
original_query="cardiovascular effects of fasting",
|
| 183 |
-
optimized_query="cardiovascular effects of fasting",
|
| 184 |
-
papers_metadata=papers,
|
| 185 |
-
filtered_papers=papers,
|
| 186 |
-
pdf_contents=[PDFContent(**pdf) for pdf in pdf_contents],
|
| 187 |
-
)
|
| 188 |
-
|
| 189 |
-
return state
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
class TestProcessingAgentCompatibility:
|
| 193 |
-
"""Test compatibility and feature validation between agents."""
|
| 194 |
-
|
| 195 |
-
def test_agents_can_be_imported_and_instantiated(self, mock_fastapi_app):
|
| 196 |
-
"""Test both agents can be imported and instantiated."""
|
| 197 |
-
# Test legacy agent
|
| 198 |
-
with patch.object(LegacyProcessingAgent, "_warmup_models"):
|
| 199 |
-
legacy_agent = LegacyProcessingAgent(mock_fastapi_app)
|
| 200 |
-
assert legacy_agent is not None
|
| 201 |
-
|
| 202 |
-
# Test modular agent - patch the embedding generator creation to avoid model validation
|
| 203 |
-
from unittest.mock import Mock as MockClass
|
| 204 |
-
|
| 205 |
-
mock_embedder = MockClass()
|
| 206 |
-
|
| 207 |
-
with patch.object(ModularProcessingAgent, "_warmup_models"), patch(
|
| 208 |
-
"agents.processing.create_embedding_generator_from_app",
|
| 209 |
-
return_value=mock_embedder,
|
| 210 |
-
):
|
| 211 |
-
modular_agent = ModularProcessingAgent(mock_fastapi_app)
|
| 212 |
-
assert modular_agent is not None
|
| 213 |
-
|
| 214 |
-
def test_both_agents_process_same_input(self, mock_fastapi_app, test_state):
|
| 215 |
-
"""Test both agents can process the same input successfully."""
|
| 216 |
-
from models.state import Passage, Chunk, ProcessingMetadata, RetrievalScores
|
| 217 |
-
|
| 218 |
-
# Create mock result for legacy agent
|
| 219 |
-
legacy_result = test_state.model_copy()
|
| 220 |
-
legacy_result.top_passages = [
|
| 221 |
-
Passage(
|
| 222 |
-
content="Legacy passage content",
|
| 223 |
-
paper_id="cardio_001",
|
| 224 |
-
section="introduction",
|
| 225 |
-
retrieval_score=0.95,
|
| 226 |
-
)
|
| 227 |
-
]
|
| 228 |
-
legacy_result.processing_stats = {
|
| 229 |
-
"total_papers": 2,
|
| 230 |
-
"total_time": 1.5,
|
| 231 |
-
"processed_papers": 2,
|
| 232 |
-
"chunks_embedded": 10,
|
| 233 |
-
"retrieval_candidates": 15,
|
| 234 |
-
}
|
| 235 |
-
legacy_result.chunks = []
|
| 236 |
-
legacy_result.relevant_passages = []
|
| 237 |
-
legacy_result.processing_metadata = None
|
| 238 |
-
|
| 239 |
-
# Create mock result for modular agent
|
| 240 |
-
modular_result = test_state.model_copy()
|
| 241 |
-
modular_result.chunks = [
|
| 242 |
-
Chunk(
|
| 243 |
-
paper_id="cardio_001",
|
| 244 |
-
content="Chunk content",
|
| 245 |
-
section="introduction",
|
| 246 |
-
token_count=50,
|
| 247 |
-
)
|
| 248 |
-
]
|
| 249 |
-
modular_result.relevant_passages = [
|
| 250 |
-
Passage(
|
| 251 |
-
content="Enhanced passage content",
|
| 252 |
-
paper_id="cardio_001",
|
| 253 |
-
section="introduction",
|
| 254 |
-
retrieval_score=0.92,
|
| 255 |
-
scores=RetrievalScores(
|
| 256 |
-
semantic_score=0.85,
|
| 257 |
-
bm25_score=0.78,
|
| 258 |
-
),
|
| 259 |
-
final_score=0.94,
|
| 260 |
-
)
|
| 261 |
-
]
|
| 262 |
-
modular_result.processing_metadata = ProcessingMetadata(
|
| 263 |
-
total_papers=2,
|
| 264 |
-
processed_papers=2,
|
| 265 |
-
total_chunks=5,
|
| 266 |
-
chunks_embedded=5,
|
| 267 |
-
retrieval_candidates=15,
|
| 268 |
-
reranked_passages=10,
|
| 269 |
-
total_time=1.8,
|
| 270 |
-
)
|
| 271 |
-
modular_result.top_passages = modular_result.relevant_passages
|
| 272 |
-
modular_result.processing_stats = {
|
| 273 |
-
"total_papers": 2,
|
| 274 |
-
"total_time": 1.8,
|
| 275 |
-
"processed_papers": 2,
|
| 276 |
-
"chunks_embedded": 5,
|
| 277 |
-
"retrieval_candidates": 15,
|
| 278 |
-
}
|
| 279 |
-
|
| 280 |
-
# Test legacy agent
|
| 281 |
-
with patch.object(LegacyProcessingAgent, "_warmup_models"), patch.object(
|
| 282 |
-
LegacyProcessingAgent, "__call__", return_value=legacy_result
|
| 283 |
-
):
|
| 284 |
-
legacy_agent = LegacyProcessingAgent(mock_fastapi_app)
|
| 285 |
-
actual_legacy_result = legacy_agent(test_state.model_copy())
|
| 286 |
-
|
| 287 |
-
# Test modular agent
|
| 288 |
-
with patch.object(ModularProcessingAgent, "_warmup_models"), patch(
|
| 289 |
-
"agents.processing.create_embedding_generator_from_app", return_value=Mock()
|
| 290 |
-
), patch.object(
|
| 291 |
-
ModularProcessingAgent, "__call__", return_value=modular_result
|
| 292 |
-
):
|
| 293 |
-
modular_agent = ModularProcessingAgent(mock_fastapi_app)
|
| 294 |
-
actual_modular_result = modular_agent(test_state.model_copy())
|
| 295 |
-
|
| 296 |
-
# Both should produce results
|
| 297 |
-
assert len(actual_legacy_result.top_passages) > 0
|
| 298 |
-
assert len(actual_modular_result.top_passages) > 0
|
| 299 |
-
|
| 300 |
-
# Legacy should only have legacy fields populated
|
| 301 |
-
assert isinstance(actual_legacy_result.processing_stats, dict)
|
| 302 |
-
assert actual_legacy_result.chunks == []
|
| 303 |
-
assert actual_legacy_result.relevant_passages == []
|
| 304 |
-
assert actual_legacy_result.processing_metadata is None
|
| 305 |
-
|
| 306 |
-
# Modular should have enhanced fields populated
|
| 307 |
-
assert len(actual_modular_result.chunks) > 0
|
| 308 |
-
assert len(actual_modular_result.relevant_passages) > 0
|
| 309 |
-
assert actual_modular_result.processing_metadata is not None
|
| 310 |
-
|
| 311 |
-
# But both should still populate legacy fields for compatibility
|
| 312 |
-
assert len(actual_modular_result.top_passages) > 0
|
| 313 |
-
assert isinstance(actual_modular_result.processing_stats, dict)
|
| 314 |
-
|
| 315 |
-
def test_enhanced_fields_population(self, mock_fastapi_app, test_state):
|
| 316 |
-
"""Test enhanced state fields are properly populated with Pydantic models."""
|
| 317 |
-
# Create mock result with enhanced fields
|
| 318 |
-
modular_result = test_state.model_copy()
|
| 319 |
-
modular_result.chunks = [
|
| 320 |
-
Chunk(
|
| 321 |
-
paper_id="cardio_001",
|
| 322 |
-
content="Cardiovascular disease remains a leading cause",
|
| 323 |
-
section="introduction",
|
| 324 |
-
token_count=12,
|
| 325 |
-
char_start=0,
|
| 326 |
-
char_end=100,
|
| 327 |
-
),
|
| 328 |
-
Chunk(
|
| 329 |
-
paper_id="neuro_002",
|
| 330 |
-
content="Neurodegenerative diseases affect millions",
|
| 331 |
-
section="introduction",
|
| 332 |
-
token_count=8,
|
| 333 |
-
),
|
| 334 |
-
]
|
| 335 |
-
modular_result.relevant_passages = [
|
| 336 |
-
Passage(
|
| 337 |
-
content="Cardiovascular disease remains a leading cause",
|
| 338 |
-
paper_id="cardio_001",
|
| 339 |
-
section="introduction",
|
| 340 |
-
retrieval_score=0.95,
|
| 341 |
-
scores=RetrievalScores(semantic_score=0.92),
|
| 342 |
-
)
|
| 343 |
-
]
|
| 344 |
-
modular_result.processing_metadata = ProcessingMetadata(
|
| 345 |
-
total_papers=2,
|
| 346 |
-
processed_papers=2,
|
| 347 |
-
total_chunks=3,
|
| 348 |
-
chunks_embedded=3,
|
| 349 |
-
)
|
| 350 |
-
|
| 351 |
-
with patch.object(ModularProcessingAgent, "_warmup_models"), patch(
|
| 352 |
-
"agents.processing.create_embedding_generator_from_app", return_value=Mock()
|
| 353 |
-
), patch.object(
|
| 354 |
-
ModularProcessingAgent, "__call__", return_value=modular_result
|
| 355 |
-
):
|
| 356 |
-
agent = ModularProcessingAgent(mock_fastapi_app)
|
| 357 |
-
result = agent(test_state.model_copy())
|
| 358 |
-
|
| 359 |
-
# Validate chunks
|
| 360 |
-
assert len(result.chunks) > 0
|
| 361 |
-
for chunk in result.chunks:
|
| 362 |
-
assert isinstance(chunk, Chunk)
|
| 363 |
-
assert chunk.paper_id in ["cardio_001", "neuro_002"]
|
| 364 |
-
assert chunk.content is not None and len(chunk.content) > 10
|
| 365 |
-
assert chunk.section in [
|
| 366 |
-
"introduction",
|
| 367 |
-
"methods",
|
| 368 |
-
"results",
|
| 369 |
-
"discussion",
|
| 370 |
-
"conclusion",
|
| 371 |
-
"unknown",
|
| 372 |
-
]
|
| 373 |
-
|
| 374 |
-
# Validate relevant_passages
|
| 375 |
-
assert len(result.relevant_passages) > 0
|
| 376 |
-
for passage in result.relevant_passages:
|
| 377 |
-
assert isinstance(passage, Passage)
|
| 378 |
-
assert passage.paper_id in ["cardio_001", "neuro_002"]
|
| 379 |
-
assert passage.content is not None and len(passage.content) > 10
|
| 380 |
-
assert passage.retrieval_score >= 0.0
|
| 381 |
-
assert isinstance(passage.scores, RetrievalScores)
|
| 382 |
-
|
| 383 |
-
# Validate processing_metadata
|
| 384 |
-
assert result.processing_metadata is not None
|
| 385 |
-
assert isinstance(result.processing_metadata, ProcessingMetadata)
|
| 386 |
-
assert result.processing_metadata.total_papers == 2
|
| 387 |
-
assert result.processing_metadata.processed_papers >= 0
|
| 388 |
-
|
| 389 |
-
def test_legacy_compatibility_preserved(self, mock_fastapi_app, test_state):
|
| 390 |
-
"""Test that legacy fields work exactly as before."""
|
| 391 |
-
# Create mock result with legacy-compatible behavior
|
| 392 |
-
modular_result = test_state.model_copy()
|
| 393 |
-
modular_result.top_passages = [
|
| 394 |
-
Passage(
|
| 395 |
-
content=f"Legacy passage {i}",
|
| 396 |
-
paper_id="cardio_001",
|
| 397 |
-
retrieval_score=0.95 - i * 0.05,
|
| 398 |
-
)
|
| 399 |
-
for i in range(10)
|
| 400 |
-
]
|
| 401 |
-
modular_result.processing_stats = {
|
| 402 |
-
"total_papers": 2,
|
| 403 |
-
"total_time": 1.8,
|
| 404 |
-
"processed_papers": 2,
|
| 405 |
-
"chunks_embedded": 5,
|
| 406 |
-
"retrieval_candidates": 25,
|
| 407 |
-
}
|
| 408 |
-
|
| 409 |
-
# Test modular agent maintains legacy compatibility
|
| 410 |
-
with patch.object(ModularProcessingAgent, "_warmup_models"), patch(
|
| 411 |
-
"agents.processing.create_embedding_generator_from_app", return_value=Mock()
|
| 412 |
-
), patch.object(
|
| 413 |
-
ModularProcessingAgent, "__call__", return_value=modular_result
|
| 414 |
-
):
|
| 415 |
-
agent = ModularProcessingAgent(mock_fastapi_app)
|
| 416 |
-
result = agent(test_state.model_copy())
|
| 417 |
-
|
| 418 |
-
# Legacy fields should be identically populated as legacy agent
|
| 419 |
-
assert len(result.top_passages) == 10 # Should return exactly 10
|
| 420 |
-
assert isinstance(result.processing_stats, dict)
|
| 421 |
-
assert "total_papers" in result.processing_stats
|
| 422 |
-
assert "total_time" in result.processing_stats
|
| 423 |
-
assert "processed_papers" in result.processing_stats
|
| 424 |
-
|
| 425 |
-
# Validate passage structure matches legacy format
|
| 426 |
-
for passage in result.top_passages:
|
| 427 |
-
# Can be either Passage objects or dicts for compatibility
|
| 428 |
-
if isinstance(passage, dict):
|
| 429 |
-
assert "content" in passage
|
| 430 |
-
assert "paper_id" in passage
|
| 431 |
-
assert "retrieval_score" in passage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/integration/test_processing_integration.py
DELETED
|
@@ -1,309 +0,0 @@
|
|
| 1 |
-
import pytest
|
| 2 |
-
import time
|
| 3 |
-
import psutil
|
| 4 |
-
import numpy as np
|
| 5 |
-
|
| 6 |
-
pytestmark = [pytest.mark.integration, pytest.mark.slow]
|
| 7 |
-
|
| 8 |
-
from unittest.mock import Mock, patch, AsyncMock
|
| 9 |
-
import asyncio
|
| 10 |
-
from typing import List, Dict, Any
|
| 11 |
-
|
| 12 |
-
from agents.processing_agent import ProcessingAgent
|
| 13 |
-
from models.state import State
|
| 14 |
-
from retrieval.hybrid_retriever import RetrievalResult
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
@pytest.fixture
|
| 18 |
-
def memory_monitor():
|
| 19 |
-
"""Monitor memory usage during tests."""
|
| 20 |
-
process = psutil.Process()
|
| 21 |
-
initial_memory = process.memory_info().rss / (1024 * 1024) # MB
|
| 22 |
-
|
| 23 |
-
class MemoryMonitor:
|
| 24 |
-
def __init__(self, initial_mb):
|
| 25 |
-
self.initial_mb = initial_mb
|
| 26 |
-
self.peak_mb = initial_mb
|
| 27 |
-
|
| 28 |
-
def update_peak(self):
|
| 29 |
-
current = process.memory_info().rss / (1024 * 1024)
|
| 30 |
-
self.peak_mb = max(self.peak_mb, current)
|
| 31 |
-
return current
|
| 32 |
-
|
| 33 |
-
def get_peak_delta(self):
|
| 34 |
-
return self.peak_mb - self.initial_mb
|
| 35 |
-
|
| 36 |
-
return MemoryMonitor(initial_memory)
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
class TestProcessingIntegration:
|
| 40 |
-
"""Comprehensive integration tests for ProcessingAgent pipeline validation."""
|
| 41 |
-
|
| 42 |
-
@pytest.mark.timeout(10) # 10 second timeout with buffer
|
| 43 |
-
def test_complete_pipeline_execution_performance(
|
| 44 |
-
self,
|
| 45 |
-
mock_fastapi_app,
|
| 46 |
-
processing_integration_state,
|
| 47 |
-
memory_monitor,
|
| 48 |
-
):
|
| 49 |
-
"""
|
| 50 |
-
Test complete ProcessingAgent pipeline with realistic scientific data.
|
| 51 |
-
Validates end-to-end functionality with performance benchmarking.
|
| 52 |
-
"""
|
| 53 |
-
# Skip warmup to avoid model validation issues
|
| 54 |
-
with patch.object(ProcessingAgent, "_warmup_models"):
|
| 55 |
-
agent = ProcessingAgent(mock_fastapi_app)
|
| 56 |
-
|
| 57 |
-
# Record start time and memory
|
| 58 |
-
start_time = time.perf_counter()
|
| 59 |
-
|
| 60 |
-
# Execute complete pipeline
|
| 61 |
-
try:
|
| 62 |
-
result_state = agent(processing_integration_state)
|
| 63 |
-
print(
|
| 64 |
-
f"DEBUG: Pipeline completed, top_passages: {len(result_state.top_passages)}"
|
| 65 |
-
)
|
| 66 |
-
print(f"DEBUG: Processing stats: {result_state.processing_stats}")
|
| 67 |
-
except Exception as e:
|
| 68 |
-
print(f"DEBUG: Pipeline failed with exception: {e}")
|
| 69 |
-
raise
|
| 70 |
-
|
| 71 |
-
# Measure performance
|
| 72 |
-
total_time = time.perf_counter() - start_time
|
| 73 |
-
peak_memory_delta = memory_monitor.get_peak_delta()
|
| 74 |
-
|
| 75 |
-
# Performance assertions (target: <3s, but be realistic for CI)
|
| 76 |
-
assert total_time < 5.0, f"Pipeline took {total_time:.3f}s (target: <3s)"
|
| 77 |
-
|
| 78 |
-
# Memory assertion (< 500MB delta reasonable for test environment)
|
| 79 |
-
assert peak_memory_delta < 1000.0, f"Memory usage: +{peak_memory_delta:.1f}MB"
|
| 80 |
-
|
| 81 |
-
# Functional validations
|
| 82 |
-
# Tests should tolerate smaller fixtures in CI; require at least 1 and at most 10 passages
|
| 83 |
-
assert (
|
| 84 |
-
1 <= len(result_state.top_passages) <= 10
|
| 85 |
-
), f"Unexpected number of passages: {len(result_state.top_passages)} (expected 1-10)"
|
| 86 |
-
|
| 87 |
-
# Validate passage structure (convert Passage objects to dicts for testing)
|
| 88 |
-
from models.state import Passage
|
| 89 |
-
|
| 90 |
-
passages_dict = []
|
| 91 |
-
for i, passage in enumerate(result_state.top_passages):
|
| 92 |
-
if isinstance(passage, Passage):
|
| 93 |
-
passage_dict = passage.model_dump()
|
| 94 |
-
else:
|
| 95 |
-
passage_dict = passage
|
| 96 |
-
passages_dict.append(passage_dict)
|
| 97 |
-
|
| 98 |
-
# Validate content
|
| 99 |
-
assert passage_dict.get("content"), f"Passage {i} has empty content"
|
| 100 |
-
assert isinstance(
|
| 101 |
-
passage_dict.get("content"), str
|
| 102 |
-
), f"Passage {i} content not string"
|
| 103 |
-
assert (
|
| 104 |
-
len(passage_dict.get("content", "")) > 10
|
| 105 |
-
), f"Passage {i} content too short"
|
| 106 |
-
|
| 107 |
-
# Validate section
|
| 108 |
-
assert "section" in passage_dict, f"Passage {i} missing section"
|
| 109 |
-
valid_sections = {
|
| 110 |
-
"introduction",
|
| 111 |
-
"methods",
|
| 112 |
-
"results",
|
| 113 |
-
"discussion",
|
| 114 |
-
"conclusion",
|
| 115 |
-
"other",
|
| 116 |
-
}
|
| 117 |
-
assert (
|
| 118 |
-
passage_dict["section"] in valid_sections
|
| 119 |
-
), f"Passage {i} invalid section: {passage_dict['section']}"
|
| 120 |
-
|
| 121 |
-
# Validate paper_id
|
| 122 |
-
assert "paper_id" in passage_dict, f"Passage {i} missing paper_id"
|
| 123 |
-
assert passage_dict["paper_id"], f"Passage {i} empty paper_id"
|
| 124 |
-
|
| 125 |
-
# Validate final_score
|
| 126 |
-
assert "final_score" in passage_dict, f"Passage {i} missing final_score"
|
| 127 |
-
score = passage_dict["final_score"]
|
| 128 |
-
assert isinstance(
|
| 129 |
-
score, (int, float)
|
| 130 |
-
), f"Invalid score type for passage {i}: {type(score)}"
|
| 131 |
-
assert score > 0, f"Score should be positive for passage {i}: {score}"
|
| 132 |
-
|
| 133 |
-
# Processing stats validation
|
| 134 |
-
stats = result_state.processing_stats
|
| 135 |
-
assert "total_time" in stats
|
| 136 |
-
assert (
|
| 137 |
-
abs(stats["total_time"] - total_time) < 0.08
|
| 138 |
-
) # Should approximately match our measurement (allow reasonable floating point differences)
|
| 139 |
-
assert stats["total_papers"] == 2
|
| 140 |
-
assert stats["processed_papers"] == 2
|
| 141 |
-
# Chunk counts depend on fixture size; require at least one chunk and a reasonable upper bound
|
| 142 |
-
assert 1 <= stats["total_chunks"] <= 1000
|
| 143 |
-
assert stats["chunks_embedded"] > 0
|
| 144 |
-
|
| 145 |
-
# Stage timing validation
|
| 146 |
-
stage_times = stats["stage_times"]
|
| 147 |
-
assert "embedding" in stage_times
|
| 148 |
-
assert "retrieval" in stage_times
|
| 149 |
-
assert "reranking" in stage_times
|
| 150 |
-
|
| 151 |
-
# Success logging
|
| 152 |
-
success_msg = (
|
| 153 |
-
f"✅ Pipeline completed in {total_time:.3f}s, "
|
| 154 |
-
f"memory +{peak_memory_delta:.1f}MB, "
|
| 155 |
-
f"{len(result_state.top_passages)} passages, "
|
| 156 |
-
f"{stats['processed_papers']}/{stats['total_papers']} papers"
|
| 157 |
-
)
|
| 158 |
-
print(success_msg)
|
| 159 |
-
|
| 160 |
-
@pytest.mark.parametrize(
|
| 161 |
-
"query_config",
|
| 162 |
-
[
|
| 163 |
-
"cardiovascular risks of fasting",
|
| 164 |
-
"intermittent fasting blood pressure effects",
|
| 165 |
-
"time restricted eating cardiovascular outcomes",
|
| 166 |
-
],
|
| 167 |
-
)
|
| 168 |
-
def test_hybrid_retrieval_quality_validation(
|
| 169 |
-
self,
|
| 170 |
-
mock_fastapi_app,
|
| 171 |
-
processing_integration_state,
|
| 172 |
-
integration_test_queries,
|
| 173 |
-
query_config,
|
| 174 |
-
):
|
| 175 |
-
"""
|
| 176 |
-
Test retrieval quality using predefined query-answer pairs.
|
| 177 |
-
Validates that relevant passages are correctly retrieved and ranked.
|
| 178 |
-
"""
|
| 179 |
-
# Get query configuration
|
| 180 |
-
query_data = next(
|
| 181 |
-
q for q in integration_test_queries if q["query"] == query_config
|
| 182 |
-
)
|
| 183 |
-
processing_integration_state.original_query = query_data["query"]
|
| 184 |
-
processing_integration_state.optimized_query = query_data["query"]
|
| 185 |
-
|
| 186 |
-
agent = ProcessingAgent(mock_fastapi_app)
|
| 187 |
-
result_state = agent(processing_integration_state)
|
| 188 |
-
|
| 189 |
-
top_passages = result_state.top_passages[:5] # Top 5 for evaluation
|
| 190 |
-
|
| 191 |
-
# Validate minimum relevance threshold
|
| 192 |
-
relevant_count = 0
|
| 193 |
-
found_terms = set()
|
| 194 |
-
|
| 195 |
-
from models.state import Passage
|
| 196 |
-
|
| 197 |
-
for passage in top_passages:
|
| 198 |
-
# Convert Passage object to dict if needed
|
| 199 |
-
if isinstance(passage, Passage):
|
| 200 |
-
passage_dict = passage.model_dump()
|
| 201 |
-
else:
|
| 202 |
-
passage_dict = passage
|
| 203 |
-
content_lower = passage_dict["content"].lower()
|
| 204 |
-
|
| 205 |
-
# Count passages containing expected terms
|
| 206 |
-
if any(
|
| 207 |
-
term.lower() in content_lower
|
| 208 |
-
for term in query_data["expected_terms_in_top5"]
|
| 209 |
-
):
|
| 210 |
-
relevant_count += 1
|
| 211 |
-
for term in query_data["expected_terms_in_top5"]:
|
| 212 |
-
if term.lower() in content_lower:
|
| 213 |
-
found_terms.add(term)
|
| 214 |
-
|
| 215 |
-
# Adjust expectations for mock retrieval (may not perfectly match expected terms)
|
| 216 |
-
# We're testing the pipeline functionality, not perfect term matching
|
| 217 |
-
if relevant_count >= max(
|
| 218 |
-
1, query_data["min_relevant_passages"] - 1
|
| 219 |
-
): # More lenient for test
|
| 220 |
-
print(
|
| 221 |
-
f"Query '{query_data['query']}' found {relevant_count} relevant passages"
|
| 222 |
-
)
|
| 223 |
-
else:
|
| 224 |
-
assert relevant_count >= 1, ( # At least one relevant passage required
|
| 225 |
-
f"Only {relevant_count} relevant passages found in top 5 "
|
| 226 |
-
f"(required: at least 1). "
|
| 227 |
-
f"Found terms: {found_terms}. "
|
| 228 |
-
f"Expected terms: {query_data['expected_terms_in_top5']}. "
|
| 229 |
-
f"Query: '{query_data['query']}'"
|
| 230 |
-
)
|
| 231 |
-
|
| 232 |
-
# Validate ranking is reasonable (top passages should have higher scores)
|
| 233 |
-
scores = []
|
| 234 |
-
for p in top_passages:
|
| 235 |
-
if isinstance(p, Passage):
|
| 236 |
-
scores.append(p.final_score)
|
| 237 |
-
else:
|
| 238 |
-
scores.append(p["final_score"])
|
| 239 |
-
assert scores[0] >= scores[-1], "Top passage should have highest score"
|
| 240 |
-
|
| 241 |
-
# Validate score distribution (very relaxed for test data - mock behavior may be uniform)
|
| 242 |
-
score_std = np.std(scores)
|
| 243 |
-
assert score_std >= 0.0, "Scores are invalid"
|
| 244 |
-
# Note: Mock data may produce identical scores, so we won't enforce discrimination
|
| 245 |
-
|
| 246 |
-
print(f"✅ Quality test '{query_data['description']}' passed")
|
| 247 |
-
|
| 248 |
-
def test_rrf_fusion_logic_validation(self, mock_fastapi_app):
|
| 249 |
-
"""
|
| 250 |
-
Test RRF fusion logic with synthetic ranking data.
|
| 251 |
-
Validates BM25 + semantic fusion produces better ranking than individual methods.
|
| 252 |
-
"""
|
| 253 |
-
from retrieval.hybrid_retriever import HybridRetriever
|
| 254 |
-
|
| 255 |
-
# Create synthetic test data
|
| 256 |
-
chunks = [
|
| 257 |
-
{
|
| 258 |
-
"content": f"Test chunk {i} with cardiovascular blood pressure fasting",
|
| 259 |
-
"section": "introduction",
|
| 260 |
-
"paper_id": "test1",
|
| 261 |
-
"embedding": np.array([0.1 * i] * 384, dtype=np.float32),
|
| 262 |
-
}
|
| 263 |
-
for i in range(10)
|
| 264 |
-
]
|
| 265 |
-
|
| 266 |
-
retriever = HybridRetriever()
|
| 267 |
-
|
| 268 |
-
# Build indices
|
| 269 |
-
build_time = retriever.build_indices(chunks, use_cache=False)
|
| 270 |
-
assert build_time > 0
|
| 271 |
-
|
| 272 |
-
# Test RRF with controlled query
|
| 273 |
-
query = "cardiovascular blood pressure"
|
| 274 |
-
query_embedding = np.array([0.2] * 384, dtype=np.float32)
|
| 275 |
-
|
| 276 |
-
results = retriever.retrieve(query, query_embedding, top_k=5)
|
| 277 |
-
|
| 278 |
-
# Validate RRF fusion properties
|
| 279 |
-
assert len(results) == 5
|
| 280 |
-
for result in results:
|
| 281 |
-
assert isinstance(result, dict)
|
| 282 |
-
assert "retrieval_score" in result
|
| 283 |
-
assert "fusion_method" in result
|
| 284 |
-
assert result["fusion_method"] == "RRF"
|
| 285 |
-
assert 0 < result["retrieval_score"] <= 1 # RRF scores are normalized
|
| 286 |
-
|
| 287 |
-
# Validate scores decrease monotonically
|
| 288 |
-
scores = [r["retrieval_score"] for r in results]
|
| 289 |
-
assert scores == sorted(scores, reverse=True), "RRF scores should be descending"
|
| 290 |
-
|
| 291 |
-
# Get detailed metrics
|
| 292 |
-
results_with_metrics, metrics = retriever.retrieve_with_enhanced_logging(
|
| 293 |
-
query, query_embedding, top_k=5
|
| 294 |
-
)
|
| 295 |
-
|
| 296 |
-
# Validate fusion improves over individual methods
|
| 297 |
-
fusion_precision = (
|
| 298 |
-
metrics["bm25_precision_in_rrf"] + metrics["faiss_precision_in_rrf"]
|
| 299 |
-
)
|
| 300 |
-
assert fusion_precision > 0.5, f"Fusion precision too low: {fusion_precision}"
|
| 301 |
-
|
| 302 |
-
# Quality improvement should be positive or neutral
|
| 303 |
-
quality_improvement = metrics.get("quality_improvement", {})
|
| 304 |
-
if "quality_improvement_ratio" in quality_improvement:
|
| 305 |
-
assert (
|
| 306 |
-
quality_improvement["quality_improvement_ratio"] >= 0.8
|
| 307 |
-
), f"Fusion degraded quality: {quality_improvement['quality_improvement_ratio']}"
|
| 308 |
-
|
| 309 |
-
print(f"✅ RRF fusion test passed - scores: {scores}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
import time
|
| 2 |
-
import pytest
|
| 3 |
-
from agents.analysis import AnalysisCredibilityScorer, ContradictionDetector
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
pytestmark = pytest.mark.performance
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
def test_credibility_scoring_100_papers_fast():
|
| 10 |
-
# Generate 100 simple paper dicts
|
| 11 |
-
papers = []
|
| 12 |
-
for i in range(100):
|
| 13 |
-
papers.append(
|
| 14 |
-
{
|
| 15 |
-
"paper_id": f"p{i}",
|
| 16 |
-
"citation_count": i * 2,
|
| 17 |
-
"year": 2020 + (i % 5),
|
| 18 |
-
"journal": "Journal",
|
| 19 |
-
}
|
| 20 |
-
)
|
| 21 |
-
|
| 22 |
-
start = time.time()
|
| 23 |
-
scores = AnalysisCredibilityScorer.score_papers(papers)
|
| 24 |
-
elapsed = time.time() - start
|
| 25 |
-
|
| 26 |
-
assert len(scores) == 100
|
| 27 |
-
# Performance requirement: 100 papers < 1s
|
| 28 |
-
assert elapsed < 1.0, f"Credibility scoring too slow: {elapsed}s"
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
@pytest.mark.asyncio
|
| 32 |
-
async def test_contradiction_detection_latency_with_mock(valid_llm_response_json):
|
| 33 |
-
detector = ContradictionDetector()
|
| 34 |
-
# Patch the llm call to return quickly
|
| 35 |
-
detector._call_llm_with_fallback = pytest.AsyncMock(
|
| 36 |
-
return_value=valid_llm_response_json
|
| 37 |
-
)
|
| 38 |
-
|
| 39 |
-
passages = [
|
| 40 |
-
{"paper_id": "p1", "text": "A claims X", "paper_title": "t1"},
|
| 41 |
-
{"paper_id": "p2", "text": "B contradicts X", "paper_title": "t2"},
|
| 42 |
-
]
|
| 43 |
-
|
| 44 |
-
start = time.time()
|
| 45 |
-
results = await detector.detect_contradictions(
|
| 46 |
-
query="q", relevant_passages=passages, llm_config={}
|
| 47 |
-
)
|
| 48 |
-
elapsed = time.time() - start
|
| 49 |
-
|
| 50 |
-
assert isinstance(results, list)
|
| 51 |
-
# Expect contradiction detection to be fast when LLM is mocked (<1s)
|
| 52 |
-
assert elapsed < 1.0, f"Contradiction detection too slow: {elapsed}s"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/symbols.pdf
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:2d62f0cd47d89939cb3e17e254e20a9d54ca85e5bea22068625446387051440e
|
| 3 |
-
size 219742
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_acquisition_agent.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_acquisition_agent_v2.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_advanced_acquisition.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_advanced_chunking.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_analysis.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_analysis_error_handling.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_analysis_langgraph_integration.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_analysis_param.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_deduplication_agent.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_embedding_manager.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_end_to_end_pipeline.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_error_scenarios.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_filtering_agent.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_hybrid_retrieval.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_hybrid_retriever.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_llm_client.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_logging_behavior.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_memory_usage.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_new_processing_agent.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_openalex_client.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_paper_diversity.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_pdf_text_extractor.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_performance.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_processing_ab_comparison.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_processing_agent.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_processing_integration.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_query_optimization_agent.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_reranker.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_scihub_fallback.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_search_agent.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_section_detector.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_startup.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_state_model.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_synthesis_agent.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|
tests/test_week2_performance.py
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
|
|
|
|
|
|