suryatmodulus
/

GPC-1 / gpc1_server /bootstrap.py
suryatmodulus's picture harshatheg's picture
Duplicate from harshatheg/GPC-1
96a4100
Raw History Blame Contribute Delete
1.07 kB
"""Verify or copy the exact model bundled with this release."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
import shutil
from .assets import ASSET_ROOT,sha256_file
def main():
parser=argparse.ArgumentParser();parser.add_argument('--output',type=Path,required=True)
args=parser.parse_args();source=ASSET_ROOT.parent/'model'
inventory=json.loads((ASSET_ROOT/'base_files.sha256.json').read_text())
if args.output.resolve()!=source.resolve() and args.output.exists() and any(args.output.iterdir()):
raise RuntimeError('--output must be absent or empty')
for name,digest in inventory['files'].items():
if not (source/name).is_file() or sha256_file(source/name)!=digest:
raise RuntimeError(f'Bundled model identity mismatch: {name}')
if args.output.resolve()!=source.resolve():
args.output.mkdir(parents=True,exist_ok=True)
for name in inventory['files']:shutil.copyfile(source/name,args.output/name)
print(args.output.resolve())
if __name__=='__main__':main()