our_knp/pets-knp/bundle.py

19 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from pathlib import Path
import tarfile,hashlib,json
R=Path.home()/'run/pets-knp';S=Path.home()/'KNP/pets-knp';archive=R/'model-and-proofs.tar.gz';files=[]
for p in S.iterdir():
if p.is_file():files.append((p,'source/'+p.name))
for name in ['detectors','head-v2','head','checks','deployment-checks','eval-v2-smoke','eval-v2-final']:
for p in (R/name).rglob('*'):
if p.is_file():files.append((p,'runtime/'+str(p.relative_to(R))))
for name in ['dataset-manifest.json','final-summary.json','training-counts.npz','head-training.log','training-v2.log','encoding.log','collection.log','verify.log','eval-v2-final.log','api-checks.json','browser-checks.json','pets-desktop.png','pets-mobile.png','safe-scale-regression.json','pets_infer','pets_hidden','pets_readout','pets_worker']:
p=R/name
if p.is_file():files.append((p,'runtime/'+name))
for p in (R/'data').glob('*.npz'):files.append((p,'runtime/data/'+p.name))
for p in R.glob('*-build.json'):files.append((p,'runtime/'+p.name))
report=Path.home()/'KNP/reports/2026-10-15/Отчёт_Кошки_собаки.md'
if report.exists():files.append((report,'REPORT.md'))
with tarfile.open(archive,'w:gz') as t:
for i,(p,rel) in enumerate(files):
t.add(p,arcname=rel,recursive=False);(R/'bundle-progress.json').write_text(json.dumps({'current':i+1,'total':len(files),'done':i+1==len(files)}))
sha=hashlib.sha256(archive.read_bytes()).hexdigest();(R/'model-and-proofs.tar.gz.sha256').write_text(sha+' '+archive.name+'\n');print(json.dumps({'bytes':archive.stat().st_size,'members':len(files),'sha256':sha}))