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

Method push

modelscope/hub/repository.py:119–151  ·  view source on GitHub ↗

Stage all changes, commit, and push to the remote.

(self,
             commit_message: str,
             local_branch: Optional[str] = DEFAULT_REPOSITORY_REVISION,
             remote_branch: Optional[str] = DEFAULT_REPOSITORY_REVISION,
             force: bool = False)

Source from the content-addressed store, hash-verified

117 f'\n{file_name_suffix} filter=lfs diff=lfs merge=lfs -text\n')
118
119 def push(self,
120 commit_message: str,
121 local_branch: Optional[str] = DEFAULT_REPOSITORY_REVISION,
122 remote_branch: Optional[str] = DEFAULT_REPOSITORY_REVISION,
123 force: bool = False):
124 """Stage all changes, commit, and push to the remote."""
125 warnings.warn(
126 'This function is deprecated and will be removed in future '
127 'versions. Please use git command directly or use '
128 'HubApi().upload_folder instead',
129 DeprecationWarning,
130 stacklevel=2)
131 if not isinstance(commit_message, str) or not commit_message:
132 raise InvalidParameter('commit_message must be provided!')
133 if not isinstance(force, bool):
134 raise InvalidParameter('force must be bool')
135 if not self.git_token:
136 raise NotLoginException('Must login to push, please login first.')
137
138 self.git_wrapper.config_git_token(self.model_dir, self.git_token)
139 self.git_wrapper.add_user_info(self.model_base_dir,
140 self.model_repo_name)
141 url = self.git_wrapper.get_repo_remote_url(self.model_dir)
142
143 self.git_wrapper.add(self.model_dir, all_files=True)
144 self.git_wrapper.commit(self.model_dir, commit_message)
145 self.git_wrapper.push(
146 repo_dir=self.model_dir,
147 git_token=self.git_token,
148 url=url,
149 local_branch=local_branch,
150 remote_branch=remote_branch,
151 force=force)
152
153 def tag(self,
154 tag_name: str,

Callers 8

_push_files_to_hubFunction · 0.95
prepare_caseMethod · 0.95
prepare_caseMethod · 0.95
prepare_caseMethod · 0.95
test_push_allMethod · 0.95
pushMethod · 0.45
add_content_to_fileFunction · 0.45

Calls 6

NotLoginExceptionClass · 0.90
config_git_tokenMethod · 0.80
add_user_infoMethod · 0.80
get_repo_remote_urlMethod · 0.80
commitMethod · 0.80
addMethod · 0.45

Tested by 5

prepare_caseMethod · 0.76
prepare_caseMethod · 0.76
prepare_caseMethod · 0.76
test_push_allMethod · 0.76