Skip to content

Commit 412b9f7

Browse files
committed
local eval queue fixes
1 parent f43969a commit 412b9f7

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/judgeval/tracer/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ def __init__(
192192
)
193193
self.local_eval_queue = LocalEvaluationQueue()
194194

195+
if self.enable_evaluation and self.enable_monitoring:
196+
self.local_eval_queue.start_workers()
197+
195198
Tracer._active_tracers[self.project_name] = self
196199

197200
def get_current_span(self):

src/judgeval/tracer/local_eval_queue.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from judgeval.data.evaluation_run import EvaluationRun
1717
from judgeval.utils.async_utils import safe_run_async
1818
from judgeval.scorers.score import a_execute_scoring
19+
from judgeval.api import JudgmentSyncClient
20+
from judgeval.env import JUDGMENT_API_KEY, JUDGMENT_ORG_ID
1921

2022

2123
class LocalEvaluationQueue:
@@ -37,6 +39,10 @@ def __init__(
3739
self._num_workers = num_workers # Number of worker threads
3840
self._worker_threads: List[threading.Thread] = []
3941
self._shutdown_event = threading.Event()
42+
self._api_client = JudgmentSyncClient(
43+
api_key=JUDGMENT_API_KEY,
44+
organization_id=JUDGMENT_ORG_ID,
45+
)
4046

4147
def enqueue(self, evaluation_run: EvaluationRun) -> None:
4248
"""Add evaluation run to the queue."""
@@ -83,13 +89,8 @@ def run_all(
8389

8490
def start_workers(
8591
self,
86-
callback: Optional[Callable[[EvaluationRun, List[ScoringResult]], None]] = None,
8792
) -> List[threading.Thread]:
8893
"""Start multiple background threads to process runs in parallel.
89-
90-
Args:
91-
callback: Optional function called after each run with (run, results).
92-
9394
Returns:
9495
List of started worker threads.
9596
"""
@@ -107,8 +108,10 @@ def _worker(worker_id: int) -> None:
107108

108109
try:
109110
results = self._process_run(run)
110-
if callback:
111-
callback(run, results)
111+
results_dict = [result.model_dump() for result in results]
112+
self._api_client.log_eval_results(
113+
payload={"results": results_dict, "run": run.model_dump()}
114+
)
112115
except Exception as exc:
113116
judgeval_logger.error(
114117
f"Worker {worker_id} error processing {run.eval_name}: {exc}"

0 commit comments

Comments
 (0)