intellif-aihub 0.1.21__tar.gz → 0.1.22__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of intellif-aihub might be problematic. Click here for more details.
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/PKG-INFO +1 -1
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/pyproject.toml +1 -1
- intellif_aihub-0.1.22/src/aihub/__init__.py +1 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/eval.py +31 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/task_center.py +1 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/user_system.py +1 -1
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/eval.py +59 -9
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/task_center.py +3 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/user_system.py +26 -9
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/intellif_aihub.egg-info/PKG-INFO +1 -1
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_user_system.py +13 -2
- intellif_aihub-0.1.21/src/aihub/__init__.py +0 -1
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/LICENSE +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/README.md +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/setup.cfg +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/client.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/exceptions.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/__init__.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/artifact.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/common.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/data_warehouse.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/dataset_management.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/document_center.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/labelfree.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/model_center.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/model_training_platform.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/quota_schedule_management.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/tag_resource_management.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/workflow_center.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/__init__.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/artifact.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/data_warehouse.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/dataset_management.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/document_center.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/labelfree.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/model_center.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/model_training_platform.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/quota_schedule_management.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/reporter.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/tag_resource_management.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/workflow_center.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/utils/__init__.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/utils/di.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/utils/download.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/utils/http.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/utils/s3.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/intellif_aihub.egg-info/SOURCES.txt +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/intellif_aihub.egg-info/dependency_links.txt +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/intellif_aihub.egg-info/requires.txt +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/intellif_aihub.egg-info/top_level.txt +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_artifact.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_data_warehouse.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_dataset_management.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_di.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_document_center.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_eval.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_labelfree.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_model_center.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_model_training_platform.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_quota_schedule_management.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_s3.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_tag_resource_management.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_task_center.py +0 -0
- {intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/tests/test_workflow_center.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.22"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# !/usr/bin/env python
|
|
2
2
|
# -*-coding:utf-8 -*-
|
|
3
|
+
from enum import Enum
|
|
3
4
|
from typing import Dict, List, Optional
|
|
4
5
|
|
|
5
6
|
from pydantic import BaseModel, Field
|
|
@@ -7,30 +8,47 @@ from pydantic import BaseModel, Field
|
|
|
7
8
|
|
|
8
9
|
class BaseEvalReq(BaseModel):
|
|
9
10
|
"""评测任务基础请求模型"""
|
|
11
|
+
|
|
10
12
|
run_id: str = Field(description="运行ID")
|
|
11
13
|
type: str = Field(description="评测类型,支持 'llm' 和 'cv'")
|
|
12
14
|
prediction_artifact_path: str = Field(description="推理产物的路径")
|
|
13
15
|
user_id: int = Field(0, description="用户ID,默认0")
|
|
14
16
|
|
|
15
17
|
|
|
18
|
+
class ClientType(Enum):
|
|
19
|
+
"""客户端类型枚举"""
|
|
20
|
+
|
|
21
|
+
Workflow = "workflow"
|
|
22
|
+
sdk = "sdk"
|
|
23
|
+
|
|
24
|
+
|
|
16
25
|
class CreateLLMEvalReq(BaseEvalReq):
|
|
17
26
|
"""创建LLM类型评测任务请求"""
|
|
27
|
+
|
|
18
28
|
type: str = Field(default="llm", description="评测类型,固定为 'llm'")
|
|
19
29
|
dataset_id: int = Field(description="数据集ID")
|
|
20
30
|
dataset_version_id: int = Field(description="数据集版本ID")
|
|
21
31
|
evaled_artifact_path: str = Field(description="评测结果产物的路径")
|
|
22
32
|
report: Dict = Field(description="评测报告")
|
|
33
|
+
is_public: bool = Field(default=False, description="是否公开")
|
|
34
|
+
client_type: ClientType = Field(default=ClientType.Workflow, description="客户端类型")
|
|
35
|
+
model_config = {"use_enum_values": True}
|
|
23
36
|
|
|
24
37
|
|
|
25
38
|
class CreateCVEvalReq(BaseEvalReq):
|
|
26
39
|
"""创建CV类型评测任务请求"""
|
|
40
|
+
|
|
27
41
|
type: str = Field(default="cv", description="评测类型,固定为 'cv'")
|
|
28
42
|
metrics_artifact_path: str = Field(description="指标产物的路径")
|
|
29
43
|
ground_truth_artifact_path: str = Field(description="真实标签产物的路径")
|
|
44
|
+
is_public: bool = Field(default=False, description="是否公开")
|
|
45
|
+
client_type: ClientType = Field(default=ClientType.Workflow, description="客户端类型")
|
|
46
|
+
model_config = {"use_enum_values": True}
|
|
30
47
|
|
|
31
48
|
|
|
32
49
|
class EvalRun(BaseModel):
|
|
33
50
|
"""评测任务的运行实体"""
|
|
51
|
+
|
|
34
52
|
id: int = Field(description="评测的运行ID")
|
|
35
53
|
name: str = Field(description="评测名称")
|
|
36
54
|
description: str = Field(description="评测描述")
|
|
@@ -50,15 +68,20 @@ class EvalRun(BaseModel):
|
|
|
50
68
|
eval_config: Optional[Dict] = Field(default=None, description="评测配置")
|
|
51
69
|
created_at: int = Field(description="创建时间")
|
|
52
70
|
updated_at: int = Field(description="更新时间")
|
|
71
|
+
is_public: bool = Field(default=False, description="是否公开")
|
|
72
|
+
client_type: ClientType = Field(default=ClientType.Workflow, description="客户端类型")
|
|
73
|
+
model_config = {"use_enum_values": True, "protected_namespaces": ()}
|
|
53
74
|
|
|
54
75
|
|
|
55
76
|
class CreateEvalResp(BaseModel):
|
|
56
77
|
"""创建评测任务的返回结果"""
|
|
78
|
+
|
|
57
79
|
eval_run: EvalRun = Field(alias="eval_run", description="评测运行信息")
|
|
58
80
|
|
|
59
81
|
|
|
60
82
|
class ListEvalReq(BaseModel):
|
|
61
83
|
"""列出评测任务请求"""
|
|
84
|
+
|
|
62
85
|
page_size: int = Field(20, description="页面大小")
|
|
63
86
|
page_num: int = Field(1, description="页码")
|
|
64
87
|
status: Optional[str] = Field(None, description="状态过滤")
|
|
@@ -71,11 +94,19 @@ class ListEvalReq(BaseModel):
|
|
|
71
94
|
model_ids: Optional[str] = Field(None, description="模型ID列表过滤")
|
|
72
95
|
dataset_ids: Optional[str] = Field(None, description="数据集ID列表过滤")
|
|
73
96
|
dataset_version_ids: Optional[str] = Field(None, description="数据集版本ID列表过滤")
|
|
97
|
+
model_config = {"use_enum_values": True, "protected_namespaces": ()}
|
|
74
98
|
|
|
75
99
|
|
|
76
100
|
class ListEvalResp(BaseModel):
|
|
77
101
|
"""列出评测任务响应"""
|
|
102
|
+
|
|
78
103
|
total: int = Field(description="总数")
|
|
79
104
|
page_size: int = Field(description="页面大小")
|
|
80
105
|
page_num: int = Field(description="页码")
|
|
81
106
|
data: List[EvalRun] = Field(description="评测运行列表")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class GrantPermissionReq(BaseModel):
|
|
110
|
+
"""授权权限请求"""
|
|
111
|
+
|
|
112
|
+
user_ids: list[int] = Field(description="用户ID数组")
|
|
@@ -42,6 +42,7 @@ class CreateTaskOtherInfo(BaseModel):
|
|
|
42
42
|
doc_type: str = Field(alias="doc_type", default="doc_center", description="文档类型")
|
|
43
43
|
|
|
44
44
|
model_config = {"use_enum_values": True}
|
|
45
|
+
auto_valid_interval: int = Field(3, description="自动验收间隔")
|
|
45
46
|
|
|
46
47
|
|
|
47
48
|
class ProjectInfo(BaseModel):
|
|
@@ -328,7 +328,7 @@ class SearchUsersResponse(BaseModel):
|
|
|
328
328
|
total: int = Field(description="总数")
|
|
329
329
|
page_size: int = Field(alias="page_size", description="单页条数")
|
|
330
330
|
page_num: int = Field(alias="page_num", description="当前页")
|
|
331
|
-
data: List[User] = Field(description="用户列表")
|
|
331
|
+
data: Optional[List[User]] = Field(description="用户列表")
|
|
332
332
|
|
|
333
333
|
|
|
334
334
|
# 此行放在文件末尾,否则序列化报错
|
|
@@ -7,12 +7,21 @@
|
|
|
7
7
|
- **创建评测任务 / 评测报告**
|
|
8
8
|
- **获取评测任务列表**
|
|
9
9
|
"""
|
|
10
|
+
from typing import List
|
|
10
11
|
|
|
11
12
|
import httpx
|
|
12
13
|
|
|
13
14
|
from ..exceptions import APIError
|
|
14
15
|
from ..models.common import APIWrapper
|
|
15
|
-
from ..models.eval import
|
|
16
|
+
from ..models.eval import (
|
|
17
|
+
CreateLLMEvalReq,
|
|
18
|
+
CreateCVEvalReq,
|
|
19
|
+
CreateEvalResp,
|
|
20
|
+
ListEvalReq,
|
|
21
|
+
ListEvalResp,
|
|
22
|
+
GrantPermissionReq,
|
|
23
|
+
ClientType,
|
|
24
|
+
)
|
|
16
25
|
|
|
17
26
|
_BASE = "/eval-platform/api/v1"
|
|
18
27
|
|
|
@@ -32,16 +41,20 @@ class EvalService:
|
|
|
32
41
|
report_json: dict,
|
|
33
42
|
run_id,
|
|
34
43
|
user_id: int = 0,
|
|
44
|
+
is_public: bool = False,
|
|
45
|
+
access_user_ids: List[int] = None,
|
|
35
46
|
) -> int:
|
|
36
47
|
"""创建评测报告
|
|
37
48
|
|
|
38
49
|
Args:
|
|
50
|
+
is_public (bool): 是否公开
|
|
39
51
|
run_id (str): RUN ID
|
|
40
52
|
report_json (dict): 报告内容
|
|
41
53
|
evaled_artifact_path: 评测结果制品路径
|
|
42
54
|
prediction_artifact_path: 推理结果制品路径
|
|
43
55
|
dataset_version_name (str): 数据集名称
|
|
44
56
|
user_id (int, optional): 用户ID,默认为0
|
|
57
|
+
access_user_ids (list): 授权访问的用户id
|
|
45
58
|
|
|
46
59
|
Returns:
|
|
47
60
|
id (int): 评测报告id
|
|
@@ -50,9 +63,7 @@ class EvalService:
|
|
|
50
63
|
from .dataset_management import DatasetManagementService
|
|
51
64
|
|
|
52
65
|
dataset_service = DatasetManagementService(self._http)
|
|
53
|
-
dataset_version = dataset_service.get_dataset_version_by_name(
|
|
54
|
-
dataset_version_name
|
|
55
|
-
)
|
|
66
|
+
dataset_version = dataset_service.get_dataset_version_by_name(dataset_version_name)
|
|
56
67
|
payload = CreateLLMEvalReq(
|
|
57
68
|
dataset_id=dataset_version.dataset_id,
|
|
58
69
|
dataset_version_id=dataset_version.id,
|
|
@@ -61,9 +72,15 @@ class EvalService:
|
|
|
61
72
|
report=report_json,
|
|
62
73
|
run_id=run_id,
|
|
63
74
|
user_id=user_id,
|
|
75
|
+
is_public=is_public,
|
|
76
|
+
type="llm",
|
|
77
|
+
client_type=ClientType.Workflow,
|
|
64
78
|
)
|
|
79
|
+
resp = self._eval.create(payload)
|
|
80
|
+
if is_public is False and access_user_ids:
|
|
81
|
+
self.grant_permission(user_ids=access_user_ids, run_id=resp)
|
|
65
82
|
|
|
66
|
-
return
|
|
83
|
+
return resp
|
|
67
84
|
|
|
68
85
|
def create_cv_run(
|
|
69
86
|
self,
|
|
@@ -72,16 +89,21 @@ class EvalService:
|
|
|
72
89
|
metrics_artifact_path: str,
|
|
73
90
|
ground_truth_artifact_path: str,
|
|
74
91
|
user_id: int = 0,
|
|
92
|
+
is_public: bool = False,
|
|
93
|
+
access_user_ids: List[int] = None,
|
|
75
94
|
) -> int:
|
|
76
95
|
"""创建 CV 类型评测运行
|
|
77
|
-
|
|
96
|
+
|
|
78
97
|
Args:
|
|
98
|
+
access_user_ids: 授权访问的用户ID
|
|
99
|
+
is_public (bool): 是否公开
|
|
79
100
|
run_id (str): 运行ID
|
|
80
101
|
prediction_artifact_path (str): 推理产物的路径
|
|
81
102
|
metrics_artifact_path (str): 指标产物的路径
|
|
82
103
|
ground_truth_artifact_path (str): 真实标签产物的路径
|
|
83
104
|
user_id (int, optional): 用户ID,默认为0
|
|
84
|
-
|
|
105
|
+
access_user_ids (list): 授权访问的用户id
|
|
106
|
+
|
|
85
107
|
Returns:
|
|
86
108
|
id (int): 评测运行id
|
|
87
109
|
"""
|
|
@@ -91,9 +113,15 @@ class EvalService:
|
|
|
91
113
|
metrics_artifact_path=metrics_artifact_path,
|
|
92
114
|
ground_truth_artifact_path=ground_truth_artifact_path,
|
|
93
115
|
user_id=user_id,
|
|
116
|
+
is_public=is_public,
|
|
117
|
+
type="cv",
|
|
118
|
+
client_type=ClientType.Workflow,
|
|
94
119
|
)
|
|
95
|
-
|
|
96
|
-
|
|
120
|
+
resp = self._eval.create(payload)
|
|
121
|
+
if is_public is False and access_user_ids:
|
|
122
|
+
self.grant_permission(user_ids=access_user_ids, run_id=resp)
|
|
123
|
+
|
|
124
|
+
return resp
|
|
97
125
|
|
|
98
126
|
def list(
|
|
99
127
|
self,
|
|
@@ -146,6 +174,21 @@ class EvalService:
|
|
|
146
174
|
|
|
147
175
|
return self._eval.list(payload)
|
|
148
176
|
|
|
177
|
+
def grant_permission(self, user_ids: List[int], run_id: int):
|
|
178
|
+
"""授权访问
|
|
179
|
+
|
|
180
|
+
Args:
|
|
181
|
+
user_ids (list): 授权信息
|
|
182
|
+
run_id (int): 任务ID
|
|
183
|
+
|
|
184
|
+
Returns:
|
|
185
|
+
dict: 授权信息
|
|
186
|
+
"""
|
|
187
|
+
req = GrantPermissionReq(
|
|
188
|
+
user_ids=user_ids,
|
|
189
|
+
)
|
|
190
|
+
return self._eval.grant_permission(req, run_id)
|
|
191
|
+
|
|
149
192
|
|
|
150
193
|
class _Eval:
|
|
151
194
|
def __init__(self, http: httpx.Client):
|
|
@@ -158,6 +201,13 @@ class _Eval:
|
|
|
158
201
|
raise APIError(f"backend code {wrapper.code}: {wrapper.msg}")
|
|
159
202
|
return wrapper.data.eval_run.id
|
|
160
203
|
|
|
204
|
+
def grant_permission(self, payload, task_id):
|
|
205
|
+
resp = self._http.post(f"{_BASE}/run/{task_id}/permissions", json=payload.model_dump())
|
|
206
|
+
wrapper = APIWrapper[CreateEvalResp].model_validate(resp.json())
|
|
207
|
+
if wrapper.code != 0:
|
|
208
|
+
raise APIError(f"backend code {wrapper.code}: {wrapper.msg}")
|
|
209
|
+
return wrapper.data
|
|
210
|
+
|
|
161
211
|
def list(self, payload: ListEvalReq) -> ListEvalResp:
|
|
162
212
|
# Build query parameters, excluding None values
|
|
163
213
|
params = {}
|
|
@@ -84,6 +84,7 @@ class TaskCenterService:
|
|
|
84
84
|
label_type: LabelProjectTypeEnum = LabelProjectTypeEnum.IMAGE_CLASSIFICATION,
|
|
85
85
|
description: str = "",
|
|
86
86
|
task_priority: TaskCenterPriorityEnum = TaskCenterPriorityEnum.low,
|
|
87
|
+
auto_valid_interval: int = 3,
|
|
87
88
|
) -> int:
|
|
88
89
|
"""创建标注任务
|
|
89
90
|
|
|
@@ -107,6 +108,7 @@ task_priority="low", estimated_delivery_at= "2025-08-01")
|
|
|
107
108
|
label_type (LabelProjectTypeEnum): 标注项目类型,默认为图像分类
|
|
108
109
|
description (str): 任务描述,默认为空
|
|
109
110
|
task_priority (TaskCenterPriorityEnum): 任务优先级,默认为低优先级
|
|
111
|
+
auto_valid_interval(str): 标注自动验收时间(默认三天)
|
|
110
112
|
Returns:
|
|
111
113
|
任务ID
|
|
112
114
|
"""
|
|
@@ -153,6 +155,7 @@ task_priority="low", estimated_delivery_at= "2025-08-01")
|
|
|
153
155
|
dataset_version_id=dataset_version_id,
|
|
154
156
|
doc_id=doc_id,
|
|
155
157
|
doc_type="doc_center",
|
|
158
|
+
auto_valid_interval=auto_valid_interval,
|
|
156
159
|
)
|
|
157
160
|
estimated_delivery_at_timestamp = date_str_to_timestamp(estimated_delivery_at)
|
|
158
161
|
task_req = CreateTaskReq(
|
|
@@ -290,9 +290,9 @@ class UserSystemService:
|
|
|
290
290
|
def delete_user(self, user_id: int) -> None:
|
|
291
291
|
"""删除用户
|
|
292
292
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
293
|
+
Args:
|
|
294
|
+
user_id: 目标用户 ID
|
|
295
|
+
"""
|
|
296
296
|
self._user.delete(user_id)
|
|
297
297
|
|
|
298
298
|
def set_user_roles(self, user_id: int, payload: SetUserRolesRequest) -> None:
|
|
@@ -304,7 +304,12 @@ class UserSystemService:
|
|
|
304
304
|
"""
|
|
305
305
|
self._user.set_roles(user_id, payload)
|
|
306
306
|
|
|
307
|
-
def get_user_menus(
|
|
307
|
+
def get_user_menus(
|
|
308
|
+
self,
|
|
309
|
+
user_id: int,
|
|
310
|
+
parent_id: int | None = None,
|
|
311
|
+
auth: str | None = None,
|
|
312
|
+
) -> List[TreeMenu]:
|
|
308
313
|
"""查询用户可见菜单
|
|
309
314
|
|
|
310
315
|
Args:
|
|
@@ -317,7 +322,7 @@ class UserSystemService:
|
|
|
317
322
|
"""
|
|
318
323
|
return self._user.get_menus(user_id, parent_id=parent_id, auth=auth)
|
|
319
324
|
|
|
320
|
-
def search_users(self, payload: SearchUsersRequest) ->
|
|
325
|
+
def search_users(self, payload: SearchUsersRequest) -> List[User]:
|
|
321
326
|
"""条件搜索用户
|
|
322
327
|
|
|
323
328
|
Args:
|
|
@@ -326,13 +331,15 @@ class UserSystemService:
|
|
|
326
331
|
Returns:
|
|
327
332
|
SearchUsersResponse: 搜索结果
|
|
328
333
|
"""
|
|
329
|
-
|
|
334
|
+
resp = self._user.search(payload)
|
|
335
|
+
return resp.data
|
|
330
336
|
|
|
331
|
-
def search_one(self,
|
|
337
|
+
def search_one(self, nickname: str) -> int:
|
|
332
338
|
"""搜索单个用户并返回其 ID
|
|
333
339
|
|
|
334
340
|
Args:
|
|
335
|
-
|
|
341
|
+
nickname: 用户昵称
|
|
342
|
+
|
|
336
343
|
|
|
337
344
|
Returns:
|
|
338
345
|
int: 命中的用户 ID
|
|
@@ -340,7 +347,10 @@ class UserSystemService:
|
|
|
340
347
|
Raises:
|
|
341
348
|
APIError: 未找到用户时抛出
|
|
342
349
|
"""
|
|
343
|
-
|
|
350
|
+
req = SearchUsersRequest(
|
|
351
|
+
nickname=nickname,
|
|
352
|
+
)
|
|
353
|
+
return self._user.search_one(req)
|
|
344
354
|
|
|
345
355
|
@property
|
|
346
356
|
def auth(self) -> _Auth:
|
|
@@ -568,6 +578,13 @@ class _User:
|
|
|
568
578
|
|
|
569
579
|
def search_one(self, req: SearchUsersRequest) -> int:
|
|
570
580
|
resp = self.search(req)
|
|
581
|
+
|
|
582
|
+
if resp.data is None:
|
|
583
|
+
raise APIError(f"no user found")
|
|
584
|
+
|
|
585
|
+
if len(resp.data) > 1:
|
|
586
|
+
raise APIError("more than one user found")
|
|
587
|
+
|
|
571
588
|
for user in resp.data:
|
|
572
589
|
if user.nickname == req.nickname:
|
|
573
590
|
return user.id
|
|
@@ -15,8 +15,10 @@ class TestUserSystem(unittest.TestCase):
|
|
|
15
15
|
client = Client(base_url=BASE_URL, token=TOKEN)
|
|
16
16
|
uname = f"ut_{uuid.uuid4().hex[:6]}"
|
|
17
17
|
signup_resp = client.user_system.signup(
|
|
18
|
-
SignupRequest(
|
|
19
|
-
|
|
18
|
+
SignupRequest(
|
|
19
|
+
username=uname, password="Pa55w0rd!", nickname="UTest", email=f"{uname}@example.com", role_ids=[]
|
|
20
|
+
)
|
|
21
|
+
)
|
|
20
22
|
self.assertGreater(signup_resp.id, 0)
|
|
21
23
|
login_resp = client.user_system.login(LoginRequest(username=uname, password="Pa55w0rd!"))
|
|
22
24
|
self.assertTrue(login_resp.token)
|
|
@@ -110,3 +112,12 @@ class TestUserSystem(unittest.TestCase):
|
|
|
110
112
|
client.user_system.delete_user(uid)
|
|
111
113
|
users2 = client.user_system.list_users(ListUsersRequest())
|
|
112
114
|
self.assertFalse(any(u.id == uid for u in users2.data))
|
|
115
|
+
|
|
116
|
+
def test_search_one(self) -> None:
|
|
117
|
+
client = Client(base_url=BASE_URL, token=TOKEN)
|
|
118
|
+
uid = client.user_system.search_one(
|
|
119
|
+
nickname="admin",
|
|
120
|
+
)
|
|
121
|
+
self.assertGreater(uid, 0)
|
|
122
|
+
# users = client.user_system.search_users(SearchUsersRequest(nickname="admin"))
|
|
123
|
+
# print(users)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.21"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/models/quota_schedule_management.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/model_training_platform.py
RENAMED
|
File without changes
|
{intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/quota_schedule_management.py
RENAMED
|
File without changes
|
|
File without changes
|
{intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/aihub/services/tag_resource_management.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{intellif_aihub-0.1.21 → intellif_aihub-0.1.22}/src/intellif_aihub.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|