Skip to main content

model_registry.verify_checksums

model_registry.verify_checksums(path_model, missing_ok=True)

Re-hash the files checksums.json lists and report every discrepancy at once.

Only listed files are checked. Extra files are fine and expected: a Hub snapshot carries .gitattributes and a .cache/ tree, and the model card is deliberately not hashed.

Args: path_model (Path): Model directory to verify. missing_ok (bool, optional): When True (the default) a model with no checksums.json returns None rather than raising. The load path passes False – every published model ships checksums, so their absence there means an incomplete download. True remains the default for callers that only want to verify a directory when it happens to carry checksums.

Returns: bool | None: True when everything matches; None when there is nothing to check and missing_ok is set.

Raises: FileNotFoundError: If checksums.json is absent and missing_ok is False. ValueError: If any listed file is missing or its bytes have changed (the message names every offender, since fixing them one round trip at a time is miserable), or if checksums.json is itself unreadable or names a path outside the model directory.