chore: import upstream snapshot with attribution
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
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Has been cancelled
Docker Tests (Consolidated) / Accessibility Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Unit Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Example Tests (push) Has been cancelled
Docker Tests (Consolidated) / Production Image Smoke Test (push) Has been cancelled
Docker Tests (Consolidated) / Infrastructure Tests (push) Has been cancelled
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Has been cancelled
Backwards Compatibility / Verify Encryption Constants (push) Has been cancelled
Backwards Compatibility / PyPI Version Compatibility (push) Has been cancelled
Backwards Compatibility / Database Migration Tests (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Docker Tests (Consolidated) / detect-changes (push) Has been cancelled
Docker Tests (Consolidated) / Build Test Image (push) Has been cancelled
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Has been cancelled
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
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Has been cancelled
Docker Tests (Consolidated) / Accessibility Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Unit Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Example Tests (push) Has been cancelled
Docker Tests (Consolidated) / Production Image Smoke Test (push) Has been cancelled
Docker Tests (Consolidated) / Infrastructure Tests (push) Has been cancelled
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Has been cancelled
Backwards Compatibility / Verify Encryption Constants (push) Has been cancelled
Backwards Compatibility / PyPI Version Compatibility (push) Has been cancelled
Backwards Compatibility / Database Migration Tests (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Docker Tests (Consolidated) / detect-changes (push) Has been cancelled
Docker Tests (Consolidated) / Build Test Image (push) Has been cancelled
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,275 @@
|
||||
"""
|
||||
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"
|
||||
Reference in New Issue
Block a user