SPB Git

spb/wp29_uqo

Public
2.6 KB · 25 lines python
1"""Human-effort and builder-effort decomposition (table + figure). Sources: reports/interventions.csv (human), reports/phase_status.md timestamps and2the builder's recorded subagent usage (reports/builder_effort.json, written by the builder from the client's task notifications)."""3import os, sys, json, csv4sys.path.insert(0, os.path.dirname(__file__)); from common import *5import matplotlib; matplotlib.use("Agg"); import matplotlib.pyplot as plt6def main():7    inter = list(csv.DictReader(open(os.path.join(REPO, "reports", "interventions.csv"))))8    be = json.load(open(os.path.join(REPO, "reports", "builder_effort.json")))9    runs = pd.read_csv(os.path.join(DATA, "runs.csv"))10    rows = [("Researcher: mandate preparation", "unknown", "not measured (historical)", "—"), ("Researcher: launch instruction", "< 1 min", "observed (one message)", "—"),11            ("Researcher: interventions in executor sessions", "0", "ledger (none recorded)", "—"), ("Researcher: final review of the manuscript", be.get("human_final_review", "not yet performed"), "ledger", "—")]12    for k, v in be["builder"].items(): rows.append((f"Builder session: {k}", v.get("wall", "—"), v.get("basis", ""), f"{v.get('tokens', '—')}"))13    for k, v in be["subagents"].items(): rows.append((f"Sub-session: {k}", f"{v['duration_min']:.0f} min", "client task notification", f"{v['tokens']:,}"))14    inf = runs.groupby("split").spent_usd.sum()15    L = [r"\begin{tabular}{p{2.6in}p{0.9in}p{1.6in}p{0.9in}}", r"\toprule", r"Component & Wall time & Measurement basis & Tokens \\", r"\midrule"] + [f"{a} & {b} & {c} & {d} \\\\" for a, b, c, d in rows] + [r"\midrule"]16    for s, v in inf.items(): L.append(f"Inference: {s} runs & — & client cost estimate & {v:.2f} USD \\\\")17    L += [r"\bottomrule", r"\end{tabular}"]18    os.makedirs(os.path.join(REPO, "results", "tables"), exist_ok=True); open(os.path.join(REPO, "results", "tables", "tab_effort.tex"), "w").write("\n".join(L) + "\n")19    # figure: stacked bars of sub-session tokens + builder; unknown shown as hatched placeholder20    labels = list(be["subagents"].keys()); toks = [be["subagents"][k]["tokens"] / 1e6 for k in labels]21    fig, ax = plt.subplots(figsize=(7.2, 2.6)); ax.barh(labels, toks, color="#4c72b0"); ax.set_xlabel("Tokens consumed by delegated sub-sessions (millions, client-reported)")22    ax.set_title("Builder-side effort: delegated sub-sessions (human preparation time unknown; builder session total in Table)", loc="left", fontsize=8); ax.invert_yaxis()23    fig.tight_layout(); fig.savefig(os.path.join(REPO, "results", "figures", "fig_effort.pdf")); print("\n".join(L[:8]))24if __name__ == "__main__": main()25
Files · 452964ee0fbbaa40fbbed2c87a54ca798ffd6a85
Menu

Theme