mirror of
https://github.com/modelscope/modelscope.git
synced 2025-12-16 16:27:45 +01:00
repo exist api support dataset
This commit is contained in:
@@ -361,13 +361,16 @@ class HubApi:
|
||||
"""
|
||||
if endpoint is None:
|
||||
endpoint = self.endpoint
|
||||
if (repo_type is not None) and repo_type.lower() != REPO_TYPE_MODEL:
|
||||
if (repo_type is not None) and repo_type.lower() not in REPO_TYPE_SUPPORT:
|
||||
raise Exception('Not support repo-type: %s' % repo_type)
|
||||
if (repo_id is None) or repo_id.count('/') != 1:
|
||||
raise Exception('Invalid repo_id: %s, must be of format namespace/name' % repo_type)
|
||||
|
||||
cookies = ModelScopeConfig.get_cookies()
|
||||
owner_or_group, name = model_id_to_group_owner_name(repo_id)
|
||||
if (repo_type is not None) and repo_type.lower() == REPO_TYPE_DATASET:
|
||||
path = f'{endpoint}/api/v1/datasets/{owner_or_group}/{name}'
|
||||
else:
|
||||
path = f'{endpoint}/api/v1/models/{owner_or_group}/{name}'
|
||||
|
||||
r = self.session.get(path, cookies=cookies,
|
||||
|
||||
@@ -11,7 +11,7 @@ from modelscope.hub.constants import Licenses, ModelVisibility
|
||||
from modelscope.hub.errors import GitError, HTTPError, NotLoginException
|
||||
from modelscope.hub.push_to_hub import push_to_hub, push_to_hub_async
|
||||
from modelscope.hub.repository import Repository
|
||||
from modelscope.utils.constant import ModelFile
|
||||
from modelscope.utils.constant import REPO_TYPE_DATASET, ModelFile
|
||||
from modelscope.utils.logger import get_logger
|
||||
from modelscope.utils.test_utils import (TEST_ACCESS_TOKEN1, TEST_MODEL_ORG,
|
||||
delete_credential, test_level)
|
||||
@@ -52,6 +52,12 @@ class HubUploadTest(unittest.TestCase):
|
||||
self.assertTrue(res)
|
||||
res = self.api.repo_exists('Qwen/not-a-repo')
|
||||
self.assertFalse(res)
|
||||
res = self.api.repo_exists(
|
||||
'Qwen/ProcessBench', repo_type=REPO_TYPE_DATASET)
|
||||
self.assertTrue(res)
|
||||
res = self.api.repo_exists(
|
||||
'Qwen/not-a-repo', repo_type=REPO_TYPE_DATASET)
|
||||
self.assertFalse(res)
|
||||
|
||||
def test_upload_exits_repo_master(self):
|
||||
logger.info('basic test for upload!')
|
||||
|
||||
Reference in New Issue
Block a user