mirror of
https://github.com/modelscope/modelscope.git
synced 2026-02-24 12:10:09 +01:00
fix compatible of origin command line (#944)
Co-authored-by: mulin.lyh <mulin.lyh@taobao.com>
This commit is contained in:
@@ -91,14 +91,22 @@ class DownloadCMD(CLICommand):
|
||||
parser.set_defaults(func=subparser_func)
|
||||
|
||||
def execute(self):
|
||||
if self.args.repo_id is not None:
|
||||
if self.args.repo_type == 'model':
|
||||
self.args.model = self.args.repo_id
|
||||
elif self.args.repo_type == 'dataset':
|
||||
self.args.dataset = self.args.repo_id
|
||||
else:
|
||||
raise Exception('Not support repo-type: %s'
|
||||
% self.args.repo_type)
|
||||
if self.args.model or self.args.dataset:
|
||||
# the position argument of files will be put to repo_id.
|
||||
if self.args.repo_id is not None:
|
||||
if self.args.files:
|
||||
self.args.files.insert(0, self.args.repo_id)
|
||||
else:
|
||||
self.args.files = [self.args.repo_id]
|
||||
else:
|
||||
if self.args.repo_id is not None:
|
||||
if self.args.repo_type == 'model':
|
||||
self.args.model = self.args.repo_id
|
||||
elif self.args.repo_type == 'dataset':
|
||||
self.args.dataset = self.args.repo_id
|
||||
else:
|
||||
raise Exception('Not support repo-type: %s'
|
||||
% self.args.repo_type)
|
||||
if not self.args.model and not self.args.dataset:
|
||||
raise Exception('Model or dataset must be set.')
|
||||
if self.args.model:
|
||||
|
||||
@@ -62,6 +62,11 @@ class DownloadCMDTest(unittest.TestCase):
|
||||
stat, output = subprocess.getstatusoutput(cmd)
|
||||
self.assertEqual(stat, 0)
|
||||
|
||||
def test_download_file(self):
|
||||
cmd = f'python -m modelscope.cli.cli download --model {self.model_id} {download_model_file_name}'
|
||||
stat, output = subprocess.getstatusoutput(cmd)
|
||||
self.assertEqual(stat, 0)
|
||||
|
||||
def test_download_with_cache(self):
|
||||
cmd = f'python -m modelscope.cli.cli download --model {self.model_id} --cache_dir {self.tmp_dir}'
|
||||
stat, output = subprocess.getstatusoutput(cmd)
|
||||
|
||||
Reference in New Issue
Block a user