intellif-aihub 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl

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.

Files changed (35) hide show
  1. aihub/__init__.py +1 -1
  2. aihub/client.py +91 -87
  3. aihub/exceptions.py +18 -18
  4. aihub/models/artifact.py +137 -137
  5. aihub/models/common.py +13 -13
  6. aihub/models/dataset_management.py +99 -99
  7. aihub/models/document_center.py +28 -28
  8. aihub/models/labelfree.py +31 -31
  9. aihub/models/model_training_platform.py +230 -0
  10. aihub/models/tag_resource_management.py +50 -0
  11. aihub/models/task_center.py +117 -117
  12. aihub/models/user_system.py +262 -0
  13. aihub/services/artifact.py +353 -332
  14. aihub/services/dataset_management.py +240 -240
  15. aihub/services/document_center.py +43 -43
  16. aihub/services/labelfree.py +44 -44
  17. aihub/services/model_training_platform.py +135 -0
  18. aihub/services/quota_schedule_management.py +18 -18
  19. aihub/services/reporter.py +20 -20
  20. aihub/services/tag_resource_management.py +55 -0
  21. aihub/services/task_center.py +190 -190
  22. aihub/services/user_system.py +339 -0
  23. aihub/utils/download.py +69 -69
  24. aihub/utils/http.py +13 -13
  25. aihub/utils/s3.py +77 -77
  26. {intellif_aihub-0.1.2.dist-info → intellif_aihub-0.1.3.dist-info}/METADATA +2 -2
  27. intellif_aihub-0.1.3.dist-info/RECORD +34 -0
  28. {intellif_aihub-0.1.2.dist-info → intellif_aihub-0.1.3.dist-info}/licenses/LICENSE +200 -200
  29. aihub/models/tag_management.py +0 -21
  30. aihub/models/user.py +0 -46
  31. aihub/services/tag_management.py +0 -35
  32. aihub/services/user.py +0 -47
  33. intellif_aihub-0.1.2.dist-info/RECORD +0 -32
  34. {intellif_aihub-0.1.2.dist-info → intellif_aihub-0.1.3.dist-info}/WHEEL +0 -0
  35. {intellif_aihub-0.1.2.dist-info → intellif_aihub-0.1.3.dist-info}/top_level.txt +0 -0
