MCPcopy
hub / github.com/huggingface/diffusers / extract_commit_hash

Function extract_commit_hash

src/diffusers/utils/hub_utils.py:204–215  ·  view source on GitHub ↗

Extracts the commit hash from a resolved filename toward a cache file.

(resolved_file: str | None, commit_hash: str | None = None)

Source from the content-addressed store, hash-verified

202
203
204def extract_commit_hash(resolved_file: str | None, commit_hash: str | None = None):
205 """
206 Extracts the commit hash from a resolved filename toward a cache file.
207 """
208 if resolved_file is None or commit_hash is not None:
209 return commit_hash
210 resolved_file = str(Path(resolved_file).as_posix())
211 search = re.search(r"snapshots/([^/]+)/", resolved_file)
212 if search is None:
213 return None
214 commit_hash = search.groups()[0]
215 return commit_hash if REGEX_COMMIT_HASH.match(commit_hash) else None
216
217
218def _add_variant(weights_name: str, variant: str | None = None) -> str:

Callers 1

load_configMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…