Archive 4 checkpoints (1-4)
Browse files- paper-releases/pbisc-diffusion/updates/20261013T124345Z-trunk4x-lora-sepsis-launch/diffusion/dataset/server_1/model8/plans/trunk4x_lora_sepsis_20261013/reuse_candidates.json +1 -0
- paper-releases/pbisc-diffusion/updates/20261013T124345Z-trunk4x-lora-sepsis-launch/diffusion/dataset/server_1/model8/plans/trunk4x_lora_sepsis_20261013/tools/collect_and_score.py +56 -0
- paper-releases/pbisc-diffusion/updates/20261013T124345Z-trunk4x-lora-sepsis-launch/diffusion/dataset/server_1/model8/plans/trunk4x_lora_sepsis_20261013/tools/evaluate.py +116 -0
- paper-releases/pbisc-diffusion/updates/20261013T124345Z-trunk4x-lora-sepsis-launch/diffusion/dataset/server_1/model8/plans/trunk4x_lora_sepsis_20261013/tools/finalize_archive.py +36 -0
paper-releases/pbisc-diffusion/updates/20261013T124345Z-trunk4x-lora-sepsis-launch/diffusion/dataset/server_1/model8/plans/trunk4x_lora_sepsis_20261013/reuse_candidates.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[]
|
paper-releases/pbisc-diffusion/updates/20261013T124345Z-trunk4x-lora-sepsis-launch/diffusion/dataset/server_1/model8/plans/trunk4x_lora_sepsis_20261013/tools/collect_and_score.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Durable CPU collector: copy only completed immutable remote outputs, then compare."""
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from datetime import datetime,timezone
|
| 4 |
+
import os,sys,json,subprocess,time,hashlib
|
| 5 |
+
assert os.environ.get('CUDA_VISIBLE_DEVICES')==''
|
| 6 |
+
ROOT=Path(__file__).resolve().parents[1]
|
| 7 |
+
def state(phase,**kw):
|
| 8 |
+
j=dict(phase=phase,at=datetime.now(timezone.utc).isoformat(),**kw);p=ROOT/'STATUS.tmp';p.write_text(json.dumps(j,indent=2)+'\n');p.replace(ROOT/'STATUS.json');print(json.dumps(j),flush=True)
|
| 9 |
+
def remote(path):
|
| 10 |
+
p=subprocess.run(['ssh','-o','BatchMode=yes','-o','ConnectTimeout=10','spark-0110','cat '+str(path)],text=True,capture_output=True)
|
| 11 |
+
if p.returncode:return None
|
| 12 |
+
return json.loads(p.stdout)
|
| 13 |
+
def sha(p):
|
| 14 |
+
with Path(p).open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest()
|
| 15 |
+
def main():
|
| 16 |
+
protocol=json.loads((ROOT/'ANALYSIS_PROTOCOL.json').read_text())
|
| 17 |
+
assert all(sha(Path(p))==h for p,h in protocol['code_hashes'].items())
|
| 18 |
+
deadline=time.monotonic()+24*3600
|
| 19 |
+
for draw in range(5):
|
| 20 |
+
while True:
|
| 21 |
+
if time.monotonic()>deadline:raise RuntimeError('24h observation limit; GPU job not cancelled')
|
| 22 |
+
status=remote(ROOT/'GPU_STATUS.json')
|
| 23 |
+
if status and status['phase']=='failed':raise RuntimeError('GPU campaign failed: '+str(status))
|
| 24 |
+
receipts={arm:remote(ROOT/f'completed/{arm}_draw{draw}.json') for arm in ['trunk4x','panel_matched_1x']}
|
| 25 |
+
if all(receipts.values()):break
|
| 26 |
+
state('waiting_gpu',draw=draw,remote_status=status);time.sleep(30)
|
| 27 |
+
for arm,rec in receipts.items():
|
| 28 |
+
gen=ROOT/f'generated/{arm}/draw{draw}';gen.mkdir(parents=True,exist_ok=True)
|
| 29 |
+
subprocess.run(['rsync','-a','--partial','--','spark-0110:'+str(gen)+'/',str(gen)+'/'],check=True)
|
| 30 |
+
assert sha(gen/'cells.npz')==rec['output_sha256']
|
| 31 |
+
dst=ROOT/f'runs/{arm}/draw{draw}';dst.mkdir(parents=True,exist_ok=True)
|
| 32 |
+
subprocess.run(['rsync','-a','--include=*.json','--include=*.log','--exclude=*','--','spark-0110:'+str(dst)+'/',str(dst)+'/'],check=True)
|
| 33 |
+
(ROOT/'completed').mkdir(exist_ok=True);(ROOT/f'completed/{arm}_draw{draw}.json').write_text(json.dumps(rec,indent=2)+'\n')
|
| 34 |
+
while not (ROOT/'reference/READY.json').exists():
|
| 35 |
+
if time.monotonic()>deadline:raise RuntimeError('Reference never became ready')
|
| 36 |
+
unit=subprocess.check_output(['systemctl','--user','show','pbisc-trunk4x-reference-20261013','-p','ActiveState','--value'],text=True).strip()
|
| 37 |
+
if unit not in ['active','activating']:raise RuntimeError('Reference builder stopped without READY')
|
| 38 |
+
time.sleep(10)
|
| 39 |
+
available=int(Path('/proc/meminfo').read_text().split('MemAvailable:')[1].split()[0])/1048576
|
| 40 |
+
while available<56:
|
| 41 |
+
state('waiting_cpu_headroom',available_gib=available);time.sleep(30)
|
| 42 |
+
available=int(Path('/proc/meminfo').read_text().split('MemAvailable:')[1].split()[0])/1048576
|
| 43 |
+
assert all(sha(Path(p))==h for p,h in protocol['code_hashes'].items())
|
| 44 |
+
state('scoring',draw=draw)
|
| 45 |
+
subprocess.run([sys.executable,str(ROOT/'tools/evaluate.py'),'--draw',str(draw)],check=True)
|
| 46 |
+
state('summarizing')
|
| 47 |
+
subprocess.run([sys.executable,str(ROOT/'tools/evaluate.py'),'--summarize'],check=True)
|
| 48 |
+
state('results_complete_archiving',report=str(ROOT/'RESULT.json'))
|
| 49 |
+
try:
|
| 50 |
+
subprocess.run([sys.executable,str(ROOT/'tools/finalize_archive.py')],check=True)
|
| 51 |
+
except subprocess.CalledProcessError as e:
|
| 52 |
+
state('results_complete_archive_pending',report=str(ROOT/'RESULT.json'),error=str(e));return
|
| 53 |
+
state('complete',report=str(ROOT/'RESULT.json'),table=str(ROOT/'COMPARISON.csv'),remote_checkpoints_preserved=True,archive=str(ROOT/'FINAL_ARCHIVE.json'))
|
| 54 |
+
if __name__=='__main__':
|
| 55 |
+
try:main()
|
| 56 |
+
except BaseException as e:state('failed',error=str(e));raise
|
paper-releases/pbisc-diffusion/updates/20261013T124345Z-trunk4x-lora-sepsis-launch/diffusion/dataset/server_1/model8/plans/trunk4x_lora_sepsis_20261013/tools/evaluate.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""CPU common-axis evaluation using frozen benchmark code and observed labels."""
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import os,sys,json,hashlib,subprocess,shutil,dataclasses,argparse
|
| 4 |
+
import numpy as np
|
| 5 |
+
import pandas as pd
|
| 6 |
+
from scipy import sparse
|
| 7 |
+
assert os.environ.get('CUDA_VISIBLE_DEVICES')==''
|
| 8 |
+
ROOT=Path(__file__).resolve().parents[1];M=ROOT.parents[1];F=M/'plans/paired_finetune_intradataset_20260927';S=M/'plans/paper_figures_strictpairs_20261012'
|
| 9 |
+
sys.path.insert(0,str(F/'tools'))
|
| 10 |
+
import ft_common as C
|
| 11 |
+
|
| 12 |
+
def sha(p):
|
| 13 |
+
with Path(p).open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest()
|
| 14 |
+
def write(p,x):p.parent.mkdir(parents=True,exist_ok=True);p.write_text(json.dumps(x,indent=2,default=str)+'\n')
|
| 15 |
+
def build_reference():
|
| 16 |
+
ref=ROOT/'reference';done=ref/'READY.json'
|
| 17 |
+
if done.exists():
|
| 18 |
+
j=json.loads(done.read_text());assert all(sha(Path(p))==h for p,h in j['files'].items());return
|
| 19 |
+
genes=np.array((ROOT/'data/common_genes.txt').read_text().splitlines());ds=F/'data/ye2026_sepsis';out=ROOT/'evaluation_data/ye2026_sepsis';out.mkdir(parents=True,exist_ok=True)
|
| 20 |
+
with np.load(ds/'cells_panel6k.npz') as z:
|
| 21 |
+
old=z['panel_gene_ids'].astype(str);cols=np.array([list(old).index(g) for g in genes]);x=sparse.csr_matrix((z['data'],z['indices'],z['indptr']),shape=tuple(z['shape']));x=x[:,cols].tocsr()
|
| 22 |
+
np.savez_compressed(out/'cells_panel6k.npz',data=x.data,indices=x.indices,indptr=x.indptr,shape=np.array(x.shape),row_sample=z['row_sample'],panel_gene_ids=genes,panel_measured=z['panel_measured'][:,cols]);del x
|
| 23 |
+
for name in ['cells_obs.parquet','features.npz']:
|
| 24 |
+
p=out/name
|
| 25 |
+
if not p.exists():p.symlink_to(ds/name)
|
| 26 |
+
spec=dataclasses.replace(C.DATASETS['ye2026_sepsis'],data_dir=out);C.DATASETS['ye2026_sepsis']=spec
|
| 27 |
+
panel=C.IC.load_panel6k();panel=panel.set_index('gene_id').loc[list(genes)].reset_index();C.IC.load_panel6k=lambda:panel.copy()
|
| 28 |
+
oldref=F/'scoring_cache/ye2026_sepsis';oldman=json.loads((oldref/'reference_manifest.json').read_text());labels=oldref/'observed_labels/labels/labels.parquet';lab=pd.read_parquet(labels)
|
| 29 |
+
def reuse_observed(counts,query_ids,sample_ids,**kw):
|
| 30 |
+
with np.load(oldref/'reference.npz') as z:assert np.array_equal(query_ids,z['query_ids'])
|
| 31 |
+
assert counts.shape==(len(lab),1006)
|
| 32 |
+
assert np.array_equal(lab.npz_row.to_numpy(),np.arange(len(lab)))
|
| 33 |
+
assert np.array_equal(lab.sample_id.astype(str).to_numpy(),sample_ids.astype(str))
|
| 34 |
+
p=ref/'observed_labels/labels/labels.parquet';p.parent.mkdir(parents=True,exist_ok=True)
|
| 35 |
+
if not p.exists():p.symlink_to(labels)
|
| 36 |
+
info=dict(oldman['labels']);info['reused_frozen_observed_labels']=True;info['labels_parquet']=str(p)
|
| 37 |
+
return lab.copy(),info
|
| 38 |
+
C.run_annotator=reuse_observed
|
| 39 |
+
C.build_reference(spec,ref,source='datadir',threads=4,annot=C.annotator_run())
|
| 40 |
+
if not (ref/'deg_reference.npz').exists():C.build_deg_reference(spec,ref)
|
| 41 |
+
write(done,{'common_panel_genes':len(genes),'original_panel_genes':6000,'observed_labels_reused':str(labels),'source_cells_sha256':sha(ds/'cells_panel6k.npz'),'files':{str(ref/f):sha(ref/f) for f in ['reference.npz','reference_manifest.json','deg_reference.npz','deg_reference_manifest.json']},'interpretation':'All arms rescored on common axis; original headline values are not directly pooled.'})
|
| 42 |
+
print('common reference READY',flush=True)
|
| 43 |
+
|
| 44 |
+
def project(source,out):
|
| 45 |
+
if out.exists():
|
| 46 |
+
rec=json.loads(out.with_suffix('.log').read_text());assert rec['output_sha256']==sha(out) and rec['derived_from_sha256']==sha(source);return
|
| 47 |
+
original_receipt=json.loads(source.with_suffix('.log').read_text());assert original_receipt['output_sha256']==sha(source)
|
| 48 |
+
genes=np.array((ROOT/'data/common_genes.txt').read_text().splitlines());z=np.load(source,allow_pickle=False)
|
| 49 |
+
cols=np.array([list(z['gene_ids'].astype(str)).index(g) for g in genes]);rates=z['generated_counts'][:,cols].astype(np.float32)
|
| 50 |
+
meta=json.loads(str(z['metadata_json'].item()));meta['common_axis_projection']={'source':str(source),'source_sha256':sha(source),'n_genes':len(genes),'stage':'before identical scorer Poisson readout'}
|
| 51 |
+
out.parent.mkdir(parents=True,exist_ok=True)
|
| 52 |
+
np.savez_compressed(out,generated_counts=rates,gene_ids=genes,sample_ids=z['sample_ids'],bulk_index=z['bulk_index'],metadata_json=np.array(json.dumps(meta)))
|
| 53 |
+
write(out.with_suffix('.log'),{'output_sha256':sha(out),'derived_from':str(source),'derived_from_sha256':sha(source),'operation':'CPU gene-axis projection; not new inference','condition_npz':meta.get('input_condition_path'),'condition_sha256':meta.get('input_condition_sha256')})
|
| 54 |
+
|
| 55 |
+
def score(draw,baseline_only=False):
|
| 56 |
+
build_reference();out=ROOT/(f'baseline_check/draw{draw}' if baseline_only else f'scores/draw{draw}')
|
| 57 |
+
if (out/'summary.json').exists():return
|
| 58 |
+
sources={'trunk4x':ROOT/f'generated/trunk4x/draw{draw}/cells.npz','panel_matched_1x':ROOT/f'generated/panel_matched_1x/draw{draw}/cells.npz','current_f01':S/f'generated/ye2026_sepsis/disease/draw{draw}/lora.npz','scsemi':S/f'generated/ye2026_sepsis/disease/draw{draw}/scsemi.npz'}
|
| 59 |
+
if baseline_only:sources={k:v for k,v in sources.items() if k in ['current_f01','scsemi']}
|
| 60 |
+
support=json.loads((ROOT/f'data/draw{draw}/ye2026_sepsis/support.json').read_text())
|
| 61 |
+
out.mkdir(parents=True,exist_ok=True);donorfile=out/'test_samples.txt';donorfile.write_text('\n'.join(support['test_sample_ids'])+'\n')
|
| 62 |
+
cmd=['/home/sj_server_1/miniforge3/envs/cxg_corpus/bin/python',str(F/'tools/score_ft.py'),'--dataset','ye2026_sepsis','--reference',str(ROOT/'reference'),'--out',str(out),'--threads','4','--donors',str(donorfile),'--case-groups','adult_sepsis,ped_sepsis','--control-groups','adult_HC,adult_ICU_ctrl,ped_HC,ped_ICU_ctrl']
|
| 63 |
+
for arm,source in sources.items():
|
| 64 |
+
with np.load(source) as z:assert set(z['sample_ids'].astype(str))==set(support['test_sample_ids'])
|
| 65 |
+
p=ROOT/f'projected/draw{draw}/{arm}.npz';project(source,p);cmd+=['--arm',f'{arm}={p}','--condition',f'{arm}={ROOT}/data/draw{draw}/ye2026_sepsis/test_raw.npz']
|
| 66 |
+
logs=ROOT/'logs';logs.mkdir(exist_ok=True)
|
| 67 |
+
with (logs/f'score_{baseline_only}_draw{draw}.log').open('x') as stream:subprocess.run(cmd,stdout=stream,stderr=subprocess.STDOUT,check=True)
|
| 68 |
+
summary=json.loads((out/'summary.json').read_text());assert summary['n_donors']==77 and summary['contrast_definition']['enabled']
|
| 69 |
+
write(out/'COMPARISON_RECEIPT.json',{'draw':draw,'support_sha256':support['sha256'],'sources':{k:{'path':str(p),'sha256':sha(p)} for k,p in sources.items()},'reference_ready_sha256':sha(ROOT/'reference/READY.json'),'score_code_sha256':sha(F/'tools/score_ft.py'),'note':'Native common-axis readout; donor-aware Welch benchmark DEG. Draws are overlapping, not independent biological replicates.'})
|
| 70 |
+
print('SCORED',draw,flush=True)
|
| 71 |
+
|
| 72 |
+
def summarize():
|
| 73 |
+
allrows=[]
|
| 74 |
+
for draw in range(5):
|
| 75 |
+
j=json.loads((ROOT/f'scores/draw{draw}/summary.json').read_text())
|
| 76 |
+
for arm,s in j['per_arm'].items():
|
| 77 |
+
c=s.get('contrast',{}).get('mean_cp10k',{});allrows.append({'draw':draw,'arm':arm,'composition_l1':s['composition']['l1_mean'],'precision':s['precision_coverage']['precision'],'coverage':s['precision_coverage']['coverage'],'expression_r':s['pseudobulk']['r_median'],'logfc_r':c.get('mean_r_generated'),'partial_r':c.get('mean_partial_r'),'deg_overlap':s.get('deg_top50',{}).get('sum')})
|
| 78 |
+
for row in allrows:
|
| 79 |
+
arm,draw=row['arm'],row['draw']
|
| 80 |
+
runpath=(ROOT/f'runs/{arm}/draw{draw}/RUN.json' if arm in ['trunk4x','panel_matched_1x'] else F/f'runs/ye2026_sepsis/fewshot_n5/draw{draw}/lora/RUN.json' if arm=='current_f01' else None)
|
| 81 |
+
if runpath is not None:
|
| 82 |
+
r=json.loads(runpath.read_text());row.update(training_seconds=r['wall_seconds'],base_parameters=r['trainable']['n_total_base'],trainable_parameters=r['trainable']['n_trainable'])
|
| 83 |
+
table=pd.DataFrame(allrows);table.to_csv(ROOT/'COMPARISON.csv',index=False)
|
| 84 |
+
table.groupby('arm').mean(numeric_only=True).drop(columns='draw').to_csv(ROOT/'COMPARISON_MEANS.csv')
|
| 85 |
+
sys.path.insert(0,str(S/'tools'))
|
| 86 |
+
from donor_statistics import paired_donor_bootstrap
|
| 87 |
+
per=[]
|
| 88 |
+
for draw in range(5):
|
| 89 |
+
d=pd.read_csv(ROOT/f'scores/draw{draw}/per_donor.csv');d['draw']=draw;d['donor_id']=d['donor'].astype(str);d['sample_id']=d['donor_id'];per.append(d)
|
| 90 |
+
per=pd.concat(per,ignore_index=True);ci=[]
|
| 91 |
+
for metric in ['comp_l1','precision','coverage','pb_r']:
|
| 92 |
+
for baseline in ['panel_matched_1x','current_f01','scsemi']:
|
| 93 |
+
result=paired_donor_bootstrap(per.rename(columns={metric:'value'}),'trunk4x',baseline,n_boot=2000,seed=20261013);result['metric']=metric;ci.append(result)
|
| 94 |
+
pd.DataFrame(ci).to_csv(ROOT/'DONOR_PAIRED_CI.csv',index=False)
|
| 95 |
+
import matplotlib
|
| 96 |
+
matplotlib.use('Agg')
|
| 97 |
+
import matplotlib.pyplot as plt
|
| 98 |
+
plt.rcParams.update({'font.family':'sans-serif','font.sans-serif':['Arial','Liberation Sans'],'font.size':11,'axes.spines.top':False,'axes.spines.right':False,'pdf.fonttype':42})
|
| 99 |
+
arms=['panel_matched_1x','trunk4x','current_f01','scsemi'];names=['Matched ×1','Trunk ×4','Current ×1','scSemi'];colors=['#0D6EA8','#168FE5','#59A8DF','#83C6A8']
|
| 100 |
+
fig,axes=plt.subplots(2,3,figsize=(12.3,6.5))
|
| 101 |
+
for ax,metric,label in zip(axes.flat,['logfc_r','partial_r','deg_overlap','composition_l1','precision','coverage'],['Disease logFC r ↑','Partial r | bulk ↑','Top-50 DEG overlap ↑','Composition L1 ↓','Precision ↑','Coverage ↑']):
|
| 102 |
+
for i,arm in enumerate(arms):
|
| 103 |
+
v=table.loc[table.arm==arm,metric].to_numpy(float);ax.bar(i,np.nanmean(v),color=colors[i],width=.65);ax.scatter(i+np.linspace(-.14,.14,len(v)),v,s=20,facecolors='white',edgecolors='#45525C',zorder=3)
|
| 104 |
+
ax.set_xticks(range(4),names,rotation=15,ha='right');ax.set_title(label);ax.axhline(0,color='#ABB4BB',lw=.6)
|
| 105 |
+
fig.suptitle('Sepsis: five paired supports, five fixed support draws',fontsize=16)
|
| 106 |
+
fig.text(.5,.01,'Common gene axis; dots are overlapping support draws, not independent replicates. Matched ×1 and trunk ×4 share the pretraining panel.',ha='center',fontsize=9)
|
| 107 |
+
fig.tight_layout(rect=(0,.04,1,.96))
|
| 108 |
+
for ext in ['png','pdf','svg']:fig.savefig(ROOT/f'COMPARISON.{ext}',dpi=200)
|
| 109 |
+
plt.close(fig)
|
| 110 |
+
|
| 111 |
+
write(ROOT/'RESULT.json',{'phase':'complete','draws':5,'arms':4,'new_pretraining':False,'new_adapters':10,'comparison':'Same-panel x1 vs trunkx4 is primary; current_f01 is a different-panel baseline. All expression scores use common4258 genes.','table':str(ROOT/'COMPARISON.csv'),'details':[str(ROOT/f'scores/draw{i}/summary.json') for i in range(5)]})
|
| 112 |
+
if __name__=='__main__':
|
| 113 |
+
p=argparse.ArgumentParser();p.add_argument('--baseline-only',action='store_true');p.add_argument('--build-reference',action='store_true');p.add_argument('--draw',type=int);p.add_argument('--summarize',action='store_true');a=p.parse_args()
|
| 114 |
+
if a.build_reference:build_reference()
|
| 115 |
+
elif a.draw is not None:score(a.draw,a.baseline_only)
|
| 116 |
+
elif a.summarize:summarize()
|
paper-releases/pbisc-diffusion/updates/20261013T124345Z-trunk4x-lora-sepsis-launch/diffusion/dataset/server_1/model8/plans/trunk4x_lora_sepsis_20261013/tools/finalize_archive.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Publish only completed comparison results and remote adapter checkpoints."""
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from datetime import datetime,timezone
|
| 4 |
+
import json,subprocess,sys
|
| 5 |
+
ROOT=Path(__file__).resolve().parents[1];M=ROOT.parents[1];CLI=M.parents[1]/'paper-release-20260928/maintenance/update.py'
|
| 6 |
+
def main():
|
| 7 |
+
assert json.loads((ROOT/'RESULT.json').read_text())['phase']=='complete'
|
| 8 |
+
assets=[]
|
| 9 |
+
for p in [ROOT/'RESULT.json',ROOT/'COMPARISON.csv',ROOT/'COMPARISON_MEANS.csv',ROOT/'DONOR_PAIRED_CI.csv',*[ROOT/f'COMPARISON.{e}' for e in ['png','pdf','svg']]]:
|
| 10 |
+
assets.append({'host':'server_1','source':str(p),'kind':'report','state':'completed'})
|
| 11 |
+
locations=[]
|
| 12 |
+
for draw in range(5):
|
| 13 |
+
folder=ROOT/f'scores/draw{draw}'
|
| 14 |
+
for p in folder.rglob('*'):
|
| 15 |
+
if p.is_file() and p.suffix in ['.json','.csv','.md'] and 'labels' not in p.parts:
|
| 16 |
+
assets.append({'host':'server_1','source':str(p),'kind':'report','state':'completed'})
|
| 17 |
+
for arm in ['trunk4x','panel_matched_1x']:
|
| 18 |
+
rec=json.loads((ROOT/f'completed/{arm}_draw{draw}.json').read_text());run=ROOT/f'runs/{arm}/draw{draw}'
|
| 19 |
+
for name in ['RUN.json','checkpoint_ft.pt']:
|
| 20 |
+
assets.append({'host':'server_2','source':str(run/name),'kind':'checkpoint' if name.endswith('.pt') else 'report','state':'completed'})
|
| 21 |
+
gen=ROOT/f'generated/{arm}/draw{draw}/cells.npz'
|
| 22 |
+
locations.append({'host':'server_1','path':str(gen),'state':'completed','sha256':rec['output_sha256'],'receipt':str(gen.with_suffix('.log')),'reason':'Trunk-width LoRA matched-panel Sepsis benchmark; no new pretraining.'})
|
| 23 |
+
request=ROOT/'final_archive_request.json';request.write_text(json.dumps({'project_id':'pbisc-diffusion','summary':'Completed matched-panel x1/trunkx4 Sepsis LoRA comparison:5 exact-five support draws, common-axis four-arm scores, donor CIs;10new adapters.','assets':assets,'inference_locations':locations},indent=2)+'\n')
|
| 24 |
+
ident=datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ')+'-trunk4x-sepsis-results'
|
| 25 |
+
with (ROOT/'final_archive.log').open('x') as log:
|
| 26 |
+
subprocess.run(['/home/sj_server_1/miniforge3/bin/python',str(CLI),'prepare','--request',str(request),'--id',ident],check=True,stdout=log,stderr=subprocess.STDOUT)
|
| 27 |
+
prepared=json.loads((CLI.parent/'updates'/ident/'manifest.json').read_text())
|
| 28 |
+
assert {(x['host'],x['source']) for x in prepared['assets'] if x['category']!='update_metadata'} <= {(x['host'],x['source']) for x in assets}
|
| 29 |
+
assert all(x['repo_id'] in ['junidude14/PBISC-data','junidude14/PBISC'] for x in prepared['assets'])
|
| 30 |
+
subprocess.run(['/home/sj_server_1/miniforge3/bin/python',str(CLI),'publish',ident,'--execute'],check=True,stdout=log,stderr=subprocess.STDOUT)
|
| 31 |
+
receipt=CLI.parent/'updates'/ident/'UPDATE_VERIFIED.json'
|
| 32 |
+
assert json.loads(receipt.read_text())['status']=='PASS'
|
| 33 |
+
assert json.loads((CLI.parent.parent/'LATEST.json').read_text())['id']==ident
|
| 34 |
+
assert json.loads((CLI.parent.parent/'CURRENT_CATALOG.json').read_text())['latest_id']==ident
|
| 35 |
+
(ROOT/'FINAL_ARCHIVE.json').write_text(json.dumps({'update_id':ident,'verified_receipt':str(CLI.parent/'updates'/ident/'UPDATE_VERIFIED.json')},indent=2)+'\n')
|
| 36 |
+
if __name__=='__main__':main()
|