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

Method __init__

modelscope/hub/utils/caching.py:167–190  ·  view source on GitHub ↗

Put file to the cache Args: cache_root(`str`): The modelscope local cache root(default: ~/.cache/modelscope/hub) owner(`str`): The model owner. name('str'): The name of the model Returns: Raises: None m

(self, cache_root, owner=None, name=None)

Source from the content-addressed store, hash-verified

165 """
166
167 def __init__(self, cache_root, owner=None, name=None):
168 """Put file to the cache
169 Args:
170 cache_root(`str`): The modelscope local cache root(default: ~/.cache/modelscope/hub)
171 owner(`str`): The model owner.
172 name('str'): The name of the model
173 Returns:
174 Raises:
175 None
176 <Tip>
177 model_id = {owner}/{name}
178 </Tip>
179 """
180 if owner is None or name is None:
181 # get model meta from
182 super().__init__(os.path.join(cache_root))
183 self.load_model_meta()
184 else:
185 super().__init__(os.path.join(cache_root, owner, name))
186 self.model_meta = {
187 FileSystemCache.MODEL_META_MODEL_ID: '%s/%s' % (owner, name)
188 }
189 self.save_model_meta()
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,

Callers

nothing calls this directly

Calls 4

load_model_metaMethod · 0.95
save_model_metaMethod · 0.95
load_model_versionMethod · 0.95
__init__Method · 0.45

Tested by

no test coverage detected