shanto268's picture
v4 flagship Space (3 tiers) from registry v2 (earlier contents: 906bc45ae05c)
f76c3bf verified
Raw History Blame Contribute Delete
1.5 kB
"""Integrity check of a Space bundle's checkpoint copies. deploy/sync.py --flagship ships each checkpoint without its train_keys (unused at
inference) and records both hashes in models/<tier>/info.json: <key>_sha256 = the published checkpoint (= registry, the provenance) and
<key>_bundle_sha256 = the shipped copy. install() makes geomgnn.paper check the copy against the latter; folders without
*_bundle_sha256 and the registry's source paths keep the registry check unchanged."""
from __future__ import annotations
import json
from pathlib import Path
from . import paper as PA
_REGISTRY_CHECK = PA._check
def _check(reg, name, model_dir=None):
md = PA._model_dir(model_dir)
info = Path(md) / name / "info.json" if md else None
z = json.loads(info.read_text()) if info is not None and info.exists() else {}
if "checkpoints_bundle_sha256" not in z:
return _REGISTRY_CHECK(reg, name, model_dir)
a = PA.arms(reg)[name]
for key in ("checkpoints", "surrogate"):
fs, hs = PA.files(reg, name, key, model_dir), z.get(key + "_bundle_sha256") or []
if z.get(key + "_sha256", []) != PA._hashes(a, key) or len(fs) != len(hs):
raise RuntimeError(f"{name}: {info} does not list the registry's {key} (sha256)")
for f, h in zip(fs, hs):
if PA._sha(f) != h:
raise RuntimeError(f"{name}: {f.name} SHA256 differs from the bundle manifest ({h[:12]})")
return a
def install() -> None:
PA._check = _check