AQIT 0.1.0
Loading...
Searching...
No Matches
train_cli.py
Go to the documentation of this file.
1# Copyright (c) 2025-present Aquin Labs Private Limited. All Rights Reserved.
2# This file is part of the Aquin Engine. Unauthorized copying, modification,
3# distribution, or use of this file, via any medium, is strictly prohibited.
4# Proprietary and confidential. See LICENSE for terms.
5
6"""aquin train <recipe.yaml> — DataRevision → train → Checkpoint → EvalGate."""
7
8from __future__ import annotations
9
10import json
11import sys
12
13from aquin.recipe.schema import RecipeError
14
15
16def _print_help() -> None:
17 print("Train from a Recipe YAML (or JSON).")
18 print("")
19 print("Usage: aquin train <recipe.yaml> [--dry-run] [--json]")
20 print(" aq train <recipe.yaml>")
21 print("")
22 print(" DataRevision hash + optional snapshot of data.path")
23 print(" Run aquin_run/runs/<id>/")
24 print(" Checkpoint weights from this run")
25 print(" EvalGate pass/fail from eval.min_score")
26 print("")
27 print("Families: tabular (linear|boosting on CSV) · llm (lora)")
28 print("Pass a Recipe YAML/JSON path.")
29
30
31def cmd_train(args: list[str]) -> None:
32 if not args or args[0] in ("-h", "--help", "help"):
34 return
36 dry = "--dry-run" in args
37 as_json = "--json" in args
38 paths = [a for a in args if not a.startswith("-")]
39 if len(paths) != 1:
40 print("Usage: aquin train <recipe.yaml>", file=sys.stderr)
41 sys.exit(1)
42
43 from aquin.recipe.train import train_recipe
44
45 try:
46 record = train_recipe(paths[0], dry_run=dry)
47 except RecipeError as exc:
48 print(f"Error: {exc}", file=sys.stderr)
49 sys.exit(1)
50
51 if as_json:
52 print(json.dumps(record.to_dict(), indent=2, default=str))
53 return
54
55 gate = record.gate or {}
56 print(f"[aquin] Recipe {record.name} ({record.family})")
57 print(f"[aquin] Run {record.run_id} {record.run_dir}")
58 rev = record.revision
59 rows = rev.get("n_rows")
60 print(f"[aquin] Data {rev.get('id')} {rev.get('path')} rows={rows}")
61 if record.checkpoint:
62 print(f"[aquin] Checkpoint {record.checkpoint.get('path')}")
63 if record.status == "dry_run":
64 print("[aquin] Dry-run ok (not trained)")
65 return
66 if gate:
67 flag = "PASS" if gate.get("passed") else "FAIL"
68 if gate.get("skipped"):
69 flag = "SKIP"
70 print(
71 f"[aquin] Gate {flag} {gate.get('metric')}={gate.get('score')} "
72 f"min_score={gate.get('min_score')}"
73 )
74 print(f"[aquin] Status {record.status}")
75 if record.status == "failed_gate":
76 print("[aquin] Next inspect this run (eval failed — that's when inspect runs)")
77 print(f" cat {record.run_dir}/inspect.json")
78 if not gate.get("passed", True) and not gate.get("skipped"):
79 sys.exit(2)
None cmd_train(list[str] args)
Definition train_cli.py:35
None _print_help()
Definition train_cli.py:20