Skip to content

Commit 99c6ae1

Browse files
committed
feat(source): add TypedDicts for reading balatrollm source files
1 parent 2078223 commit 99c6ae1

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

src/balatrobench/source.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
"""Source data models for reading runs/ files.
2+
3+
These TypedDicts mirror the JSON structure written by balatrollm.
4+
They are used for parsing source files, not for output.
5+
"""
6+
7+
from typing import TypedDict
8+
9+
10+
class SourceModel(TypedDict):
11+
"""Model identification in task.json."""
12+
13+
vendor: str
14+
name: str
15+
16+
17+
class SourceTask(TypedDict):
18+
"""task.json structure."""
19+
20+
model: SourceModel
21+
seed: str
22+
deck: str # JSON contains string like "RED", not Deck enum
23+
stake: str # JSON contains string like "WHITE", not Stake enum
24+
strategy: str
25+
26+
27+
class SourceStrategy(TypedDict):
28+
"""strategy.json structure."""
29+
30+
name: str
31+
description: str
32+
author: str
33+
version: str
34+
tags: list[str]
35+
36+
37+
class SourceStats(TypedDict):
38+
"""stats.json structure (flat)."""
39+
40+
# Outcome
41+
run_won: bool
42+
run_completed: bool
43+
final_ante: int
44+
final_round: int
45+
46+
# Providers
47+
providers: dict[str, int]
48+
49+
# Calls
50+
calls_total: int
51+
calls_success: int
52+
calls_error: int
53+
calls_failed: int
54+
55+
# Tokens
56+
tokens_in_total: int
57+
tokens_out_total: int
58+
tokens_in_avg: float
59+
tokens_out_avg: float
60+
tokens_in_std: float
61+
tokens_out_std: float
62+
63+
# Timing
64+
time_total_ms: int
65+
time_avg_ms: float
66+
time_std_ms: float
67+
68+
# Cost
69+
cost_total: float
70+
cost_avg: float
71+
cost_std: float

0 commit comments

Comments
 (0)