File size: 1,432 Bytes
c0c3a41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
import gzip, hashlib, json
from pathlib import Path

root = Path(__file__).parent
manifest = json.loads((root / "metadata/manifest.json").read_text())
rows = 0
seen = set()
for item in manifest["data_files"]:
    path = root / item["file"]
    digest = hashlib.sha256(path.read_bytes()).hexdigest()
    if digest != item["sha256"]:
        raise ValueError(f"checksum mismatch: {path}")
    with gzip.open(path, "rt", encoding="utf-8") as handle:
        for line in handle:
            row = json.loads(line)
            sid = row.get("source_id")
            if not sid or sid in seen:
                raise ValueError(f"missing or duplicate source_id: {sid}")
            seen.add(sid)
            messages = row.get("messages")
            if [message.get("role") for message in messages] != ["user", "assistant", "tool", "assistant"]:
                raise ValueError(f"invalid roles: {sid}")
            call = messages[1]["tool_calls"][0]
            if call["id"] != messages[2].get("tool_call_id"):
                raise ValueError(f"call/result mismatch: {sid}")
            if not str(messages[3].get("content") or "").startswith("\\boxed{"):
                raise ValueError(f"missing boxed answer: {sid}")
            rows += 1
if rows != manifest["rows"]:
    raise ValueError(f"row count mismatch: {rows} != {manifest['rows']}")
print(json.dumps({"rows": rows, "valid": True}, sort_keys=True))