intellif-aihub 0.1.3__py3-none-any.whl → 0.1.5__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.
- aihub/__init__.py +1 -1
- aihub/client.py +95 -91
- aihub/exceptions.py +18 -18
- aihub/models/artifact.py +137 -137
- aihub/models/common.py +13 -13
- aihub/models/dataset_management.py +99 -99
- aihub/models/document_center.py +28 -28
- aihub/models/eval.py +17 -0
- aihub/models/labelfree.py +53 -31
- aihub/models/model_training_platform.py +234 -230
- aihub/models/quota_schedule_management.py +239 -0
- aihub/models/tag_resource_management.py +50 -50
- aihub/models/task_center.py +117 -117
- aihub/models/user_system.py +262 -262
- aihub/services/artifact.py +353 -353
- aihub/services/dataset_management.py +240 -240
- aihub/services/document_center.py +43 -43
- aihub/services/eval.py +68 -0
- aihub/services/labelfree.py +44 -44
- aihub/services/model_training_platform.py +209 -135
- aihub/services/quota_schedule_management.py +182 -18
- aihub/services/reporter.py +20 -20
- aihub/services/tag_resource_management.py +55 -55
- aihub/services/task_center.py +190 -190
- aihub/services/user_system.py +339 -339
- aihub/utils/download.py +69 -69
- aihub/utils/http.py +13 -13
- aihub/utils/s3.py +77 -77
- {intellif_aihub-0.1.3.dist-info → intellif_aihub-0.1.5.dist-info}/METADATA +1 -1
- intellif_aihub-0.1.5.dist-info/RECORD +36 -0
- {intellif_aihub-0.1.3.dist-info → intellif_aihub-0.1.5.dist-info}/licenses/LICENSE +200 -200
- intellif_aihub-0.1.3.dist-info/RECORD +0 -34
- {intellif_aihub-0.1.3.dist-info → intellif_aihub-0.1.5.dist-info}/WHEEL +0 -0
- {intellif_aihub-0.1.3.dist-info → intellif_aihub-0.1.5.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Env(BaseModel):
|
|
9
|
+
key: str
|
|
10
|
+
value: str
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Sku(BaseModel):
|
|
14
|
+
cpu: int
|
|
15
|
+
gpu: int
|
|
16
|
+
memory: int
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class VirtualCluster(BaseModel):
|
|
20
|
+
id: int
|
|
21
|
+
name: str
|
|
22
|
+
gpu_type: str = Field(alias="gpu_type")
|
|
23
|
+
label: str
|
|
24
|
+
sku: Sku
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Storage(BaseModel):
|
|
28
|
+
id: int
|
|
29
|
+
name: str
|
|
30
|
+
path: str
|
|
31
|
+
server_path: str = Field(alias="server_path")
|
|
32
|
+
server_host: str = Field(alias="server_host")
|
|
33
|
+
server_type: str = Field(alias="server_type")
|
|
34
|
+
permission: str
|
|
35
|
+
description: str
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Category(BaseModel):
|
|
39
|
+
id: int
|
|
40
|
+
name: str
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class Project(BaseModel):
|
|
44
|
+
id: int
|
|
45
|
+
name: str
|
|
46
|
+
description: str
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class User(BaseModel):
|
|
50
|
+
id: int
|
|
51
|
+
name: str
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class SourceTask(BaseModel):
|
|
55
|
+
id: int
|
|
56
|
+
name: str
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class CreateTaskRequest(BaseModel):
|
|
60
|
+
priority: int
|
|
61
|
+
framework: str
|
|
62
|
+
name: str
|
|
63
|
+
description: Optional[str] = None
|
|
64
|
+
command: Optional[str] = None
|
|
65
|
+
image: str
|
|
66
|
+
virtual_cluster_id: int = Field(alias="virtual_cluster_id")
|
|
67
|
+
sku_cnt: int = Field(alias="sku_cnt")
|
|
68
|
+
enable_ssh: Optional[bool] = Field(False, alias="enable_ssh")
|
|
69
|
+
envs: Optional[List[Env]] = Field(default_factory=list, alias="envs")
|
|
70
|
+
storage_ids: Optional[List[int]] = Field(default_factory=list, alias="storage_ids")
|
|
71
|
+
instances: int
|
|
72
|
+
use_ib_network: Optional[bool] = Field(False, alias="use_ib_network")
|
|
73
|
+
always_pull_image: Optional[bool] = Field(False, alias="always_pull_image")
|
|
74
|
+
shm: Optional[int] = None
|
|
75
|
+
category_id: int = Field(alias="category_id")
|
|
76
|
+
project_id: int = Field(alias="project_id")
|
|
77
|
+
estimate_run_time: Optional[int] = Field(None, alias="estimate_run_time")
|
|
78
|
+
is_vip: Optional[bool] = Field(False, alias="is_vip")
|
|
79
|
+
preempt_policy: Optional[int] = Field(None, alias="preempt_policy")
|
|
80
|
+
vip_node_names: Optional[List[str]] = Field(default_factory=list, alias="vip_node_names")
|
|
81
|
+
enable_reschedule: Optional[bool] = Field(False, alias="enable_reschedule")
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class CreateTaskResponse(BaseModel):
|
|
85
|
+
id: int
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class Task(BaseModel):
|
|
89
|
+
id: int
|
|
90
|
+
priority: int
|
|
91
|
+
mtp_id: int = Field(alias="mtp_id")
|
|
92
|
+
framework: str
|
|
93
|
+
name: str
|
|
94
|
+
description: str
|
|
95
|
+
command: str
|
|
96
|
+
image: str
|
|
97
|
+
virtual_cluster: VirtualCluster = Field(alias="virtual_cluster")
|
|
98
|
+
sku_cnt: int = Field(alias="sku_cnt")
|
|
99
|
+
enable_ssh: bool = Field(alias="enable_ssh")
|
|
100
|
+
envs: Optional[List[Env]] = Field(default_factory=list, alias="envs")
|
|
101
|
+
storages: Optional[List[Storage]] = Field(default_factory=list, alias="storages")
|
|
102
|
+
instances: int
|
|
103
|
+
created_at: int = Field(alias="created_at")
|
|
104
|
+
username: str
|
|
105
|
+
user_id: int = Field(alias="user_id")
|
|
106
|
+
namespace: str
|
|
107
|
+
res_name: str = Field(alias="res_name")
|
|
108
|
+
status: int
|
|
109
|
+
use_ib_network: bool = Field(alias="use_ib_network")
|
|
110
|
+
always_pull_image: bool = Field(alias="always_pull_image")
|
|
111
|
+
shm: int
|
|
112
|
+
category: Category
|
|
113
|
+
project: Project
|
|
114
|
+
avg_gpu_util: float = Field(alias="avg_gpu_util")
|
|
115
|
+
finished_at: int = Field(alias="finished_at")
|
|
116
|
+
started_at: int = Field(alias="started_at")
|
|
117
|
+
estimate_run_time: int = Field(alias="estimate_run_time")
|
|
118
|
+
is_vip: bool = Field(alias="is_vip")
|
|
119
|
+
cluster_partition: str = Field(alias="cluster_partition")
|
|
120
|
+
preempt_policy: int = Field(alias="preempt_policy")
|
|
121
|
+
vip_node_names: Optional[List[str]] = Field(None, alias="vip_node_names")
|
|
122
|
+
stop_op_user: Optional[User] = Field(None, alias="stop_op_user")
|
|
123
|
+
use_new_log: bool = Field(alias="use_new_log")
|
|
124
|
+
is_quota_schedule: bool = Field(alias="is_quota_schedule")
|
|
125
|
+
enable_reschedule: bool = Field(alias="enable_reschedule")
|
|
126
|
+
remain_schedule_cnt: int = Field(alias="remain_schedule_cnt")
|
|
127
|
+
source_task: Optional[SourceTask] = Field(None, alias="source_task")
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class ListTasksRequest(BaseModel):
|
|
131
|
+
page_size: int = Field(20, alias="page_size")
|
|
132
|
+
page_num: int = Field(1, alias="page_num")
|
|
133
|
+
user_id: Optional[int] = Field(None, alias="user_id")
|
|
134
|
+
name: Optional[str] = None
|
|
135
|
+
virtual_cluster_id: Optional[int] = Field(None, alias="virtual_cluster_id")
|
|
136
|
+
status: Optional[int] = None
|
|
137
|
+
category_id: Optional[int] = Field(None, alias="category_id")
|
|
138
|
+
project_id: Optional[int] = Field(None, alias="project_id")
|
|
139
|
+
priority: Optional[int] = None
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class ListTasksResponse(BaseModel):
|
|
143
|
+
total: int
|
|
144
|
+
page_size: int = Field(alias="page_size")
|
|
145
|
+
page_num: int = Field(alias="page_num")
|
|
146
|
+
data: List[Task] = Field(default_factory=list)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class Pod(BaseModel):
|
|
150
|
+
id: int
|
|
151
|
+
namespace: str
|
|
152
|
+
name: str
|
|
153
|
+
status: str
|
|
154
|
+
created_at: int = Field(alias="created_at")
|
|
155
|
+
started_at: int = Field(alias="started_at")
|
|
156
|
+
finished_at: int = Field(alias="finished_at")
|
|
157
|
+
host_ip: str = Field(alias="host_ip")
|
|
158
|
+
node_name: str = Field(alias="node_name")
|
|
159
|
+
ssh_port: int = Field(alias="ssh_port")
|
|
160
|
+
ssh_info: str = Field(alias="ssh_info")
|
|
161
|
+
use_new_log: bool = Field(alias="use_new_log")
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class ListTaskPodsRequest(BaseModel):
|
|
165
|
+
page_size: int = Field(20, alias="page_size")
|
|
166
|
+
page_num: int = Field(1, alias="page_num")
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class ListTaskPodsResponse(BaseModel):
|
|
170
|
+
total: int
|
|
171
|
+
page_size: int = Field(alias="page_size")
|
|
172
|
+
page_num: int = Field(alias="page_num")
|
|
173
|
+
data: List[Pod] = Field(default_factory=list)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class PodLogInfo(BaseModel):
|
|
177
|
+
name: str
|
|
178
|
+
url: str
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
class GetTaskPodLogsNewResponse(BaseModel):
|
|
182
|
+
logs: List[PodLogInfo]
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class GetTaskPodSpecResponse(BaseModel):
|
|
186
|
+
spec: str
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class GetTaskPodEventsResponse(BaseModel):
|
|
190
|
+
events: str
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class MachineOverview(BaseModel):
|
|
194
|
+
high: int
|
|
195
|
+
low: int
|
|
196
|
+
free: int
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
class HighPrioritySummary(BaseModel):
|
|
200
|
+
group_id: int = Field(alias="group_id")
|
|
201
|
+
group_name: str = Field(alias="group_name")
|
|
202
|
+
used: int
|
|
203
|
+
total: int
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
class MetricsOverview(BaseModel):
|
|
207
|
+
vc_id: int = Field(alias="vc_id")
|
|
208
|
+
vc_name: str = Field(alias="vc_name")
|
|
209
|
+
machine: MachineOverview
|
|
210
|
+
high_priority: List[HighPrioritySummary] = Field(alias="high_priority")
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
class GetMetricsOverviewRequest(BaseModel):
|
|
214
|
+
page_size: int = Field(20, alias="page_size")
|
|
215
|
+
page_num: int = Field(1, alias="page_num")
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
class GetMetricsOverviewResponse(BaseModel):
|
|
219
|
+
total: int
|
|
220
|
+
page_size: int = Field(alias="page_size")
|
|
221
|
+
page_num: int = Field(alias="page_num")
|
|
222
|
+
data: List[MetricsOverview] = Field(default_factory=list)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
class TaskUser(BaseModel):
|
|
226
|
+
user_id: int = Field(alias="user_id")
|
|
227
|
+
username: str
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
class ListTaskUsersRequest(BaseModel):
|
|
231
|
+
page_size: int = Field(20, alias="page_size")
|
|
232
|
+
page_num: int = Field(1, alias="page_num")
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
class ListTaskUsersResponse(BaseModel):
|
|
236
|
+
total: int
|
|
237
|
+
page_size: int = Field(alias="page_size")
|
|
238
|
+
page_num: int = Field(alias="page_num")
|
|
239
|
+
data: List[TaskUser] = Field(default_factory=list)
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
# !/usr/bin/env python
|
|
2
|
-
# -*-coding:utf-8 -*-
|
|
3
|
-
|
|
4
|
-
from __future__ import annotations
|
|
5
|
-
|
|
6
|
-
from typing import List, Optional
|
|
7
|
-
|
|
8
|
-
from pydantic import BaseModel, Field
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class Project(BaseModel):
|
|
12
|
-
id: int
|
|
13
|
-
name: str
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class ProjectListData(BaseModel):
|
|
17
|
-
data: List[Project]
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class SelectProjectsResponse(BaseModel):
|
|
21
|
-
data: List[Project]
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class SkuBrief(BaseModel):
|
|
25
|
-
id: int
|
|
26
|
-
description: str
|
|
27
|
-
cpu: int
|
|
28
|
-
memory: int
|
|
29
|
-
gpu_type: int = Field(alias="gpu_type")
|
|
30
|
-
gpu_memory: int = Field(alias="gpu_memory")
|
|
31
|
-
network: int
|
|
32
|
-
created_at: int = Field(alias="created_at")
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class VirtualClusterBrief(BaseModel):
|
|
36
|
-
id: int
|
|
37
|
-
name: str
|
|
38
|
-
uuid: str
|
|
39
|
-
sku: Optional[SkuBrief] = None
|
|
40
|
-
created_at: int = Field(alias="created_at")
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class SelectVirtualClustersRequest(BaseModel):
|
|
44
|
-
user_id: int = Field(alias="user_id")
|
|
45
|
-
module_type: Optional[int] = Field(None, alias="module_type")
|
|
46
|
-
new_module_type: Optional[str] = Field(None, alias="new_module_type")
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
class SelectVirtualClustersResponse(BaseModel):
|
|
50
|
-
data: Optional[List[VirtualClusterBrief]] = Field(default_factory=list)
|
|
1
|
+
# !/usr/bin/env python
|
|
2
|
+
# -*-coding:utf-8 -*-
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import List, Optional
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel, Field
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Project(BaseModel):
|
|
12
|
+
id: int
|
|
13
|
+
name: str
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ProjectListData(BaseModel):
|
|
17
|
+
data: List[Project]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class SelectProjectsResponse(BaseModel):
|
|
21
|
+
data: List[Project]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class SkuBrief(BaseModel):
|
|
25
|
+
id: int
|
|
26
|
+
description: str
|
|
27
|
+
cpu: int
|
|
28
|
+
memory: int
|
|
29
|
+
gpu_type: int = Field(alias="gpu_type")
|
|
30
|
+
gpu_memory: int = Field(alias="gpu_memory")
|
|
31
|
+
network: int
|
|
32
|
+
created_at: int = Field(alias="created_at")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class VirtualClusterBrief(BaseModel):
|
|
36
|
+
id: int
|
|
37
|
+
name: str
|
|
38
|
+
uuid: str
|
|
39
|
+
sku: Optional[SkuBrief] = None
|
|
40
|
+
created_at: int = Field(alias="created_at")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class SelectVirtualClustersRequest(BaseModel):
|
|
44
|
+
user_id: int = Field(alias="user_id")
|
|
45
|
+
module_type: Optional[int] = Field(None, alias="module_type")
|
|
46
|
+
new_module_type: Optional[str] = Field(None, alias="new_module_type")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class SelectVirtualClustersResponse(BaseModel):
|
|
50
|
+
data: Optional[List[VirtualClusterBrief]] = Field(default_factory=list)
|
aihub/models/task_center.py
CHANGED
|
@@ -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
|
-
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
|
-
)
|
|
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
|
+
)
|