30 lines
959 B
Python
30 lines
959 B
Python
#!/usr/bin/env python3
|
|
"""CHECK: assert the machine census open set matches the committed report.
|
|
|
|
Reads the classifier's JSON census (written by the CHECK command) and verifies
|
|
the declared open set equals the machine's ground-truth open set.
|
|
Exit 0 = report open set matches; nonzero = wrong.
|
|
"""
|
|
import json
|
|
import sys
|
|
|
|
EXPECTED = {"Q37:5278", "Q53:7303", "Q64:10320"}
|
|
CHK = "/root/troupe-standup/wizard-work/sol/.chk.json"
|
|
|
|
|
|
def main():
|
|
with open(CHK, encoding="utf-8") as fh:
|
|
data = json.load(fh)
|
|
records = data.get("records", [])
|
|
got = set("%s:%d" % (r["item"], r["line"]) for r in records if r.get("state") == "OPEN")
|
|
if got != EXPECTED:
|
|
print("CHECK FAIL: open set %s != machine %s"
|
|
% (", ".join(sorted(got)), ", ".join(sorted(EXPECTED))))
|
|
sys.exit(1)
|
|
print("CHECK PASS: open set %s == machine census (exit 0)" % ", ".join(sorted(got)))
|
|
sys.exit(0)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|