File size: 1,688 Bytes
2e7de11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Harbor entry point. Keep evaluation errors distinct from candidate failures."""
import json
import os
from pathlib import Path

from penrose_score import VERSION, evaluate


def test_rubric():
    log = Path(os.environ.get("T35_LOG_DIR", "/logs/verifier"))
    log.mkdir(parents=True, exist_ok=True)
    (log / "reward.txt").unlink(missing_ok=True)
    (log / "evaluation-error.json").unlink(missing_ok=True)
    try:
        result = evaluate(
            os.environ.get("T35_FINAL", "/root/Desktop/final.mp4"),
            os.environ.get("T35_PNG", "/root/edit/penrose.png"),
            os.environ.get("T35_EDIT", "/root/edit"),
            os.environ.get("T35_TERMINAL_LOG", "/logs/artifacts/terminal-attempts.log"),
        )
    except Exception as err:
        (log / "evaluation-error.json").write_text(
            json.dumps({"rubric_version": VERSION, "evaluation_error": str(err), "reward": None}, indent=2) + "\n")
        raise
    (log / "score-report.json").write_text(json.dumps(result, indent=2, allow_nan=False) + "\n")
    (log / "reward.txt").write_text("%.6f\n" % result["reward"])
    for c in result["checks"]:
        print("%-32s %.4f / %.4f" % (c["id"], c["earned"], c["weight"]))
    if result.get("reference_svg_imported"):
        print("GATE: reference SVG was opened in GIMP -> all drawing credit forfeited")
        print("      hits: %s" % result["reference_svg_import_hits"])
    if result.get("terminal_attempts"):
        print("GATE: terminal attempts logged -> reward 0")
        for line in result["terminal_attempts"]:
            print("      %s" % line)
    print("Fractional reward:", result["reward"])
    assert 0 <= result["reward"] <= 1