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

Function load

modelscope/utils/hf_util/patcher.py:850–878  ·  view source on GitHub ↗
(
        cls,
        repo_id_or_path: Union[str, Path],
        repo_type: Optional[str] = None,
        token: Optional[str] = None,
        ignore_metadata_errors: bool = False,
    )

Source from the content-addressed store, hash-verified

848 repo_type=repo_type or 'model')
849
850 def load(
851 cls,
852 repo_id_or_path: Union[str, Path],
853 repo_type: Optional[str] = None,
854 token: Optional[str] = None,
855 ignore_metadata_errors: bool = False,
856 ):
857 from modelscope.hub.api import HubApi
858 api = HubApi()
859 api.login(token)
860 if os.path.exists(repo_id_or_path):
861 file_path = repo_id_or_path
862 elif repo_type == 'model' or repo_type is None:
863 from modelscope import model_file_download
864 file_path = model_file_download(repo_id_or_path, 'README.md')
865 elif repo_type == 'dataset':
866 from modelscope import dataset_file_download
867 file_path = dataset_file_download(repo_id_or_path, 'README.md')
868 else:
869 raise ValueError(
870 f'repo_type should be `model` or `dataset`, but now is {repo_type}'
871 )
872
873 with open(file_path, 'r') as f:
874 repo_card = cls(
875 f.read(), ignore_metadata_errors=ignore_metadata_errors)
876 if not hasattr(repo_card.data, 'tags'):
877 repo_card.data.tags = []
878 return repo_card
879
880 # Patch repocard.validate
881 from huggingface_hub import repocard

Callers

nothing calls this directly

Calls 4

HubApiClass · 0.90
model_file_downloadFunction · 0.90
existsMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…