"""Publish additional development source names and proposal checkpoints."""
import collections,html,json
from pathlib import Path
R=Path(__file__).resolve().parents[1];O=R/'results/r112/species-breadth';p=json.loads((O/'selection.json').read_text());a=json.loads((O/'assets.json').read_text());v=json.loads((O/'verify.json').read_text());E=html.escape;groups=collections.defaultdict(list)
for x in a['records']:groups[x['source_species']].append(x)
cards=[]
for name in sorted(groups):
 rows=groups[name];meta=p['per_name'][name];images=''.join('<figure><a href="'+E(x['source_crop'])+'"><img loading="lazy" src="'+E(x['source_crop'])+'" alt="Public source crop '+E(name)+'"></a><figcaption>'+E(x['annotation_id'])+'</figcaption></figure>' for x in rows);cards.append('<article><h3>'+E(name)+'</h3><p>Eight crops · '+str(meta['site_components'])+' conservative location components · '+str(meta['slide_filenames'])+' slide filenames'+(' · genus not in previous 80-name pool' if meta['genus_new_to_80_name_pool'] else '')+'</p><div class="grid">'+images+'</div></article>')
page='''<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Additional source-name breadth</title><style>body{font:16px/1.5 system-ui;color:#193b37;background:#f2f6f2;margin:0}main{max-width:1250px;margin:auto;padding:24px}a{color:#076c59}.notice{background:#fff8df;border-left:5px solid #b88418;padding:15px}article{background:white;border:1px solid #cbd8d1;padding:12px;margin:14px 0}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:7px}.grid img{width:100%;height:130px;object-fit:contain;background:#eee}figure{margin:0;font-size:.8rem}</style><main><nav><a href="/results/r112/">Synthetic training</a> · <a href="/results/r112/species-scaleup/">Previous 80-name pool</a></nav><h1>Additional source-name breadth</h1><p class="notice"><strong>Source crops, not finished training labels.</strong> The UDE authors reviewed the source names; they have not been independently reconciled with Academy taxonomy. Different strings may be synonyms or morphotypes. Crops can contain neighboring organisms; source annotations are rough and there are no expert-verified masks. Eight crops per name is limited coverage.</p><p>Metadata selection added 1,096 prior-development crops across 137 additional exact source-name strings and 55 source genera, including 33 genera absent from the preceding 80-name pool. Each name has eight selected crops from at least three conservative location components, with per-site and per-slide caps. These components are not proof of biological independence. Previously reserved or candidate-unseen components remain excluded; some selected crops and sites were previously used.</p><p>All 1,096 extracted grayscale images have been checked against the verified source archive. Three candidate masks have been generated for each crop and checked for file and geometric consistency. Model proposals and any agreement between them are not ground truth. <a href="mask-hypotheses/">Inspect one triad per source name.</a></p><p class="notice"><strong>Prior split exposure:</strong> 164 of these crops come from location groups assigned to the earlier 80-name check partition, and 148 from its tuning groups. The earlier check crop pixels were not opened, but training on this full pool would leak these location groups into that comparison. The location-restricted reader exposes 784 training-component crops. <a href="prior-split-exposure.json">Review the audit</a> · <a href="/diatom_pilot/ude_breadth_dataset.py">Reader</a></p><p id="proposal-status">Loading proposal checkpoint…</p><p><small>Progress is a saved checkpoint; it does not prove the process is still running.</small></p><p><a href="selection.json">Frozen selection</a> · <a href="selection-verify.json">Selection replay</a> · <a href="assets.json">Crop provenance</a> · <a href="verify.json">Pixel verification</a> · <a href="mask-hypotheses/protocol.json">Proposal protocol</a> · <a href="mask-hypotheses/progress.json">Proposal checkpoint</a></p><h2>Additional source-name scenes</h2><p>98 development fields use all 784 crops from the earlier training-location groups with separated, spread and clustered insertions. Masks and background organisms remain unverified.</p><p><a href="/results/r112/breadth-diverse-scenes/">Inspect all new fields and provenance</a></p><h2>Development reader</h2><p>Choose the location-restricted scope explicitly. The full scope includes prior tuning and check components and cannot support a location-unseen comparison with the older split.</p><pre>from diatom_pilot.ude_breadth_dataset import UDEBreadthDataset
data = UDEBreadthDataset("prior_training_components", include_unverified_masks=True)</pre><p><a href="reader-verify.json">Reader and proposal checks</a> · <a href="mask-hypotheses/verify.json">All proposal geometry checks</a></p><h2>All 137 source-name strings</h2><p>Click a crop to inspect native grayscale pixels. These source names are copied from the public dataset and are not a classifier's predictions.</p>'''+''.join(cards)+'''<script>async function poll(){let s=document.getElementById('proposal-status');try{let r=await fetch('mask-hypotheses/progress.json?t='+Date.now(),{cache:'no-store'});if(!r.ok)throw Error();let p=await r.json();let n=p.completed??p.processed_this_run??0;let total=p.total_sources??1096;s.textContent='Most recent proposal checkpoint: '+n+' / '+total+' crops; phase '+p.phase+'.';}catch(e){s.textContent='No proposal checkpoint is available yet.';}}poll();setInterval(poll,15000);</script></main></html>''';(O/'index.html').write_text(page);print('published',len(cards),'source-name galleries')
