Datasets:
Download scripts/summarize_job.py from micro1-inc/MissionReport: direct link, hf CLI and curl.
- Browser
- Download file 2.78 kB
-
https://huggingface.co/datasets/micro1-inc/MissionReport/resolve/main/scripts/summarize_job.py
- Command line
-
hf download hf://datasets/micro1-inc/MissionReport/scripts/summarize_job.py
-
curl -L -o summarize_job.py https://huggingface.co/datasets/micro1-inc/MissionReport/resolve/main/scripts/summarize_job.py
2.78 kB
| #!/usr/bin/env python3 | |
| """Summarize a Harbor job (or trials directory) run on the MissionReport tasks. | |
| usage: python scripts/summarize_job.py <job or trials directory> [--criteria] | |
| Prints one line per trial: task, model, reward, positive points earned, penalty points triggered. | |
| With --criteria, also lists each criterion the report missed and each penalty it triggered, with | |
| the judge's one-line reason. Reads result.json and steps/answer/verifier/reward-details.json from | |
| each trial directory. Standard library only. | |
| """ | |
| import json | |
| import sys | |
| from pathlib import Path | |
| def criteria_of(trial: Path) -> list[dict]: | |
| details = trial / "steps" / "answer" / "verifier" / "reward-details.json" | |
| if not details.is_file(): | |
| return [] | |
| rubric = json.loads(details.read_text()).get("reward", {}).get("rubric") or {} | |
| return rubric.get("criteria") or [] | |
| def main() -> None: | |
| root = Path(sys.argv[1]) | |
| show = "--criteria" in sys.argv | |
| rewards = [] | |
| for result in sorted(root.rglob("result.json")): | |
| trial = result.parent | |
| data = json.loads(result.read_text()) | |
| if "trial_name" not in data: | |
| continue # the job-level result.json | |
| task = data.get("task_name", trial.name).split("/")[-1] | |
| model = ((data.get("agent_info") or {}).get("model_info") or {}).get("name") or data["agent_info"]["name"] | |
| reward = ((data.get("verifier_result") or {}).get("rewards") or {}).get("reward") | |
| error = (data.get("exception_info") or {}).get("exception_type") | |
| criteria = criteria_of(trial) | |
| earned = sum(c["signed_score"] for c in criteria if c["signed_score"] > 0 and c.get("raw")) | |
| possible = sum(c["signed_score"] for c in criteria if c["signed_score"] > 0) | |
| penalties = -sum(c["signed_score"] for c in criteria if c["signed_score"] < 0 and c.get("raw")) | |
| shown = "error: " + error if error else ("no reward" if reward is None else f"{reward:.3f}") | |
| print(f"{task:8} {model:32} {shown:>12} earned {earned:g}/{possible:g} penalties {penalties:g}") | |
| if reward is not None: | |
| rewards.append(reward) | |
| if show: | |
| for c in criteria: | |
| missed = c["signed_score"] > 0 and not c.get("raw") | |
| triggered = c["signed_score"] < 0 and c.get("raw") | |
| if missed or triggered: | |
| tag = "MISSED " if missed else "PENALTY" | |
| print(f" {tag} {c['signed_score']:+g} {c['description']}") | |
| if c.get("judge_reasoning"): | |
| print(f" judge: {c['judge_reasoning']}") | |
| if rewards: | |
| print(f"\n{len(rewards)} graded trials, mean reward {sum(rewards) / len(rewards):.3f}") | |
| if __name__ == "__main__": | |
| main() | |