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

Method from_path

modelscope/utils/repo_utils.py:421–428  ·  view source on GitHub ↗
(cls, path: str, file_hash_info: dict = None)

Source from the content-addressed store, hash-verified

419
420 @classmethod
421 def from_path(cls, path: str, file_hash_info: dict = None):
422 file_hash_info = file_hash_info or compute_file_hash(path)
423 size = file_hash_info['file_size']
424 sha = file_hash_info['file_hash']
425 with open(path, 'rb') as f:
426 sample = f.read(512)
427
428 return cls(sha256=sha, size=size, sample=sample)
429
430 @classmethod
431 def from_bytes(cls, data: bytes, file_hash_info: dict = None):

Callers 1

__post_init__Method · 0.80

Calls 2

compute_file_hashFunction · 0.90
readMethod · 0.45

Tested by

no test coverage detected