betterwithage commited on
Commit
fa4eb4f
·
verified ·
1 Parent(s): 245504e

fix: make receipt evaluation portable

Browse files

Copy the complete repository into the isolated re-forge directory so packaged kernels and doctrine inputs resolve on fresh checkouts. Avoid privileged symlinks and non-ASCII status output on Windows.

Files changed (1) hide show
  1. scripts/eval.py +6 -8
scripts/eval.py CHANGED
@@ -12,16 +12,14 @@ want = receipt["model"]["sha256"]
12
  print(f"model.joblib sha256 {'MATCHES receipt' if got==want else 'MISMATCH — refuse'}: {got[:16]}…")
13
  if got != want: sys.exit(1)
14
  with tempfile.TemporaryDirectory() as td:
15
- os.makedirs(f"{td}/repo/scripts")
16
- # symlink the kernel build dir so forge.py's in-repo path logic resolves it
17
- os.symlink(f"{root}/build", f"{td}/repo/build")
18
- shutil.copy(f"{root}/scripts/forge.py", f"{td}/repo/scripts/forge.py")
19
- out = subprocess.run([sys.executable, f"{td}/repo/scripts/forge.py"],
20
- capture_output=True, text=True)
21
  print(out.stdout[-500:] if out.returncode == 0 else out.stderr[-500:])
22
  if out.returncode: sys.exit(1)
23
- re_receipt = json.load(open(f"{td}/repo/scripts/TRAINING_RECEIPT.json"))
24
  d = abs(re_receipt["metrics_MEASURED"]["test_accuracy_21_class"]
25
  - receipt["metrics_MEASURED"]["test_accuracy_21_class"])
26
- print(f"re-measured 21-class accuracy delta vs receipt: {d:.4f} ({'OK 0.02' if d<=0.02 else 'FAIL'})")
27
  sys.exit(0 if d <= 0.02 else 1)
 
12
  print(f"model.joblib sha256 {'MATCHES receipt' if got==want else 'MISMATCH — refuse'}: {got[:16]}…")
13
  if got != want: sys.exit(1)
14
  with tempfile.TemporaryDirectory() as td:
15
+ copy = f"{td}/repo"
16
+ shutil.copytree(root, copy, ignore=shutil.ignore_patterns(".cache"))
17
+ out = subprocess.run([sys.executable, f"{copy}/scripts/forge.py"],
18
+ capture_output=True, text=True, cwd=copy)
 
 
19
  print(out.stdout[-500:] if out.returncode == 0 else out.stderr[-500:])
20
  if out.returncode: sys.exit(1)
21
+ re_receipt = json.load(open(f"{copy}/scripts/TRAINING_RECEIPT.json"))
22
  d = abs(re_receipt["metrics_MEASURED"]["test_accuracy_21_class"]
23
  - receipt["metrics_MEASURED"]["test_accuracy_21_class"])
24
+ print(f"re-measured 21-class accuracy delta vs receipt: {d:.4f} ({'OK <=0.02' if d<=0.02 else 'FAIL'})")
25
  sys.exit(0 if d <= 0.02 else 1)