File size: 992 Bytes
9a32825 | 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 | """Report measured recovery outcomes without treating infrastructure errors as trials."""
import argparse
import collections
import json
from pathlib import Path
def summarize(root):
rows = []
for path in Path(root).rglob('outcome.json'):
row = json.loads(path.read_text())
rows.append(dict(path=str(path.parent), **row))
trials = [r for r in rows if r.get('status') in ('completed', 'teacher_failure')]
return dict(runs=len(rows), valid_trials=len(trials),
successes=sum(bool(r.get('success')) for r in trials),
outcomes=dict(collections.Counter(r.get('status', 'unknown') for r in rows)),
rows=[{k:r.get(k) for k in ('path','status','success','steps','error','wall_seconds')}
for r in rows])
if __name__ == '__main__':
p = argparse.ArgumentParser(description=__doc__)
p.add_argument('runs', type=Path)
a = p.parse_args()
print(json.dumps(summarize(a.runs), indent=2))
|