From ed36fda365a7b15d500665c612cc2bc2ebbf3f40 Mon Sep 17 00:00:00 2001 From: sora <2075279110@qq.com> Date: Thu, 10 Sep 2026 10:05:29 +0000 Subject: [PATCH] Auto-save results by default (evalharness-results/-/); final notice: run finished + saved location with clickable links Co-Authored-By: Claude --- evalharness/cli.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/evalharness/cli.py b/evalharness/cli.py index dd94021..4813a83 100644 --- a/evalharness/cli.py +++ b/evalharness/cli.py @@ -435,6 +435,18 @@ def _cmd_eval_run(args) -> int: run_started = _time.time() total_runs = len(args.datasets) model_spec = _compose_model_spec(args) + if not out_dir and model_spec and not args.out: + # always persist results: default dir = evalharness-results/-/ + import re as _re + + stamp = _time.strftime('%Y%m%d-%H%M%S') + tag = _re.sub(r'[^A-Za-z0-9._-]+', '-', args.model or 'run')[:40].strip('-') + out_dir = f'evalharness-results/{stamp}-{tag}' + from pathlib import Path + + Path(out_dir).mkdir(parents=True, exist_ok=True) + (Path(out_dir) / 'viz').mkdir(exist_ok=True) + (Path(out_dir) / 'reports').mkdir(exist_ok=True) console = _rich_console() _print_run_plan(console, args, model_spec) for i, name in enumerate(args.datasets): @@ -599,18 +611,13 @@ def _cmd_eval_run(args) -> int: else: print(f'\n{label} -> ' + ' · '.join(os.path.abspath(p) for p in paths)) - if len(rows) > 1: - if out_dir: - _notice('结果已生成', f'{out_dir}/reports/.report.json', - f'{out_dir}/viz/summary.md') - else: - print('\n提示: 加 --out-dir <目录> 可保存全部报告 (reports/*.json + summary.md)') - elif rows and rows[0]['ok']: - saved = args.out or (f'{out_dir}/reports/{rows[0]["name"]}.report.json' if out_dir else '') - if saved: - _notice('结果已生成', saved) - else: - print('\n提示: 加 --out <文件> 或 --out-dir <目录> 可保存报告') + ok_n = sum(1 for r in rows if r['ok']) + if out_dir: + _notice('运行结束 · 结果已保存', f'{out_dir}/reports/.report.json', + f'{out_dir}/viz/summary.md') + elif rows and rows[0]['ok'] and args.out: + _notice('运行结束 · 结果已保存', args.out) + print(f'\n{ok_n}/{len(rows)} benchmarks ok') return 0 if all(r['ok'] for r in rows) else 1