2022-09-20 17:49:31 +08:00
|
|
|
# Copyright (c) Alibaba, Inc. and its affiliates.
|
|
|
|
|
|
2022-06-22 18:39:08 +08:00
|
|
|
import unittest
|
|
|
|
|
|
2022-06-24 23:54:10 +08:00
|
|
|
from modelscope.hub.api import HubApi
|
2022-06-22 18:39:08 +08:00
|
|
|
from modelscope.utils.hub import create_model_if_not_exist
|
|
|
|
|
|
2022-06-24 23:54:10 +08:00
|
|
|
# note this is temporary before official account management is ready
|
2024-11-02 08:04:40 +08:00
|
|
|
YOUR_ACCESS_TOKEN = 'Get SDK token from https://www.modelscope.cn/my/myaccesstoken'
|
2022-06-22 18:39:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class HubExampleTest(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
2022-06-24 23:54:10 +08:00
|
|
|
self.api = HubApi()
|
2022-08-02 18:16:28 +08:00
|
|
|
self.api.login(YOUR_ACCESS_TOKEN)
|
2022-06-22 18:39:08 +08:00
|
|
|
|
|
|
|
|
@unittest.skip('to be used for local test only')
|
|
|
|
|
def test_example_model_creation(self):
|
|
|
|
|
# ATTENTION:change to proper model names before use
|
2024-11-02 08:04:40 +08:00
|
|
|
model_name = 'model-name'
|
|
|
|
|
model_chinese_name = '我的测试模型'
|
|
|
|
|
model_owner = 'iic'
|
|
|
|
|
model_id = '%s/%s' % (model_owner, model_name)
|
2022-06-22 18:39:08 +08:00
|
|
|
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()
|