From 392cc8daca9a1b847c848788e916459ef2b621ed Mon Sep 17 00:00:00 2001 From: sora <2075279110@qq.com> Date: Thu, 10 Sep 2026 11:13:34 +0000 Subject: [PATCH] Persistent benchmark counter [i/N] on the single progress bar; phase lines all route through the live channel for strict ordering Co-Authored-By: Claude --- evalharness/cli.py | 19 +++++++++++++------ evalharness/progress/rich_terminal.py | 13 +++++++++++-- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/evalharness/cli.py b/evalharness/cli.py index 9d2cfe8..e3f4bf7 100644 --- a/evalharness/cli.py +++ b/evalharness/cli.py @@ -487,8 +487,17 @@ def _cmd_eval_run(args) -> int: for i, name in enumerate(args.datasets): t0 = _time.time() try: - _print_phase(console, i + 1, total_runs, name, - 'loading/downloading dataset') + if _shared_reporter is not None and total_runs > 1: + _shared_reporter.set_bench_tag(f'[{i + 1}/{total_runs}]') + + def _emit(msg, _i=i, _n=name): + if _shared_reporter is not None: + _col = _phase_color(msg) + _shared_reporter.log(f'[{_col}][{_i + 1}/{total_runs}] {_n}: {msg}[/{_col}]') + else: + _print_phase(console, _i + 1, total_runs, _n, msg) + + _emit('loading/downloading dataset') ds = get_dataset(name, **overrides) if _shared_reporter is not None: _shared_reporter.pause() # let hub tqdm print cleanly @@ -496,8 +505,7 @@ def _cmd_eval_run(args) -> int: if _shared_reporter is not None: _shared_reporter.resume() origin = ds.lineage.get('from', 'unknown') - _print_phase(console, i + 1, total_runs, name, - f'dataset ready · samples={sample_count} · source={origin}') + _emit(f'dataset ready · samples={sample_count} · source={origin}') if model_spec: # generate + score in one go from evalharness.model import run_eval @@ -556,8 +564,7 @@ def _cmd_eval_run(args) -> int: if args.out: report.save(args.out) if out_dir: - _print_phase(console, i + 1, total_runs, name, - 'writing results') + _emit('writing results') from pathlib import Path as _P bench_dir = _P(out_dir) / name diff --git a/evalharness/progress/rich_terminal.py b/evalharness/progress/rich_terminal.py index d84144e..a7778f0 100644 --- a/evalharness/progress/rich_terminal.py +++ b/evalharness/progress/rich_terminal.py @@ -39,6 +39,8 @@ class RichTerminalProgress: ) self.task_id = None self.bench_name = '' + self.bench_tag = '' # e.g. '[1/6]': persistent benchmark counter + self._last_phase = '' self.started = 0.0 self.current_started = 0.0 self.inflight = 0 @@ -86,7 +88,7 @@ class RichTerminalProgress: self.started = time.monotonic() self.inflight = 0 self.bench_name = description - desc = f'[green]{description} · generating[/green]' + desc = f'[green]{self.bench_tag}{description} · generating[/green]' if self.task_id is None: self.progress.start() self.task_id = self.progress.add_task( @@ -100,13 +102,20 @@ class RichTerminalProgress: success=completed, failed=0, rate='0.00', inflight=0, last_result='restored') + def set_bench_tag(self, tag: str): + """Persistent counter shown on the sample bar, e.g. '[1/6]'.""" + self.bench_tag = tag + ' ' if tag else '' + if self._last_phase: + self.set_phase(self._last_phase) + def set_phase(self, phase: str): + self._last_phase = phase """Retag the sample bar with what is happening (generating/scoring/ writing) -- the bar alone does not say which stage we are in.""" if self.task_id is not None: self.progress.update( self.task_id, - description=f'[green]{self.bench_name} · {phase}[/green]') + description=f'[green]{self.bench_tag}{self.bench_name} · {phase}[/green]') def begin_sample(self, label: str): if self.task_id is None: