c889a57b6b
Test Suites / Build CI Environment (push) Has been cancelled
Test Suites / Basic Tests (push) Has been cancelled
Test Suites / End-to-End Tests (push) Has been cancelled
Test Suites / CLI Tests (push) Has been cancelled
Test Suites / Slow End-to-End Tests (push) Has been cancelled
Test Suites / Graph Database Tests (push) Has been cancelled
Test Suites / Vector DB Tests (push) Has been cancelled
Test Suites / Temporal Graph Test (push) Has been cancelled
Test Suites / Search Test on Different DBs (push) Has been cancelled
Test Suites / Example Tests (push) Has been cancelled
Test Suites / Notebook Tests (push) Has been cancelled
Test Suites / OS and Python Tests Ubuntu (push) Has been cancelled
Test Suites / OS and Python Tests Extended (push) Has been cancelled
Test Suites / LLM Test Suite (push) Has been cancelled
Test Suites / S3 File Storage Test (push) Has been cancelled
Test Suites / Run Integration Tests (push) Has been cancelled
Test Suites / MCP Tests (push) Has been cancelled
Test Suites / Docker Compose Test (push) Has been cancelled
Test Suites / Docker CI test (push) Has been cancelled
Test Suites / Relational DB Migration Tests (push) Has been cancelled
Test Suites / Distributed Cognee Test (push) Has been cancelled
Test Suites / DB Examples Tests (push) Has been cancelled
Test Suites / Test Completion Status (push) Has been cancelled
Test Suites / Claude Code Review (push) Has been cancelled
Test Suites / basic checks (push) Has been cancelled
build | Build and Push Cognee MCP Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
build | Build and Push Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.11) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.12) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (kuzu, kuzu) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (neo4j, neo4j) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Examples (push) Has been cancelled
Weighted Edges Tests / Code Quality for Weighted Edges (push) Has been cancelled
89 lines
2.9 KiB
Python
89 lines
2.9 KiB
Python
import unittest
|
|
import json
|
|
import os
|
|
|
|
|
|
from cognee.eval_framework.analysis.dashboard_generator import (
|
|
create_distribution_plots,
|
|
create_ci_plot,
|
|
generate_details_html,
|
|
get_dashboard_html_template,
|
|
create_dashboard,
|
|
)
|
|
|
|
|
|
class TestDashboardFunctions(unittest.TestCase):
|
|
def setUp(self):
|
|
"""Set up test data."""
|
|
self.metrics_data = {
|
|
"accuracy": [0.8, 0.85, 0.9, 0.95, 1.0],
|
|
"f1_score": [0.7, 0.75, 0.8, 0.85, 0.9],
|
|
}
|
|
|
|
self.ci_data = {
|
|
"accuracy": (0.9, 0.85, 0.95),
|
|
"f1_score": (0.8, 0.75, 0.85),
|
|
}
|
|
|
|
self.detail_data = [
|
|
{
|
|
"question": "What is AI?",
|
|
"answer": "Artificial Intelligence",
|
|
"golden_answer": "Artificial Intelligence",
|
|
"metrics": {
|
|
"accuracy": {"score": 1.0, "reason": "Exact match"},
|
|
"f1_score": {"score": 0.9, "reason": "High similarity"},
|
|
},
|
|
}
|
|
]
|
|
|
|
def test_generate_details_html(self):
|
|
"""Test HTML details generation."""
|
|
html_output = generate_details_html(self.detail_data)
|
|
|
|
self.assertIn("<h3>accuracy Details</h3>", html_output[0])
|
|
self.assertIn("<th>Question</th>", html_output[1])
|
|
self.assertIn("Exact match", "".join(html_output))
|
|
|
|
def test_get_dashboard_html_template(self):
|
|
"""Test full dashboard HTML generation."""
|
|
figures = create_distribution_plots(self.metrics_data)
|
|
ci_plot = create_ci_plot(self.ci_data)
|
|
dashboard_html = get_dashboard_html_template(
|
|
figures + [ci_plot], generate_details_html(self.detail_data), "Benchmark 1"
|
|
)
|
|
|
|
self.assertIn("<title>LLM Evaluation Dashboard Benchmark 1</title>", dashboard_html)
|
|
self.assertIn("<h2>Metrics Distribution</h2>", dashboard_html)
|
|
self.assertIn("<h2>95% confidence interval for all the metrics</h2>", dashboard_html)
|
|
self.assertIn("Benchmark 1", dashboard_html)
|
|
|
|
def test_create_dashboard(self):
|
|
"""Test the full dashboard generation and file creation."""
|
|
metrics_path = "test_metrics.json"
|
|
aggregate_metrics_path = "test_aggregate.json"
|
|
output_file = "test_dashboard.html"
|
|
|
|
with open(metrics_path, "w") as f:
|
|
json.dump(self.detail_data, f)
|
|
|
|
with open(aggregate_metrics_path, "w") as f:
|
|
json.dump(
|
|
{
|
|
metric: {"mean": v[0], "ci_lower": v[1], "ci_upper": v[2]}
|
|
for metric, v in self.ci_data.items()
|
|
},
|
|
f,
|
|
)
|
|
|
|
output = create_dashboard(
|
|
metrics_path, aggregate_metrics_path, output_file, "Test Benchmark"
|
|
)
|
|
|
|
self.assertEqual(output, output_file)
|
|
self.assertTrue(os.path.exists(output_file))
|
|
|
|
os.remove(metrics_path)
|
|
os.remove(aggregate_metrics_path)
|
|
os.remove(output_file)
|