import json, subprocess, sys
repo=sys.argv[1]
def show(p,c='624efc5'): return subprocess.run(['git','-C',repo,'show',f'{c}:{p}'],capture_output=True,check=True).stdout
H=json.loads(show('data/test/held_out_plots.json')); T=json.loads(show('data/test/test_set.json'))
bs={t['book'] for t in T}
for k,v in H.items():
    for b,x in v.items():
        if b in bs:
            print(k,list(x.keys()),{kk:(type(vv).__name__,len(vv) if hasattr(vv,'__len__') else vv) for kk,vv in x.items()})
            for kk,vv in x.items():
                if isinstance(vv,list) and vv and isinstance(vv[0],dict):
                    print(' item keys',list(vv[0].keys())[:12]); ips=[p.get('i_p') for p in vv]; print(' i_p',min(i for i in ips if i is not None),max(i for i in ips if i is not None),len(ips))
                    sc=sorted(t['plot']['i_p'] for t in T if t['book']==b); print(' scene i_p',sc,'covered',sum(i in ips for i in sc))
