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

Function _unpatch_hub

modelscope/utils/hf_util/patcher.py:942–999  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

940
941
942def _unpatch_hub():
943 import huggingface_hub
944 from huggingface_hub import hf_api
945
946 from huggingface_hub import repocard
947 if hasattr(repocard.RepoCard, '_validate_origin'):
948 repocard.RepoCard.validate = repocard.RepoCard._validate_origin
949 delattr(repocard.RepoCard, '_validate_origin')
950 if hasattr(repocard.RepoCard, '_load_origin'):
951 repocard.RepoCard.load = repocard.RepoCard._load_origin
952 delattr(repocard.RepoCard, '_load_origin')
953
954 if hasattr(hf_api, '_hf_hub_download_origin'):
955 huggingface_hub.file_download.hf_hub_download = hf_api._hf_hub_download_origin
956 huggingface_hub.hf_hub_download = hf_api._hf_hub_download_origin
957 huggingface_hub.file_download.hf_hub_download = hf_api._hf_hub_download_origin
958 delattr(hf_api, '_hf_hub_download_origin')
959
960 if hasattr(hf_api, '_file_exists_origin'):
961 hf_api.file_exists = hf_api._file_exists_origin
962 huggingface_hub.file_exists = hf_api.file_exists
963 huggingface_hub.hf_api.file_exists = hf_api.file_exists
964 delattr(hf_api, '_file_exists_origin')
965
966 if hasattr(hf_api, '_whoami_origin'):
967 hf_api.whoami = hf_api._whoami_origin
968 huggingface_hub.whoami = hf_api.whoami
969 huggingface_hub.hf_api.whoami = hf_api.whoami
970 delattr(hf_api, '_whoami_origin')
971
972 if hasattr(hf_api, '_create_repo_origin'):
973 from transformers.utils import hub
974 hf_api.create_repo = hf_api._create_repo_origin
975 huggingface_hub.create_repo = hf_api.create_repo
976 huggingface_hub.hf_api.create_repo = hf_api.create_repo
977 hub.create_repo = hf_api.create_repo
978 delattr(hf_api, '_create_repo_origin')
979
980 if hasattr(hf_api, '_upload_folder_origin'):
981 hf_api.upload_folder = hf_api._upload_folder_origin
982 huggingface_hub.upload_folder = hf_api.upload_folder
983 huggingface_hub.hf_api.upload_folder = hf_api.upload_folder
984 delattr(hf_api, '_upload_folder_origin')
985
986 if hasattr(hf_api, '_upload_file_origin'):
987 hf_api.upload_file = hf_api._upload_file_origin
988 huggingface_hub.upload_file = hf_api.upload_file
989 huggingface_hub.hf_api.upload_file = hf_api.upload_file
990 repocard.upload_file = hf_api.upload_file
991 delattr(hf_api, '_upload_file_origin')
992
993 if hasattr(hf_api, '_create_commit_origin'):
994 hf_api.create_commit = hf_api._create_commit_origin
995 huggingface_hub.create_commit = hf_api.create_commit
996 huggingface_hub.hf_api.create_commit = hf_api.create_commit
997 from transformers.utils import hub
998 hub.create_commit = hf_api.create_commit
999 delattr(hf_api, '_create_commit_origin')

Callers 1

unpatch_hubFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…