@@ -1,117 +1,117 @@
1
- from __future__ import annotations
2
-
3
- import json
4
- from enum import Enum
5
- from typing import Optional, List
6
-
7
- from pydantic import BaseModel, Field, field_serializer, field_validator
8
-
9
-
10
- class TaskCenterPriorityEnum(Enum):
11
- """
12
- 任务优先级枚举
13
- """
14
-
15
- low = "low"
16
- medium = "medium"
17
- high = "high"
18
-
19
-
20
- class LabelProjectTypeEnum(Enum):
21
- """
22
- 任务类型枚举
23
- """
24
-
25
- IMAGE_CLASSIFICATION = 1
26
- OBJECT_DETECTION = 2
27
- SEMANTIC_SEGMENTATION = 3
28
- TEXT_CLASSIFICATION = 4
29
- TEXT_SEGMENTATION = 5
30
- TEXT_RECOGNITION = 6
31
- IMAGE_CAPTIONING = 7
32
- IMAGE_STYLE_TRANSFER = 8
33
- IMAGE_COLORIZATION = 9
34
- IMAGE_RESTORATION = 10
35
-
36
-
37
- class CreateTaskOtherInfo(BaseModel):
38
- label_project_type: LabelProjectTypeEnum = LabelProjectTypeEnum.IMAGE_CLASSIFICATION
39
- dataset_id: int = Field(alias="dataset_id")
40
- dataset_version_id: int = Field(alias="dataset_version_id")
41
- doc_id: int = Field(alias="doc_id")
42
- doc_type: str = Field(alias="doc_type", default="doc_center")
43
-
44
-
45
- class ProjectInfo(BaseModel):
46
- label_project_id: int = Field(alias="label_project_id")
47
- label_project_name: str = Field(alias="label_project_name")
48
-
49
-
50
- class TaskDetailOtherInfo(BaseModel):
51
- label_project_type: LabelProjectTypeEnum = LabelProjectTypeEnum.IMAGE_CLASSIFICATION
52
- dataset_id: int = Field(alias="dataset_id")
53
- dataset_version_id: int = Field(alias="dataset_version_id")
54
- doc_id: int = Field(alias="doc_id")
55
- doc_type: str = Field(alias="doc_type", default="doc_center")
56
- label_projects: Optional[List[ProjectInfo]] = Field(alias="label_projects")
57
-
58
-
59
- class CreateTaskReq(BaseModel):
60
- name: str
61
- description: Optional[str] = None
62
- task_priority: Optional[str] = None
63
- type: Optional[str] = None
64
- receiver_id: Optional[int] = None
65
- project_id: Optional[int] = None
66
- other_info: CreateTaskOtherInfo = Field(alias="other_info")
67
- estimated_delivery_at: Optional[int] = None
68
-
69
- @field_serializer("other_info")
70
- def serialize_other_info(self, value: CreateTaskOtherInfo) -> str:
71
- """将 other_info 序列化为 JSON 字符串"""
72
- return value.model_dump_json()
73
-
74
-
75
- class CreateTaskResp(BaseModel):
76
- id: int = Field(alias="id")
77
-
78
-
79
- class LabelTaskDetail(BaseModel):
80
- """任务详情"""
81
-
82
- name: str
83
- description: Optional[str] = Field(alias="description")
84
- task_priority: Optional[str] = Field(alias="task_priority")
85
- type: Optional[str] = Field(alias="type")
86
- receiver_id: Optional[int] = Field(alias="receiver_id")
87
- project_id: Optional[int] = None
88
- other_info: TaskDetailOtherInfo = Field(alias="other_info")
89
- estimated_delivery_at: Optional[int] = None
90
-
91
- @field_serializer("other_info")
92
- def serialize_other_info(self, value: TaskDetailOtherInfo) -> str:
93
- """将 other_info 序列化为 JSON 字符串"""
94
- return value.model_dump_json()
95
-
96
- @field_validator("other_info", mode="before")
97
- @classmethod
98
- def parse_other_info(cls, value):
99
- """将字符串解析为 TaskDetailOtherInfo 对象"""
100
- if isinstance(value, str):
101
- try:
102
- # 解析 JSON 字符串为字典
103
- data = json.loads(value)
104
- # 创建 TaskDetailOtherInfo 对象
105
- return TaskDetailOtherInfo(**data)
106
- except (json.JSONDecodeError, TypeError, ValueError) as e:
107
- raise ValueError(f"无法解析 other_info 字符串: {e}")
108
- elif isinstance(value, dict):
109
- # 如果传入的是字典,直接创建对象
110
- return TaskDetailOtherInfo(**value)
111
- elif isinstance(value, TaskDetailOtherInfo):
112
- # 如果已经是对象,直接返回
113
- return value
114
- else:
115
- raise ValueError(
116
- f"other_info 必须是字符串、字典或 TaskDetailOtherInfo 对象,得到: {type(value)}"
117
- )
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from enum import Enum
5
+ from typing import Optional, List
6
+
7
+ from pydantic import BaseModel, Field, field_serializer, field_validator
8
+
9
+
10
+ class TaskCenterPriorityEnum(Enum):
11
+ """
12
+ 任务优先级枚举
13
+ """
14
+
15
+ low = "low"
16
+ medium = "medium"
17
+ high = "high"
18
+
19
+
20
+ class LabelProjectTypeEnum(Enum):
21
+ """
22
+ 任务类型枚举
23
+ 1 - 目标检测 2 - 语义分割 3 - 图片分类 4 - 实例分割 5 - 视频标注 6 - 人类偏好文本标注 7- 敏感预料文本标注 8 - 文本标注 9 - 关键点标注
24
+ """
25
+
26
+ OBJECT_DETECTION = 1
27
+ SEGMENTATION = 2
28
+ IMAGE_CLASSIFICATION = 3
29
+ INSTANCE_SEGMENTATION = 4
30
+ VIDEO_LABELING = 5
31
+ HUMAN_PREFERENCE_TEXT_LABELING = 6
32
+ SENSITIVE_TEXT_LABELING = 7
33
+ TEXT_LABELING = 8
34
+ KEYPOINT_LABELING = 9
35
+
36
+
37
+ class CreateTaskOtherInfo(BaseModel):
38
+ label_project_type: LabelProjectTypeEnum = LabelProjectTypeEnum.IMAGE_CLASSIFICATION
39
+ dataset_id: int = Field(alias="dataset_id")
40
+ dataset_version_id: int = Field(alias="dataset_version_id")
41
+ doc_id: int = Field(alias="doc_id")
42
+ doc_type: str = Field(alias="doc_type", default="doc_center")
43
+
44
+
45
+ class ProjectInfo(BaseModel):
46
+ label_project_id: int = Field(alias="label_project_id")
47
+ label_project_name: str = Field(alias="label_project_name")
48
+
49
+
50
+ class TaskDetailOtherInfo(BaseModel):
51
+ label_project_type: LabelProjectTypeEnum = LabelProjectTypeEnum.IMAGE_CLASSIFICATION
52
+ dataset_id: int = Field(alias="dataset_id")
53
+ dataset_version_id: int = Field(alias="dataset_version_id")
54
+ doc_id: int = Field(alias="doc_id")
55
+ doc_type: str = Field(alias="doc_type", default="doc_center")
56
+ label_projects: Optional[List[ProjectInfo]] = Field(alias="label_projects")
57
+
58
+
59
+ class CreateTaskReq(BaseModel):
60
+ name: str
61
+ description: Optional[str] = None
62
+ task_priority: Optional[str] = None
63
+ type: Optional[str] = None
64
+ receiver_id: Optional[int] = None
65
+ project_id: Optional[int] = None
66
+ other_info: CreateTaskOtherInfo = Field(alias="other_info")
67
+ estimated_delivery_at: Optional[int] = None
68
+
69
+ @field_serializer("other_info")
70
+ def serialize_other_info(self, value: CreateTaskOtherInfo) -> str:
71
+ """将 other_info 序列化为 JSON 字符串"""
72
+ return value.model_dump_json()
73
+
74
+
75
+ class CreateTaskResp(BaseModel):
76
+ id: int = Field(alias="id")
77
+
78
+
79
+ class LabelTaskDetail(BaseModel):
80
+ """任务详情"""
81
+
82
+ name: str
83
+ description: Optional[str] = Field(alias="description")
84
+ task_priority: Optional[str] = Field(alias="task_priority")
85
+ type: Optional[str] = Field(alias="type")
86
+ receiver_id: Optional[int] = Field(alias="receiver_id")
87
+ project_id: Optional[int] = None
88
+ other_info: TaskDetailOtherInfo = Field(alias="other_info")
89
+ estimated_delivery_at: Optional[int] = None
90
+
91
+ @field_serializer("other_info")
92
+ def serialize_other_info(self, value: TaskDetailOtherInfo) -> str:
93
+ """将 other_info 序列化为 JSON 字符串"""
94
+ return value.model_dump_json()
95
+
96
+ @field_validator("other_info", mode="before")
97
+ @classmethod
98
+ def parse_other_info(cls, value):
99
+ """将字符串解析为 TaskDetailOtherInfo 对象"""
100
+ if isinstance(value, str):
101
+ try:
102
+ # 解析 JSON 字符串为字典
103
+ data = json.loads(value)
104
+ # 创建 TaskDetailOtherInfo 对象
105
+ return TaskDetailOtherInfo(**data)
106
+ except (json.JSONDecodeError, TypeError, ValueError) as e:
107
+ raise ValueError(f"无法解析 other_info 字符串: {e}")
108
+ elif isinstance(value, dict):
109
+ # 如果传入的是字典,直接创建对象
110
+ return TaskDetailOtherInfo(**value)
111
+ elif isinstance(value, TaskDetailOtherInfo):
112
+ # 如果已经是对象,直接返回
113
+ return value
114
+ else:
115
+ raise ValueError(
116
+ f"other_info 必须是字符串、字典或 TaskDetailOtherInfo 对象,得到: {type(value)}"
117
+ )
@@ -0,0 +1,262 @@
1
+ # !/usr/bin/env python
2
+ # -*-coding:utf-8 -*-
3
+ from __future__ import annotations
4
+
5
+ from typing import List, Optional
6
+
7
+ from pydantic import BaseModel, Field
8
+
9
+
10
+ # ======================================================================
11
+ # COMMON
12
+ # ======================================================================
13
+
14
+ class Role(BaseModel):
15
+ id: int
16
+ name: str
17
+ role_type: int = Field(alias="role_type")
18
+ menu_ids: Optional[List[int]] = Field(None, alias="menu_ids")
19
+
20
+
21
+ class Menu(BaseModel):
22
+ id: int
23
+ name: str
24
+ parent: int
25
+ auth: str
26
+
27
+
28
+ class TreeMenu(BaseModel):
29
+ id: int
30
+ name: str
31
+ parent: int
32
+ auth: str
33
+ children: Optional[List["TreeMenu"]] = None
34
+ roles: Optional[List[Role]] = None
35
+
36
+
37
+ class TagBrief(BaseModel):
38
+ id: int
39
+ name: str
40
+
41
+
42
+ # ======================================================================
43
+ # ------------------------------- AUTH ---------------------------------
44
+ # ======================================================================
45
+
46
+ class LoginRequest(BaseModel):
47
+ username: str = Field(alias="username")
48
+ password: str = Field(alias="password")
49
+
50
+
51
+ class LoginResponse(BaseModel):
52
+ id: int = Field(alias="id")
53
+ token: str = Field(alias="token")
54
+
55
+
56
+ class SignupRequest(BaseModel):
57
+ username: str = Field(alias="username")
58
+ password: str = Field(alias="password")
59
+ nickname: str = Field(alias="nickname")
60
+ email: str = Field(alias="email")
61
+ role_ids: List[int] = Field(alias="role_ids")
62
+
63
+
64
+ class SignupResponse(BaseModel):
65
+ id: int = Field(alias="id")
66
+
67
+
68
+ # ======================================================================
69
+ # ------------------------------- MENU ---------------------------------
70
+ # ======================================================================
71
+ class ListMenusRequest(BaseModel):
72
+ need_roles: Optional[bool] = Field(None, alias="need_roles")
73
+
74
+
75
+ class ListMenusResponse(BaseModel):
76
+ menus: List[TreeMenu] = Field(None, alias="menus")
77
+
78
+
79
+ class CreateMenuRequest(BaseModel):
80
+ name: str = Field(alias="name")
81
+ parent: int = Field(alias="parent")
82
+ auth: str = Field(alias="auth")
83
+ role_ids: Optional[List[int]] = Field(None, alias="role_ids")
84
+
85
+
86
+ class CreateMenuResponse(BaseModel):
87
+ id: int = Field(alias="id")
88
+
89
+
90
+ class UpdateMenuRequest(BaseModel):
91
+ name: Optional[str] = Field(None, alias="name")
92
+ parent: Optional[int] = Field(None, alias="parent")
93
+ auth: str = Field(alias="auth")
94
+ role_ids: Optional[List[int]] = Field(None, alias="role_ids")
95
+
96
+
97
+ class GetMenuRolesResponse(BaseModel):
98
+ role_ids: List[int] = Field(alias="role_ids")
99
+
100
+
101
+ class SetMenuRolesRequest(BaseModel):
102
+ role_ids: List[int] = Field(alias="role_ids")
103
+
104
+
105
+ class SearchMenusRequest(BaseModel):
106
+ page_size: int = Field(20, alias="page_size")
107
+ page_num: int = Field(1, alias="page_num")
108
+ name: Optional[str] = None
109
+ parent_ids: Optional[List[int]] = Field(None, alias="parent_ids")
110
+ auth: Optional[str] = None
111
+ menu_ids: Optional[List[int]] = Field(None, alias="menu_ids")
112
+
113
+
114
+ class SearchMenusResponse(BaseModel):
115
+ total: int
116
+ page_size: int = Field(alias="page_size")
117
+ page_num: int = Field(alias="page_num")
118
+ data: List[Menu]
119
+
120
+
121
+ # ======================================================================
122
+ # ------------------------------- ROLE ---------------------------------
123
+ # ======================================================================
124
+
125
+
126
+ class CreateRoleRequest(BaseModel):
127
+ id: Optional[int] = Field(None, alias="id")
128
+ name: str
129
+ role_type: int = Field(alias="role_type")
130
+ menu_ids: Optional[List[int]] = Field(None, alias="menu_ids")
131
+
132
+
133
+ class CreateRoleResponse(BaseModel):
134
+ id: int
135
+
136
+
137
+ class UpdateRoleRequest(BaseModel):
138
+ name: Optional[str] = None
139
+ role_type: Optional[int] = Field(None, alias="role_type")
140
+ menu_ids: Optional[List[int]] = Field(None, alias="menu_ids")
141
+
142
+
143
+ class GetRoleMenusResponse(BaseModel):
144
+ menu_ids: List[int] = Field(alias="menu_ids")
145
+
146
+
147
+ class SetRoleMenusRequest(BaseModel):
148
+ menu_ids: List[int] = Field(alias="menu_ids")
149
+
150
+
151
+ class ListRolesRequest(BaseModel):
152
+ page_size: int = Field(20, alias="page_size")
153
+ page_num: int = Field(1, alias="page_num")
154
+ role_type: Optional[int] = Field(None, alias="role_type")
155
+
156
+
157
+ class ListRolesResponse(BaseModel):
158
+ total: int
159
+ page_size: int = Field(alias="page_size")
160
+ page_num: int = Field(alias="page_num")
161
+ data: List[Role]
162
+
163
+
164
+ class SearchRolesRequest(BaseModel):
165
+ page_size: int = Field(20, alias="page_size")
166
+ page_num: int = Field(1, alias="page_num")
167
+ name: Optional[str] = None
168
+ role_ids: Optional[List[int]] = Field(None, alias="role_ids")
169
+ menu_ids: Optional[List[int]] = Field(None, alias="menu_ids")
170
+
171
+
172
+ class SearchRolesResponse(BaseModel):
173
+ total: int
174
+ page_size: int = Field(alias="page_size")
175
+ page_num: int = Field(alias="page_num")
176
+ data: List[Role]
177
+
178
+
179
+ # ======================================================================
180
+ # ------------------------------- USER ---------------------------------
181
+ # ======================================================================
182
+
183
+ class User(BaseModel):
184
+ id: int
185
+ username: str
186
+ nickname: str
187
+ email: str
188
+ roles: Optional[List[Role]] = Field(None, alias="roles")
189
+ status: int
190
+ tags: Optional[List[TagBrief]] = Field(None, alias="tags")
191
+ created_at: int = Field(alias="created_at")
192
+
193
+
194
+ class ListUsersRequest(BaseModel):
195
+ page_size: int = Field(20, alias="page_size")
196
+ page_num: int = Field(1, alias="page_num")
197
+ search_key: Optional[str] = Field(None, alias="search_key")
198
+
199
+
200
+ class ListUsersResponse(BaseModel):
201
+ total: int
202
+ page_size: int = Field(alias="page_size")
203
+ page_num: int = Field(alias="page_num")
204
+ data: List[User]
205
+
206
+
207
+ class CreateUserRequest(BaseModel):
208
+ id: int
209
+ username: str
210
+ password: str
211
+ nickname: str
212
+ email: str
213
+ role_ids: Optional[List[int]] = Field(None, alias="role_ids")
214
+ created_at: Optional[int] = Field(None, alias="created_at")
215
+ updated_at: Optional[int] = Field(None, alias="updated_at")
216
+ status: Optional[int] = None
217
+ tag_ids: Optional[List[int]] = Field(None, alias="tag_ids")
218
+
219
+
220
+ class CreateUserResponse(BaseModel):
221
+ id: int
222
+
223
+
224
+ class UpdateUserRequest(BaseModel):
225
+ username: Optional[str] = None
226
+ nickname: Optional[str] = None
227
+ email: Optional[str] = None
228
+ password: Optional[str] = None
229
+ role_ids: Optional[List[int]] = Field(default_factory=list, alias="role_ids")
230
+ status: Optional[int] = None
231
+ tag_ids: Optional[List[int]] = Field(default_factory=list, alias="tag_ids")
232
+
233
+
234
+ class SetUserRolesRequest(BaseModel):
235
+ role_ids: List[int] = Field(alias="role_ids")
236
+
237
+
238
+ class GetUserMenusResponse(BaseModel):
239
+ menus: List[TreeMenu]
240
+
241
+
242
+ class SearchUsersRequest(BaseModel):
243
+ page_size: int = Field(20, alias="page_size")
244
+ page_num: int = Field(1, alias="page_num")
245
+ username: Optional[str] = None
246
+ nickname: Optional[str] = None
247
+ email: Optional[str] = None
248
+ user_ids: Optional[List[int]] = Field(None, alias="user_ids")
249
+ role_ids: Optional[List[int]] = Field(None, alias="role_ids")
250
+ role_names: Optional[List[str]] = Field(None, alias="role_names")
251
+ status: Optional[int] = None
252
+
253
+
254
+ class SearchUsersResponse(BaseModel):
255
+ total: int
256
+ page_size: int = Field(alias="page_size")
257
+ page_num: int = Field(alias="page_num")
258
+ data: List[User]
259
+
260
+
261
+ # 此行放在文件末尾,否则序列化报错
262
+ TreeMenu.update_forward_refs()