Files
dj/integration-work/verify_composed_frame_deployment.py
T
2026-11-13 11:46:25 +08:00

33 lines
2.6 KiB
Python

"""Read-only data and installation verification after the first-frame feature upgrade."""
import hashlib,json,pathlib,sqlite3,sys,urllib.request
root=pathlib.Path(__file__).resolve().parent.parent
backup=pathlib.Path((root/'integration-work/current-upgrade-backup.txt').read_text('utf-8').strip())
def connect(path):return sqlite3.connect(path.as_uri()+'?mode=ro',uri=True)
with connect(backup/'huobao-data/huobao.sqlite3') as old,connect(root/'huobao-data/huobao.sqlite3') as live:
tables=[r[0] for r in old.execute("select name from sqlite_master where type='table' and name!='sqlite_sequence' order by name")]
for table in tables:
columns=[r[1] for r in old.execute(f'pragma table_info("{table}")')]
query='select '+','.join('"'+c+'"' for c in columns)+' from "'+table+'" order by rowid'
assert old.execute(query).fetchall()==live.execute(query).fetchall(),table+' changed'
assert live.execute('pragma integrity_check').fetchone()[0]=='ok'
counts={name:live.execute('select count(*) from '+name).fetchone()[0] for name in ['ai_service_configs','dramas','episodes','storyboards','style_presets']}
manifest=json.loads((backup/'manifest.json').read_text('utf-8'))
media=[item for item in manifest['data_files'] if item['path'].startswith('static/')]
for item in media:
assert hashlib.sha256((root/'huobao-data'/item['path']).read_bytes()).hexdigest()==item['sha256'],item['path']
runtime=root/'HuobaoDrama/resources'
build=json.loads((runtime/'huobao-local-build.json').read_text())
assert 'ltx-wan-all-reference-first-frame-composition' in build['custom_features']
assert hashlib.sha256((runtime/'app.asar').read_bytes()).hexdigest()==build['archive_sha256']
front=root/'huobao-source/frontend/.output/public'
for file in front.rglob('*'):
if file.is_file():assert file.read_bytes()==(runtime/'frontend'/file.relative_to(front)).read_bytes(),str(file)
launch=json.loads((root/'huobao-data/last-launch.json').read_text('utf-8'))
with urllib.request.urlopen(launch['api']+'/health',timeout=10) as response:assert response.status==200
report={'passed':True,'backup':str(backup),'database_tables_identical':len(tables),'media_files_unchanged':len(media),'counts':counts,'archive_sha256':build['archive_sha256'],'frontend_identical':True,'health':'ok','real_model_jobs_started':0}
report_name=sys.argv[1] if len(sys.argv)>1 else 'composed-frame-deployed-audit.json'
assert pathlib.Path(report_name).name==report_name and report_name.endswith('.json')
if report_name.startswith('video-cleanup'):assert 'verified-local-video-comfy-source-cleanup' in build['custom_features']
(root/'integration-work'/report_name).write_text(json.dumps(report,indent=2),'utf-8')
print(json.dumps(report))