MCPcopy Create free account
hub / github.com/modelscope/modelscope / load_model_meta

Method load_model_meta

modelscope/hub/utils/caching.py:192–211  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

190 self.cached_model_revision = self.load_model_version()
191
192 def load_model_meta(self):
193 meta_file_path = os.path.join(self.cache_root_location,
194 FileSystemCache.MODEL_META_FILE_NAME)
195 if os.path.exists(meta_file_path):
196 try:
197 with open(meta_file_path, 'rb') as f:
198 data = pickle.load(f)
199 if isinstance(data, dict):
200 self.model_meta = data
201 return
202 logger.warning('Model meta %s has unexpected type, resetting.',
203 meta_file_path)
204 except Exception as e:
205 logger.warning('Failed to load model meta %s: %s. Resetting.',
206 meta_file_path, e)
207 try:
208 os.replace(meta_file_path, meta_file_path + '.corrupted')
209 except OSError:
210 pass
211 self.model_meta = {FileSystemCache.MODEL_META_MODEL_ID: 'unknown'}
212
213 def load_model_version(self):
214 model_version_file_path = os.path.join(

Callers 1

__init__Method · 0.95

Calls 3

replaceMethod · 0.80
existsMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected