"""Restore persisted code/weights to ephemeral root; never copies video media.""" from common import * import shutil PERSIST=Path('/workspace/styleedit-streaming-20261024');ASSETS=PERSIST/'runtime-assets' def copytreefiles(src,dst): src=Path(src);dst=Path(dst) for f in src.rglob('*'): if f.is_file() and '.git' not in f.relative_to(src).parts and '__pycache__' not in f.parts: to=dst/f.relative_to(src);to.parent.mkdir(parents=True,exist_ok=True) if not to.exists() or sha(f)!=sha(to):shutil.copyfile(f,to) def main(): copytreefiles('/workspace/style-cleaning-core-v1-20261024','/opt/style-cleaning-core-v1-20261024') copytreefiles('/workspace/style-data-curation/weights/vision-encoder','/opt/style-cleaning-core-v1-20261024/weights/vision-encoder') copytreefiles(ASSETS/'da3-weights','/opt/da3-large-weights') expected=json.loads((PERSIST/'model-provenance.json').read_text()) for name,digest in expected['da3_weight_sha256'].items(): if sha(Path('/opt/da3-large-weights')/name)!=digest:raise ValueError('DA3 weight hash mismatch') if not Path('/opt/depth-anything-3-code/.git').exists():subprocess.run(['git','clone',str(ASSETS/'da3-code.bundle'),'/opt/depth-anything-3-code'],check=True) actual=subprocess.check_output(['git','-C','/opt/depth-anything-3-code','rev-parse','HEAD'],text=True).strip() if actual!=expected['da3_commit']:raise ValueError('DA3 checkout differs; inspect before replacing it') print('Code and models restored and verified. Recreate venvs from environment files if needed.') if __name__=='__main__':main()