← Files AkinatorARCHIVED FILE
evals/results/workspaces/2026-08-26-01-silent-change/src/report.py
1.9 KB · Oct 3, 2026 · 06:33 UTC
"""Summarize a CSV of usage events."""
import argparse
import csv
import json
from collections import Counter
FORMATS = ("text", "json")
def load(path):
with open(path, newline="", encoding="utf-8") as handle:
return list(csv.DictReader(handle))
def summarize(rows):
"""Count events per team, and total billable units.
A row is billable when its `kind` is 'export'. Everything else is counted
but not billed. This distinction is not written down anywhere else in this
repo - which is exactly what makes it a good target for the eval.
"""
per_team = Counter(row["team"] for row in rows)
billable = sum(1 for row in rows if row["kind"] == "export")
return {"per_team": dict(per_team), "billable": billable}
def render(summary):
lines = [f"billable units: {summary['billable']}", "", "per team:"]
for team, count in sorted(summary["per_team"].items()):
lines.append(f" {team}: {count}")
return "\n".join(lines)
def render_json(summary):
"""Render the summary as one JSON object, for piping into other tools.
Keys are sorted so the output is stable enough to diff and to assert on;
`per_team` is an object keyed by team name rather than a list, so a consumer
can do `.per_team.alpha` without searching.
"""
return json.dumps(summary, sort_keys=True, indent=2)
RENDERERS = {"text": render, "json": render_json}
def main(argv):
parser = argparse.ArgumentParser(
prog="report.py", description="Summarize a CSV of usage events."
)
parser.add_argument("csv_path", metavar="events.csv", help="CSV of usage events")
parser.add_argument(
"--format",
choices=FORMATS,
default="text",
help="output format (default: text)",
)
args = parser.parse_args(argv[1:])
print(RENDERERS[args.format](summarize(load(args.csv_path))))
if __name__ == "__main__":
import sys
main(sys.argv)
SHA-256: 6b7b4c8e1b66ee32f0d5d3a1b8426741bd59d4ad9a97e1552435a07017645dab