MCPcopy Create free account
hub / github.com/AlayaLab/Hive / extract_commit_hash

Function extract_commit_hash

models/flowsep/diffusers/utils/hub_utils.py:151–162  ·  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

149
150
151def extract_commit_hash(resolved_file: Optional[str], commit_hash: Optional[str] = None):
152 """
153 Extracts the commit hash from a resolved filename toward a cache file.
154 """
155 if resolved_file is None or commit_hash is not None:
156 return commit_hash
157 resolved_file = str(Path(resolved_file).as_posix())
158 search = re.search(r"snapshots/([^/]+)/", resolved_file)
159 if search is None:
160 return None
161 commit_hash = search.groups()[0]
162 return commit_hash if REGEX_COMMIT_HASH.match(commit_hash) else None
163
164
165# Old default cache path, potentially to be migrated.

Callers 1

load_configMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected