"""Real source-data records and incomplete-release example, no model inference.""" from pathlib import Path import json from peppa.compiled import Node,Plan,execute,replay,release from peppa.data import normalize_snooppi from peppa.schema import digest root=Path(__file__).resolve().parents[1] rows=[json.loads(l) for l in (root/'examples/snooppi_raw.jsonl').read_text().splitlines()] def normalize(p,s):return {'normalized':[normalize_snooppi(r) for r in p['raw']]} def report(p,s): records=[{'id':digest({'sequence':r['partner_a'],'target':r['partner_b']}),'sequence':r['partner_a'],'source':r['source'],'source_label':r['label'],'chemistry_verified':False,'scores':{}} for r in p['normalized']] # Existing interaction labels are preserved as source annotations, not property predictions. obligations=[{'id':'pampa','unit':'log10(cm/s)','support':'calibrated','direction':'ge','threshold':-6,'scale':1}] return {'release_report':release(records,obligations)} registry={'normalize':{'revision':'1','run':normalize,'validate':lambda r:None},'report':{'revision':'1','run':report,'validate':lambda r:None}} plan=Plan((Node('01','normalize','1',('raw',),('normalized',)),Node('02','report','1',('normalized',),('release_report',))),('release_report',),2) cache={};out=execute(plan,{'raw':rows},registry,cache) assert replay(out['events'])==out['artifacts'] assert execute(plan,{'raw':rows},registry,cache)==out results=root/'results';results.mkdir(exist_ok=True) (results/'compiled_trace.jsonl').write_text(''.join(json.dumps(e,sort_keys=True)+'\n' for e in out['events'])) (results/'compiled_release.json').write_text(json.dumps(out['artifacts']['release_report'],indent=2)+'\n') print(json.dumps({'source_rows':len(rows),'complete_execution':out['complete'],'released_candidates':len(out['artifacts']['release_report']['selected']),'replay_equal':True,'cache_equal':True}))