Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: re-implement benchmark queue tracking

LearningCircuit9e31e46267fc
diff --git a/src/local_deep_research/benchmarks/web_api/benchmark_service.py b/src/local_deep_research/benchmarks/web_api/benchmark_service.py
index e7d62bfa42..623a6f2366 100644
--- a/src/local_deep_research/benchmarks/web_api/benchmark_service.py
+++ b/src/local_deep_research/benchmarks/web_api/benchmark_service.py
@@ -22,6 +22,43 @@ from ..graders import extract_answer_from_response, grade_single_result
from ..runners import format_query
+class BenchmarkQueueTracker:
+ """Simple in-memory tracker for benchmark queue status.
+
+ This replaces the removed memory_queue functionality for benchmarks.
+ Since benchmarks are temporary and don't need persistence,
+ this simple in-memory solution is sufficient.
+ """
+
+ def __init__(self):
+ self.tasks = {}
+
+ def add_task(
+ self, task_id: str, username: str, task_type: str = "benchmark"
+ ):
+ """Add a new task to tracking."""
+ self.tasks[task_id] = {
+ "username": username,
+ "task_type": task_type,
+ "status": "queued",
+ "created_at": datetime.now(UTC),
+ }
+
+ def update_task_status(self, task_id: str, status: str):
+ """Update the status of a task."""
+ if task_id in self.tasks:
+ self.tasks[task_id]["status"] = status
+ self.tasks[task_id]["updated_at"] = datetime.now(UTC)
+
+ def get_task_status(self, task_id: str) -> Optional[Dict]:
+ """Get the current status of a task."""
+ return self.tasks.get(task_id)
+
+ def remove_task(self, task_id: str):
+ """Remove a task from tracking."""
+ self.tasks.pop(task_id, None)
+
+
class BenchmarkService:
"""Service for managing benchmark runs through the web interface."""
@@ -31,6 +68,7 @@ class BenchmarkService:
self.rate_limit_detected: Dict[
int, bool
] = {} # Track rate limiting per benchmark run
+ self.queue_tracker = BenchmarkQueueTracker() # Initialize queue tracker
def _get_socket_service(self):
"""Get socket service instance, handling cases where Flask app is not available."""
@@ -271,9 +309,9 @@ class BenchmarkService:
def _run_benchmark_thread(self, benchmark_run_id: int):
"""Main benchmark execution thread."""
# IMPORTANT: This runs in a background thread, so we cannot access the user database
- # TODO: Queue tracking for benchmarks needs to be re-implemented with the new queue system
- # See issue #596 for queue consolidation details
+ # Using in-memory queue tracker for benchmark status tracking
+ task_id = None
try:
# Get the benchmark data that was passed to us
# We need to retrieve this from the service database or from memory
@@ -339,6 +377,12 @@ class BenchmarkService:
total_examples = len(task_queue) + len(existing_results)
completed_examples = len(existing_results)
+ # Initialize task tracking
+ task_id = f"benchmark_{benchmark_run_id}_{int(datetime.now(UTC).timestamp())}"
+ username = benchmark_data.get("username", "benchmark_user")
+ self.queue_tracker.add_task(task_id, username, "benchmark")
+ self.queue_tracker.update_task_status(task_id, "processing")
+
# Track progress in memory
progress_info = {
"total_examples": total_examples,
@@ -437,9 +481,13 @@ class BenchmarkService:
if was_cancelled:
status = BenchmarkStatus.CANCELLED
message = "Benchmark cancelled by user"
+ if task_id:
+ self.queue_tracker.update_task_status(task_id, "cancelled")
else:
status = BenchmarkStatus.COMPLETED
message = "Benchmark completed successfully"
+ if task_id:
+ self.queue_tracker.update_task_status(task_id, "completed")
# Store completion info for later database update
self.active_runs[benchmark_run_id]["completion_info"] = {
@@ -469,6 +517,9 @@ class BenchmarkService:
except Exception as e:
logger.exception(f"Benchmark run {benchmark_run_id} failed")
+ # Update task status if we have a task_id
+ if task_id:
+ self.queue_tracker.update_task_status(task_id, "failed")
# Store failure info for later database update
if benchmark_run_id in self.active_runs:
self.active_runs[benchmark_run_id]["completion_info"] = {