7a0da7932b
Backwards Compatibility / Verify Encryption Constants (push) Waiting to run
Backwards Compatibility / PyPI Version Compatibility (push) Waiting to run
Backwards Compatibility / Database Migration Tests (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Blocked by required conditions
Docker Tests (Consolidated) / detect-changes (push) Waiting to run
Docker Tests (Consolidated) / Build Test Image (push) Waiting to run
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Blocked by required conditions
Docker Tests (Consolidated) / Accessibility Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Unit Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Example Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / Production Image Smoke Test (push) Blocked by required conditions
Docker Tests (Consolidated) / Infrastructure Tests (push) Blocked by required conditions
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Waiting to run
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
276 lines
8.7 KiB
Python
276 lines
8.7 KiB
Python
"""
|
|
Tests for uncovered code paths in api/benchmark_functions.py.
|
|
|
|
Targets:
|
|
- evaluate_simpleqa: evaluation_config with model only, provider only
|
|
- evaluate_browsecomp: evaluation_config branches
|
|
- evaluate_xbench_deepsearch: evaluation_config branches
|
|
- compare_configurations: default configs, report generation, metrics formatting
|
|
"""
|
|
|
|
from unittest.mock import patch
|
|
|
|
|
|
MODULE = "local_deep_research.api.benchmark_functions"
|
|
|
|
|
|
class TestEvaluateSimpleqa:
|
|
@patch(f"{MODULE}.run_simpleqa_benchmark")
|
|
def test_evaluation_config_with_model_only(self, mock_run):
|
|
"""evaluation_config is set when only model is provided."""
|
|
from local_deep_research.api.benchmark_functions import (
|
|
evaluate_simpleqa,
|
|
)
|
|
|
|
mock_run.return_value = {"status": "complete"}
|
|
|
|
evaluate_simpleqa(
|
|
num_examples=5,
|
|
evaluation_model="gpt-4",
|
|
)
|
|
|
|
call_kwargs = mock_run.call_args[1]
|
|
assert call_kwargs["evaluation_config"] == {"model_name": "gpt-4"}
|
|
|
|
@patch(f"{MODULE}.run_simpleqa_benchmark")
|
|
def test_evaluation_config_with_provider_only(self, mock_run):
|
|
"""evaluation_config is set when only provider is provided."""
|
|
from local_deep_research.api.benchmark_functions import (
|
|
evaluate_simpleqa,
|
|
)
|
|
|
|
mock_run.return_value = {"status": "complete"}
|
|
|
|
evaluate_simpleqa(
|
|
num_examples=5,
|
|
evaluation_provider="openai",
|
|
)
|
|
|
|
call_kwargs = mock_run.call_args[1]
|
|
assert call_kwargs["evaluation_config"] == {"provider": "openai"}
|
|
|
|
@patch(f"{MODULE}.run_simpleqa_benchmark")
|
|
def test_evaluation_config_with_both(self, mock_run):
|
|
"""evaluation_config includes both model and provider."""
|
|
from local_deep_research.api.benchmark_functions import (
|
|
evaluate_simpleqa,
|
|
)
|
|
|
|
mock_run.return_value = {"status": "complete"}
|
|
|
|
evaluate_simpleqa(
|
|
num_examples=5,
|
|
evaluation_model="gpt-4",
|
|
evaluation_provider="openai",
|
|
)
|
|
|
|
call_kwargs = mock_run.call_args[1]
|
|
assert call_kwargs["evaluation_config"]["model_name"] == "gpt-4"
|
|
assert call_kwargs["evaluation_config"]["provider"] == "openai"
|
|
|
|
@patch(f"{MODULE}.run_simpleqa_benchmark")
|
|
def test_no_evaluation_config(self, mock_run):
|
|
"""evaluation_config is None when neither model nor provider."""
|
|
from local_deep_research.api.benchmark_functions import (
|
|
evaluate_simpleqa,
|
|
)
|
|
|
|
mock_run.return_value = {"status": "complete"}
|
|
|
|
evaluate_simpleqa(num_examples=5)
|
|
|
|
call_kwargs = mock_run.call_args[1]
|
|
assert call_kwargs["evaluation_config"] is None
|
|
|
|
|
|
class TestEvaluateBrowsecomp:
|
|
@patch(f"{MODULE}.run_browsecomp_benchmark")
|
|
def test_evaluation_config_with_model(self, mock_run):
|
|
"""evaluation_config with model for browsecomp."""
|
|
from local_deep_research.api.benchmark_functions import (
|
|
evaluate_browsecomp,
|
|
)
|
|
|
|
mock_run.return_value = {"status": "complete"}
|
|
|
|
evaluate_browsecomp(
|
|
num_examples=5,
|
|
evaluation_model="claude-3",
|
|
)
|
|
|
|
call_kwargs = mock_run.call_args[1]
|
|
assert call_kwargs["evaluation_config"]["model_name"] == "claude-3"
|
|
|
|
@patch(f"{MODULE}.run_browsecomp_benchmark")
|
|
def test_evaluation_config_with_provider(self, mock_run):
|
|
"""evaluation_config with provider for browsecomp."""
|
|
from local_deep_research.api.benchmark_functions import (
|
|
evaluate_browsecomp,
|
|
)
|
|
|
|
mock_run.return_value = {"status": "complete"}
|
|
|
|
evaluate_browsecomp(
|
|
num_examples=5,
|
|
evaluation_provider="anthropic",
|
|
)
|
|
|
|
call_kwargs = mock_run.call_args[1]
|
|
assert call_kwargs["evaluation_config"]["provider"] == "anthropic"
|
|
|
|
|
|
class TestEvaluateXbenchDeepsearch:
|
|
@patch(f"{MODULE}.run_xbench_deepsearch_benchmark")
|
|
def test_evaluation_config_with_model(self, mock_run):
|
|
"""evaluation_config with model for xbench."""
|
|
from local_deep_research.api.benchmark_functions import (
|
|
evaluate_xbench_deepsearch,
|
|
)
|
|
|
|
mock_run.return_value = {"status": "complete"}
|
|
|
|
evaluate_xbench_deepsearch(
|
|
num_examples=5,
|
|
evaluation_model="gpt-4o",
|
|
)
|
|
|
|
call_kwargs = mock_run.call_args[1]
|
|
assert call_kwargs["evaluation_config"]["model_name"] == "gpt-4o"
|
|
|
|
@patch(f"{MODULE}.run_xbench_deepsearch_benchmark")
|
|
def test_evaluation_config_with_provider(self, mock_run):
|
|
"""evaluation_config with provider for xbench."""
|
|
from local_deep_research.api.benchmark_functions import (
|
|
evaluate_xbench_deepsearch,
|
|
)
|
|
|
|
mock_run.return_value = {"status": "complete"}
|
|
|
|
evaluate_xbench_deepsearch(
|
|
num_examples=5,
|
|
evaluation_provider="openai",
|
|
)
|
|
|
|
call_kwargs = mock_run.call_args[1]
|
|
assert call_kwargs["evaluation_config"]["provider"] == "openai"
|
|
|
|
|
|
class TestCompareConfigurations:
|
|
@patch(
|
|
"local_deep_research.security.file_write_verifier.write_file_verified"
|
|
)
|
|
@patch(f"{MODULE}.run_benchmark")
|
|
def test_default_configurations(self, mock_run, mock_write):
|
|
"""Uses default configurations when none provided."""
|
|
from local_deep_research.api.benchmark_functions import (
|
|
compare_configurations,
|
|
)
|
|
|
|
mock_run.return_value = {
|
|
"metrics": {"accuracy": 0.85, "average_processing_time": 1.5},
|
|
"total_examples": 20,
|
|
}
|
|
|
|
result = compare_configurations(
|
|
dataset_type="simpleqa",
|
|
num_examples=5,
|
|
output_dir="/tmp/test_bench",
|
|
)
|
|
|
|
assert result["status"] == "complete"
|
|
assert result["configurations_tested"] == 3 # 3 default configs
|
|
assert mock_run.call_count == 3
|
|
|
|
@patch(
|
|
"local_deep_research.security.file_write_verifier.write_file_verified"
|
|
)
|
|
@patch(f"{MODULE}.run_benchmark")
|
|
def test_custom_configurations(self, mock_run, mock_write):
|
|
"""Passes custom configurations correctly."""
|
|
from local_deep_research.api.benchmark_functions import (
|
|
compare_configurations,
|
|
)
|
|
|
|
mock_run.return_value = {
|
|
"metrics": {"accuracy": 0.9, "average_processing_time": 2.0},
|
|
"total_examples": 10,
|
|
}
|
|
|
|
configs = [
|
|
{
|
|
"name": "Fast",
|
|
"search_tool": "wikipedia",
|
|
"iterations": 1,
|
|
"questions_per_iteration": 2,
|
|
},
|
|
]
|
|
|
|
result = compare_configurations(
|
|
configurations=configs,
|
|
num_examples=10,
|
|
output_dir="/tmp/test_bench",
|
|
)
|
|
|
|
assert result["configurations_tested"] == 1
|
|
|
|
@patch(
|
|
"local_deep_research.security.file_write_verifier.write_file_verified"
|
|
)
|
|
@patch(f"{MODULE}.run_benchmark")
|
|
def test_report_written(self, mock_run, mock_write):
|
|
"""Comparison report is written to file."""
|
|
from local_deep_research.api.benchmark_functions import (
|
|
compare_configurations,
|
|
)
|
|
|
|
mock_run.return_value = {
|
|
"metrics": {"accuracy": 0.85, "average_processing_time": 1.5},
|
|
"total_examples": 20,
|
|
}
|
|
|
|
result = compare_configurations(
|
|
num_examples=5,
|
|
output_dir="/tmp/test_bench",
|
|
)
|
|
|
|
mock_write.assert_called_once()
|
|
# Report content should contain markdown table
|
|
report_content = mock_write.call_args[0][1]
|
|
assert "Configuration" in report_content
|
|
assert "Accuracy" in report_content
|
|
assert result["report_path"].endswith(".md")
|
|
|
|
@patch(
|
|
"local_deep_research.security.file_write_verifier.write_file_verified"
|
|
)
|
|
@patch(f"{MODULE}.run_benchmark")
|
|
def test_extra_config_items_passed(self, mock_run, mock_write):
|
|
"""Extra config items beyond standard ones are passed through."""
|
|
from local_deep_research.api.benchmark_functions import (
|
|
compare_configurations,
|
|
)
|
|
|
|
mock_run.return_value = {
|
|
"metrics": {"accuracy": 0.5},
|
|
"total_examples": 5,
|
|
}
|
|
|
|
configs = [
|
|
{
|
|
"name": "Custom",
|
|
"search_tool": "searxng",
|
|
"iterations": 1,
|
|
"questions_per_iteration": 1,
|
|
"custom_param": "value",
|
|
},
|
|
]
|
|
|
|
compare_configurations(
|
|
configurations=configs,
|
|
num_examples=5,
|
|
output_dir="/tmp/test_bench",
|
|
)
|
|
|
|
call_kwargs = mock_run.call_args[1]
|
|
assert call_kwargs["search_config"]["custom_param"] == "value"
|