forked from ChelseaKR/permit-bearings
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeta_gate_cli.py
More file actions
62 lines (52 loc) · 1.84 KB
/
Copy pathbeta_gate_cli.py
File metadata and controls
62 lines (52 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""Read-only CLI for the pilot-neutral aggregate beta gate."""
from __future__ import annotations
import argparse
import json
import sys
from collections.abc import Sequence
from pathlib import Path
from .beta_gate import DEFAULT_RECORD_PATH, load_beta_gate
def _parser(repository_root: Path) -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
description=(
"Validate and recompute the prepared pilot-neutral beta gate. "
"Success is planning integrity only, never a tested-beta claim."
)
)
subparsers = parser.add_subparsers(dest="command", required=True)
validate = subparsers.add_parser(
"validate",
help="validate bound artifacts and print the recomputed status as JSON",
)
validate.add_argument(
"--record",
type=Path,
default=None,
help=(
"aggregate record to validate; defaults to DEFAULT_RECORD_PATH "
"inside --repository-root"
),
)
validate.add_argument("--repository-root", type=Path, default=repository_root)
return parser
def main(argv: Sequence[str] | None = None) -> int:
"""Return 0 for a valid prepared/not-run record and 2 for invalid input."""
default_root = Path(__file__).resolve().parents[2]
args = _parser(default_root).parse_args(argv)
record = (
args.record
if args.record is not None
else args.repository_root / DEFAULT_RECORD_PATH
)
try:
summary = load_beta_gate(
record,
repository_root=args.repository_root,
)
except ValueError as error:
print(f"pilot beta aggregate gate: INVALID: {error}", file=sys.stderr)
return 2
print(json.dumps(summary.to_dict(), ensure_ascii=True, indent=2, sort_keys=True))
return 0
if __name__ == "__main__":
raise SystemExit(main())