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

Function _api_push_to_hub

modelscope/hub/push_to_hub.py:68–100  ·  view source on GitHub ↗
(repo_name,
                     output_dir,
                     token,
                     private=True,
                     commit_message='',
                     tag=None,
                     source_repo='',
                     ignore_file_pattern=None,
                     revision=DEFAULT_REPOSITORY_REVISION)

Source from the content-addressed store, hash-verified

66
67
68def _api_push_to_hub(repo_name,
69 output_dir,
70 token,
71 private=True,
72 commit_message='',
73 tag=None,
74 source_repo='',
75 ignore_file_pattern=None,
76 revision=DEFAULT_REPOSITORY_REVISION):
77 try:
78 api = HubApi()
79 api.login(token)
80 api.push_model(
81 repo_name,
82 output_dir,
83 visibility=ModelVisibility.PUBLIC
84 if not private else ModelVisibility.PRIVATE,
85 chinese_name=repo_name,
86 commit_message=commit_message,
87 tag=tag,
88 original_model_id=source_repo,
89 ignore_file_pattern=ignore_file_pattern,
90 revision=revision)
91 commit_message = commit_message or 'No commit message'
92 logger.info(
93 f'Successfully upload the model to {repo_name} with message: {commit_message}'
94 )
95 return True
96 except Exception as e:
97 logger.error(
98 f'Error happens when uploading model {repo_name} with message: {commit_message}: {e}'
99 )
100 return False
101
102
103def push_to_hub(repo_name,

Callers 1

push_to_hubFunction · 0.85

Calls 3

HubApiClass · 0.90
push_modelMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…