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

Method push_model

modelscope/cli/modelcard.py:137–159  ·  view source on GitHub ↗
(self, tpl_dir='readme.tpl')

Source from the content-addressed store, hash-verified

135 return self.api.get_model_url(self.model_id)
136
137 def push_model(self, tpl_dir='readme.tpl'):
138 from modelscope.hub.repository import Repository
139 if self.args.version_tag and self.args.version_info:
140 clone_dir = tempfile.TemporaryDirectory().name
141 repo = Repository(clone_dir, clone_from=self.model_id)
142 repo.tag_and_push(self.args.version_tag, self.args.version_info)
143 shutil.rmtree(clone_dir)
144 else:
145 cfg_file = os.path.join(self.args.model_dir, 'README.md')
146 if not os.path.exists(cfg_file):
147 with open(os.path.join(template_path,
148 tpl_dir)) as tpl_file_path:
149 tpl = Template(tpl_file_path.read())
150 f = open(cfg_file, 'w')
151 f.write(tpl.substitute(model_id=self.model_id))
152 f.close()
153 self.api.push_model(
154 model_id=self.model_id,
155 model_dir=self.args.model_dir,
156 visibility=self.args.visibility,
157 license=self.args.license,
158 chinese_name=self.args.chinese_name)
159 self.pprint()
160
161 def pprint(self):
162 logger.info('>>> Clone the model_git < %s >, commit and push it.'

Callers 6

executeMethod · 0.95
_api_push_to_hubFunction · 0.80

Calls 8

tag_and_pushMethod · 0.95
pprintMethod · 0.95
RepositoryClass · 0.90
TemplateClass · 0.85
existsMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45