MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / extract_commit_hash

Function extract_commit_hash

src/diffusers/utils/hub_utils.py:181–192  ·  view source on GitHub ↗

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

(resolved_file: Optional[str], commit_hash: Optional[str] = None)

Source from the content-addressed store, hash-verified

179
180
181def extract_commit_hash(resolved_file: Optional[str], commit_hash: Optional[str] = None):
182 """
183 Extracts the commit hash from a resolved filename toward a cache file.
184 """
185 if resolved_file is None or commit_hash is not None:
186 return commit_hash
187 resolved_file = str(Path(resolved_file).as_posix())
188 search = re.search(r"snapshots/([^/]+)/", resolved_file)
189 if search is None:
190 return None
191 commit_hash = search.groups()[0]
192 return commit_hash if REGEX_COMMIT_HASH.match(commit_hash) else None
193
194
195# Old default cache path, potentially to be migrated.

Callers 1

load_configMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected