mirror of
https://github.com/modelscope/modelscope.git
synced 2025-12-25 12:39:25 +01:00
[to #42322933] add create if not exist and add(back) create model example
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9130661
This commit is contained in:
33
tests/hub/test_hub_examples.py
Normal file
33
tests/hub/test_hub_examples.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import unittest
|
||||
|
||||
from maas_hub.maas_api import MaasApi
|
||||
|
||||
from modelscope.utils.hub import create_model_if_not_exist
|
||||
|
||||
USER_NAME = 'maasadmin'
|
||||
PASSWORD = '12345678'
|
||||
|
||||
|
||||
class HubExampleTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.api = MaasApi()
|
||||
# note this is temporary before official account management is ready
|
||||
self.api.login(USER_NAME, PASSWORD)
|
||||
|
||||
@unittest.skip('to be used for local test only')
|
||||
def test_example_model_creation(self):
|
||||
# ATTENTION:change to proper model names before use
|
||||
model_name = 'cv_unet_person-image-cartoon_compound-models'
|
||||
model_chinese_name = '达摩卡通化模型'
|
||||
model_org = 'damo'
|
||||
model_id = '%s/%s' % (model_org, model_name)
|
||||
|
||||
created = create_model_if_not_exist(self.api, model_id,
|
||||
model_chinese_name)
|
||||
if not created:
|
||||
print('!! NOT created since model already exists !!')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -1,6 +1,5 @@
|
||||
# Copyright (c) Alibaba, Inc. and its affiliates.
|
||||
import os
|
||||
import os.path as osp
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
@@ -8,7 +7,6 @@ import uuid
|
||||
|
||||
from modelscope.hub.api import HubApi, ModelScopeConfig
|
||||
from modelscope.hub.file_download import model_file_download
|
||||
from modelscope.hub.repository import Repository
|
||||
from modelscope.hub.snapshot_download import snapshot_download
|
||||
from modelscope.hub.utils.utils import get_gitlab_domain
|
||||
|
||||
|
||||
Reference in New Issue
Block a user