#!/usr/bin/env python3 from __future__ import annotations import argparse import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] BACKEND = ROOT / "backend" sys.path.insert(0, str(BACKEND)) from app.modules.weights.service import sync_weights # noqa: E402 def main() -> None: parser = argparse.ArgumentParser(description="Sync Seg weight files into Seg_Data_Server_Net/weights.") parser.add_argument("--mode", choices=["copy", "reflink", "hardlink"], default="copy") parser.add_argument("--hash", action="store_true", help="calculate sha256 for every copied weight") parser.add_argument("--no-skip-existing", action="store_true", help="recopy files even when size matches") args = parser.parse_args() manifest = sync_weights( mode=args.mode, hash_files=args.hash, skip_existing=not args.no_skip_existing, ) total_gb = manifest["total_bytes"] / 1024 / 1024 / 1024 print(f"synced {manifest['count']} weights, total {total_gb:.2f} GB") print("manifest:", ROOT / "weights" / "manifest.json") if __name__ == "__main__": main()