|
| 1 | +#[path = "command/fixtures.rs"] |
| 2 | +mod fixtures; |
| 3 | +#[path = "command/options.rs"] |
| 4 | +mod options; |
| 5 | +#[path = "command/report.rs"] |
| 6 | +mod report; |
| 7 | + |
1 | 8 | use anyhow::Result; |
2 | 9 | use std::path::PathBuf; |
3 | 10 |
|
4 | 11 | use crate::config; |
5 | 12 |
|
6 | | -use super::fixtures::{collect_eval_fixtures, load_eval_report}; |
7 | | -use super::report::{ |
8 | | - build_eval_report, evaluation_failure_message, print_eval_report, write_eval_report, |
9 | | -}; |
10 | | -use super::runner::run_eval_fixture; |
11 | | -use super::thresholds::{parse_rule_threshold_args, EvalThresholdOptions}; |
12 | 13 | use super::EvalRunOptions; |
| 14 | +use fixtures::run_eval_fixtures; |
| 15 | +use options::prepare_eval_options; |
| 16 | +use report::emit_eval_report; |
13 | 17 |
|
14 | 18 | pub async fn eval_command( |
15 | 19 | config: config::Config, |
16 | 20 | fixtures_dir: PathBuf, |
17 | 21 | output_path: Option<PathBuf>, |
18 | 22 | options: EvalRunOptions, |
19 | 23 | ) -> Result<()> { |
20 | | - let fixtures = collect_eval_fixtures(&fixtures_dir)?; |
21 | | - if fixtures.is_empty() { |
22 | | - anyhow::bail!( |
23 | | - "No fixture files found in {} (expected .json/.yml/.yaml)", |
24 | | - fixtures_dir.display() |
25 | | - ); |
26 | | - } |
27 | | - |
28 | | - let mut results = Vec::new(); |
29 | | - for fixture in fixtures { |
30 | | - results.push(run_eval_fixture(&config, fixture).await?); |
31 | | - } |
32 | | - |
33 | | - let baseline = match options.baseline_report.as_deref() { |
34 | | - Some(path) => Some(load_eval_report(path)?), |
35 | | - None => None, |
36 | | - }; |
37 | | - let min_rule_thresholds = parse_rule_threshold_args(&options.min_rule_f1, "min-rule-f1")?; |
38 | | - let max_rule_drop_thresholds = |
39 | | - parse_rule_threshold_args(&options.max_rule_f1_drop, "max-rule-f1-drop")?; |
40 | | - let threshold_options = EvalThresholdOptions { |
41 | | - max_micro_f1_drop: options.max_micro_f1_drop, |
42 | | - min_micro_f1: options.min_micro_f1, |
43 | | - min_macro_f1: options.min_macro_f1, |
44 | | - min_rule_f1: min_rule_thresholds, |
45 | | - max_rule_f1_drop: max_rule_drop_thresholds, |
46 | | - }; |
47 | | - |
48 | | - let report = build_eval_report(results, baseline.as_ref(), &threshold_options); |
49 | | - print_eval_report(&report); |
50 | | - |
51 | | - if let Some(path) = output_path.as_deref() { |
52 | | - write_eval_report(&report, path).await?; |
53 | | - } |
54 | | - |
55 | | - if let Some(message) = evaluation_failure_message(&report) { |
56 | | - anyhow::bail!("{}", message); |
57 | | - } |
58 | | - |
59 | | - Ok(()) |
| 24 | + let results = run_eval_fixtures(&config, &fixtures_dir).await?; |
| 25 | + let prepared_options = prepare_eval_options(&options)?; |
| 26 | + emit_eval_report(results, output_path.as_deref(), prepared_options).await |
60 | 27 | } |
0 commit comments