intellif-aihub 0.1.4__py3-none-any.whl → 0.1.6__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 +35 -12
- aihub/models/artifact.py +1 -1
- aihub/models/data_warehouse.py +95 -0
- aihub/models/dataset_management.py +99 -61
- aihub/models/document_center.py +26 -18
- aihub/models/eval.py +20 -11
- aihub/models/labelfree.py +12 -38
- aihub/models/model_center.py +141 -0
- aihub/models/model_training_platform.py +183 -149
- aihub/models/quota_schedule_management.py +201 -150
- aihub/models/tag_resource_management.py +30 -24
- aihub/models/task_center.py +39 -36
- aihub/models/user_system.py +159 -125
- aihub/models/workflow_center.py +461 -0
- aihub/services/artifact.py +22 -15
- aihub/services/data_warehouse.py +97 -0
- aihub/services/dataset_management.py +142 -23
- aihub/services/document_center.py +24 -5
- aihub/services/eval.py +14 -7
- aihub/services/labelfree.py +11 -0
- aihub/services/model_center.py +183 -0
- aihub/services/model_training_platform.py +99 -29
- aihub/services/quota_schedule_management.py +104 -7
- aihub/services/tag_resource_management.py +33 -2
- aihub/services/task_center.py +23 -9
- aihub/services/user_system.py +237 -2
- aihub/services/workflow_center.py +522 -0
- aihub/utils/download.py +19 -3
- {intellif_aihub-0.1.4.dist-info → intellif_aihub-0.1.6.dist-info}/METADATA +3 -3
- intellif_aihub-0.1.6.dist-info/RECORD +42 -0
- intellif_aihub-0.1.4.dist-info/RECORD +0 -36
- {intellif_aihub-0.1.4.dist-info → intellif_aihub-0.1.6.dist-info}/WHEEL +0 -0
- {intellif_aihub-0.1.4.dist-info → intellif_aihub-0.1.6.dist-info}/licenses/LICENSE +0 -0
- {intellif_aihub-0.1.4.dist-info → intellif_aihub-0.1.6.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from enum import IntEnum
|
|
4
|
+
from typing import List, Optional
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Env(BaseModel):
|
|
10
|
+
"""环境变量"""
|
|
11
|
+
key: str = Field(description="变量名")
|
|
12
|
+
value: Optional[str] = Field(None, description="变量值")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Source(BaseModel):
|
|
16
|
+
"""节点输入来源"""
|
|
17
|
+
node: Optional[str] = Field(None, description="节点")
|
|
18
|
+
param: Optional[str] = Field(None, description="参数名")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class InputParam(BaseModel):
|
|
22
|
+
"""节点输入"""
|
|
23
|
+
input_param: str = Field(alias="input_param", description="输入参数名")
|
|
24
|
+
source: Optional[Source] = Field(None, description="来源")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class PipelineInput(BaseModel):
|
|
28
|
+
"""顶层输入"""
|
|
29
|
+
input_param: str = Field(alias="input_param", description="顶层输入参数名")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class OutputParam(BaseModel):
|
|
33
|
+
"""节点输出"""
|
|
34
|
+
output_param: str = Field(alias="output_param", description="输出参数名")
|
|
35
|
+
output_file: str = Field(alias="output_file", description="生成文件路径")
|
|
36
|
+
value_type: Optional[int] = Field(None, alias="value_type", description="0-字符串,1-文件路径")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class Node(BaseModel):
|
|
40
|
+
"""工作流节点"""
|
|
41
|
+
uuid: str = Field(description="节点唯一ID")
|
|
42
|
+
position: Optional[List[int]] = Field(default_factory=list, description="画布坐标")
|
|
43
|
+
name: str = Field(description="节点名称")
|
|
44
|
+
task_type: str = Field(alias="task_type", description="任务类别 compute/monitor")
|
|
45
|
+
depends_on: List[str] = Field(alias="depends_on", description="依赖节点uuid列表")
|
|
46
|
+
command: Optional[str] = Field(None, description="执行命令")
|
|
47
|
+
image: Optional[str] = Field(None, description="镜像")
|
|
48
|
+
retry_cnt: Optional[int] = Field(0, alias="retry_cnt", description="失败重试次数")
|
|
49
|
+
virtual_cluster_id: Optional[int] = Field(None, alias="virtual_cluster_id", description="虚拟集群ID")
|
|
50
|
+
sku_cnt: Optional[int] = Field(None, alias="sku_cnt", description="sku数量")
|
|
51
|
+
envs: List[Env] = Field(default_factory=list, alias="envs", description="环境变量")
|
|
52
|
+
inputs: List[InputParam] = Field(default_factory=list, alias="inputs", description="输入列表")
|
|
53
|
+
outputs: List[OutputParam] = Field(default_factory=list, alias="outputs", description="输出列表")
|
|
54
|
+
storage_ids: List[int] = Field(default_factory=list, alias="storage_ids", description="挂载存储 ID")
|
|
55
|
+
module_id: Optional[int] = Field(None, alias="module_id", description="模块 ID")
|
|
56
|
+
module_version: Optional[int] = Field(None, alias="module_version", description="模块版本号")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class User(BaseModel):
|
|
60
|
+
"""用户"""
|
|
61
|
+
id: int = Field(description="用户ID")
|
|
62
|
+
name: str = Field(description="用户名")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class EnvDef(BaseModel):
|
|
66
|
+
"""模块环境变量定义"""
|
|
67
|
+
key: str = Field(description="名称")
|
|
68
|
+
description: str = Field(description="描述")
|
|
69
|
+
is_optional: Optional[bool] = Field(False, alias="is_optional", description="是否可选")
|
|
70
|
+
suggestion: Optional[str] = Field(None, description="建议配置")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class InputDef(BaseModel):
|
|
74
|
+
"""模块输入定义"""
|
|
75
|
+
name: str = Field(description="名称")
|
|
76
|
+
description: str = Field(description="描述")
|
|
77
|
+
is_optional: Optional[bool] = Field(False, alias="is_optional", description="是否可选")
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class OutputDef(BaseModel):
|
|
81
|
+
"""模块输出定义"""
|
|
82
|
+
name: str = Field(description="名称")
|
|
83
|
+
value_type: int = Field(alias="value_type", description="类型,0-普通文本,1-文件路径")
|
|
84
|
+
description: str = Field(description="描述")
|
|
85
|
+
path: str = Field(description="路径")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class ModuleCategory(BaseModel):
|
|
89
|
+
"""模块类别"""
|
|
90
|
+
id: int = Field(description="类别 ID")
|
|
91
|
+
name: str = Field(description="类别名称")
|
|
92
|
+
description: str = Field(description="类别描述")
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class CodeConfig(BaseModel):
|
|
96
|
+
"""构建镜像所需的代码仓库信息"""
|
|
97
|
+
repo: str = Field(description="仓库地址")
|
|
98
|
+
ref: str = Field(description="分支/Tag")
|
|
99
|
+
commit: str = Field(description="Commit 哈希")
|
|
100
|
+
dockerfile: str = Field(description="Dockerfile路径")
|
|
101
|
+
build_dir: str = Field(alias="build_dir", description="构建目录")
|
|
102
|
+
readme_path: str = Field(alias="readme_path", description="README文件路径")
|
|
103
|
+
readme_content: str = Field(alias="readme_content", description="README纯文本")
|
|
104
|
+
image_id: int = Field(alias="image_id", description="生成镜像记录ID")
|
|
105
|
+
image_uri: str = Field(alias="image_uri", description="镜像仓库URI")
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class Module(BaseModel):
|
|
109
|
+
"""可复用任务模块"""
|
|
110
|
+
id: int = Field(description="模块ID")
|
|
111
|
+
name: str = Field(description="模块名称")
|
|
112
|
+
version: int = Field(description="版本号")
|
|
113
|
+
description: str = Field(description="模块简介")
|
|
114
|
+
category: ModuleCategory = Field(description="所属类别")
|
|
115
|
+
code_config: CodeConfig = Field(alias="code_config", description="代码配置")
|
|
116
|
+
envs: List[EnvDef] = Field(description="环境变量")
|
|
117
|
+
inputs: List[InputDef] = Field(description="输入参数")
|
|
118
|
+
outputs: List[OutputDef] = Field(description="输出参数")
|
|
119
|
+
creator: User = Field(description="创建人")
|
|
120
|
+
created_at: int = Field(alias="created_at", description="创建时间")
|
|
121
|
+
updated_at: int = Field(alias="updated_at", description="更新时间")
|
|
122
|
+
status: int = Field(description="状态:1-构建中,2-构建成功,3-构建失败,4-审核中,5-已发布,6-审核失败")
|
|
123
|
+
hardware_suggestion: str = Field(alias="hardware_suggestion", description="硬件配置建议")
|
|
124
|
+
audit_fail_reason: str = Field(alias="audit_fail_reason", description="审核失败原因")
|
|
125
|
+
used_cnt: int = Field(alias="used_cnt", description="被引用次数")
|
|
126
|
+
ran_cnt: int = Field(alias="ran_cnt", description="累计运行次数")
|
|
127
|
+
image_build_log_url: str = Field(alias="image_build_log_url", description="镜像构建日志链接")
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
# ------------------------------------------------------------------ #
|
|
131
|
+
# Pipeline
|
|
132
|
+
# ------------------------------------------------------------------ #
|
|
133
|
+
class Pipeline(BaseModel):
|
|
134
|
+
"""工作流"""
|
|
135
|
+
id: int = Field(description="工作流 ID")
|
|
136
|
+
name: str = Field(description="名称")
|
|
137
|
+
description: str = Field(description="描述")
|
|
138
|
+
latest_version_id: Optional[int] = Field(None, alias="latest_version_id", description="最新版本ID")
|
|
139
|
+
latest_version_name: Optional[str] = Field(None, alias="latest_version_name", description="最新版本名")
|
|
140
|
+
version_cnt: int = Field(alias="version_cnt", description="版本数量")
|
|
141
|
+
created_at: int = Field(alias="created_at", description="创建时间戳(ms)")
|
|
142
|
+
user_id: int = Field(alias="user_id", description="创建者ID")
|
|
143
|
+
username: str = Field(description="创建者用户名")
|
|
144
|
+
ran_cnt: int = Field(alias="ran_cnt", description="累计运行次数")
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class ListPipelinesRequest(BaseModel):
|
|
148
|
+
"""查询工作流列表请求"""
|
|
149
|
+
page_size: int = Field(20, alias="page_size", description="每页数量")
|
|
150
|
+
page_num: int = Field(1, alias="page_num", description="当前页码")
|
|
151
|
+
name: Optional[str] = Field(None, description="名称过滤")
|
|
152
|
+
user_id: Optional[int] = Field(None, alias="user_id", description="用户过滤")
|
|
153
|
+
order_by: Optional[str] = Field(None, alias="order_by", description="排序字段")
|
|
154
|
+
order_type: Optional[str] = Field(None, alias="order_type", description="asc/desc")
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class ListPipelinesResponse(BaseModel):
|
|
158
|
+
"""查询工作流列表返回"""
|
|
159
|
+
total: int = Field(description="总数")
|
|
160
|
+
page_size: int = Field(alias="page_size", description="每页数量")
|
|
161
|
+
page_num: int = Field(alias="page_num", description="当前页码")
|
|
162
|
+
data: Optional[List[Pipeline]] = Field(default_factory=list, description="工作流列表")
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class CreatePipelineRequest(BaseModel):
|
|
166
|
+
"""创建工作流请求"""
|
|
167
|
+
pipeline_name: str = Field(alias="pipeline_name", description="工作流名称")
|
|
168
|
+
version_name: str = Field(alias="version_name", description="版本名称")
|
|
169
|
+
description: Optional[str] = Field(None, description="描述")
|
|
170
|
+
nodes: Optional[List[Node]] = Field(default_factory=list, description="节点定义列表")
|
|
171
|
+
inputs: Optional[List[PipelineInput]] = Field(default_factory=list, description="顶层输入参数列表")
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class CreatePipelineResponse(BaseModel):
|
|
175
|
+
"""创建工作流返回"""
|
|
176
|
+
id: int = Field(description="工作流ID")
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class PipelineBrief(BaseModel):
|
|
180
|
+
"""工作流简要信息"""
|
|
181
|
+
id: int = Field(description="工作流ID")
|
|
182
|
+
name: str = Field(description="名称")
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class SelectPipelinesRequest(BaseModel):
|
|
186
|
+
"""选择工作流请求"""
|
|
187
|
+
name: Optional[str] = Field(None, description="名称过滤")
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class SelectPipelinesResponse(BaseModel):
|
|
191
|
+
"""选择工作流返回"""
|
|
192
|
+
data: Optional[List[PipelineBrief]] = Field(default_factory=list, description="工作流简要列表")
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class PipelineUserBrief(BaseModel):
|
|
196
|
+
"""工作流用户信息"""
|
|
197
|
+
id: int = Field(description="用户ID")
|
|
198
|
+
name: str = Field(description="用户名")
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
class SelectPipelineUsersResponse(BaseModel):
|
|
202
|
+
"""选择工作流用户返回"""
|
|
203
|
+
data: Optional[List[PipelineUserBrief]] = Field(default_factory=list, description="工作流用户列表")
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
# ------------------------------------------------------------------ #
|
|
207
|
+
# Pipeline-Version
|
|
208
|
+
# ------------------------------------------------------------------ #
|
|
209
|
+
class PipelineVersion(BaseModel):
|
|
210
|
+
"""工作流版本信息"""
|
|
211
|
+
id: int = Field(description="版本ID")
|
|
212
|
+
pipeline_id: int = Field(alias="pipeline_id", description="工作流ID")
|
|
213
|
+
name: str = Field(description="版本名")
|
|
214
|
+
description: str = Field(description="描述")
|
|
215
|
+
created_at: int = Field(alias="created_at", description="创建时间")
|
|
216
|
+
input_config: str = Field(alias="input_config", description="输入配置")
|
|
217
|
+
can_copy: bool = Field(alias="can_copy", description="是否允许复制")
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
class ListPipelineVersionsRequest(BaseModel):
|
|
221
|
+
"""查询工作流版本列表请求"""
|
|
222
|
+
page_size: int = Field(20, alias="page_size", description="每页数量")
|
|
223
|
+
page_num: int = Field(1, alias="page_num", description="当前页码")
|
|
224
|
+
pipeline_id: Optional[int] = Field(None, alias="pipeline_id", description="按工作流ID过滤")
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class ListPipelineVersionsResponse(BaseModel):
|
|
228
|
+
"""查询工作流版本列表返回"""
|
|
229
|
+
total: int = Field(description="总数")
|
|
230
|
+
page_size: int = Field(alias="page_size", description="每页数量")
|
|
231
|
+
page_num: int = Field(alias="page_num", description="当前页码")
|
|
232
|
+
data: Optional[List[PipelineVersion]] = Field(default_factory=list, description="工作流版本列表")
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
class CreatePipelineVersionRequest(BaseModel):
|
|
236
|
+
"""创建工作流版本请求"""
|
|
237
|
+
pipeline_id: int = Field(alias="pipeline_id", description="工作流ID")
|
|
238
|
+
version_name: str = Field(alias="version_name", description="版本名")
|
|
239
|
+
description: Optional[str] = Field(None, description="描述")
|
|
240
|
+
nodes: Optional[List[Node]] = Field(default_factory=list, description="节点定义")
|
|
241
|
+
inputs: Optional[List[PipelineInput]] = Field(default_factory=list, description="输入定义")
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
class CreatePipelineVersionResponse(BaseModel):
|
|
245
|
+
"""创建工作流版本返回"""
|
|
246
|
+
id: int = Field(description="工作流版本ID")
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
class PipelineVersionBrief(BaseModel):
|
|
250
|
+
"""工作流版本简要信息"""
|
|
251
|
+
id: int = Field(description="工作流版本ID")
|
|
252
|
+
name: str = Field(description="版本名")
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
class SelectPipelineVersionsRequest(BaseModel):
|
|
256
|
+
"""选择工作流版本请求"""
|
|
257
|
+
name: Optional[str] = Field(None, description="名称过滤")
|
|
258
|
+
pipeline_id: int = Field(alias="pipeline_id", description="工作流ID过滤")
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
class SelectPipelineVersionsResponse(BaseModel):
|
|
262
|
+
"""选择工作流版本返回"""
|
|
263
|
+
data: Optional[List[PipelineVersionBrief]] = Field(default_factory=list, description="工作流版本下拉列表")
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
class GetPipelineVersionInputParamsResponse(BaseModel):
|
|
267
|
+
"""获取工作流版本输入参数返回"""
|
|
268
|
+
data: Optional[List[str]] = Field(default_factory=list, description="工作流版本的输入参数")
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
class MigratePipelineVersionsRequest(BaseModel):
|
|
272
|
+
"""迁移工作流版本请求"""
|
|
273
|
+
start_id: int = Field(alias="start_id", description="开始版本ID")
|
|
274
|
+
end_id: int = Field(alias="end_id", description="结束版本ID")
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
# ------------------------------------------------------------------ #
|
|
278
|
+
# Run
|
|
279
|
+
# ------------------------------------------------------------------ #
|
|
280
|
+
class Sku(BaseModel):
|
|
281
|
+
"""sku"""
|
|
282
|
+
cpu: int = Field(description="CPU")
|
|
283
|
+
gpu: int = Field(description="GPU")
|
|
284
|
+
memory: int = Field(description="内存 GiB")
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
class VirtualCluster(BaseModel):
|
|
288
|
+
"""虚拟集群"""
|
|
289
|
+
id: int = Field(description="虚拟集群ID")
|
|
290
|
+
name: str = Field(description="虚拟集群名称")
|
|
291
|
+
sku: Sku = Field(description="sku")
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
class Project(BaseModel):
|
|
295
|
+
"""项目"""
|
|
296
|
+
id: int = Field(description="项目ID")
|
|
297
|
+
name: str = Field(description="项目名称")
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
class IOParam(BaseModel):
|
|
301
|
+
"""输入/输出参数"""
|
|
302
|
+
input: str = Field(description="输入参数")
|
|
303
|
+
output: str = Field(description="输出参数")
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
class TaskNodeStatus(IntEnum):
|
|
307
|
+
"""任务节点状态"""
|
|
308
|
+
Waiting = 1
|
|
309
|
+
Running = 2
|
|
310
|
+
Success = 3
|
|
311
|
+
Fail = 4
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
class TaskNode(BaseModel):
|
|
315
|
+
"""运行任务的单个节点信息"""
|
|
316
|
+
name: str = Field(description="节点名称")
|
|
317
|
+
params: IOParam = Field(description="输入/输出")
|
|
318
|
+
message: str = Field(description="消息")
|
|
319
|
+
status: TaskNodeStatus = Field(description="状态")
|
|
320
|
+
namespace: str = Field(description="K8s Namespace")
|
|
321
|
+
pod_name: str = Field(alias="pod_name", description="Pod 名称")
|
|
322
|
+
started_at: int = Field(alias="started_at", description="启动时间戳")
|
|
323
|
+
finished_at: int = Field(alias="finished_at", description="完成时间戳")
|
|
324
|
+
dependencies: Optional[List[str]] = Field(default_factory=list, description="依赖节点 uuid")
|
|
325
|
+
task_id: int = Field(alias="task_id", description="任务ID")
|
|
326
|
+
module_id: int = Field(alias="module_id", description="模块ID")
|
|
327
|
+
module_version: int = Field(alias="module_version", description="模块版本号")
|
|
328
|
+
use_cache: bool = Field(alias="use_cache", description="是否使用缓存")
|
|
329
|
+
virtual_cluster: VirtualCluster = Field(alias="virtual_cluster", description="虚拟集群")
|
|
330
|
+
avg_gpu_util: float = Field(alias="avg_gpu_util", description="平均GPU利用率")
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
class Param(BaseModel):
|
|
334
|
+
"""参数"""
|
|
335
|
+
key: str = Field(description="键")
|
|
336
|
+
value: Optional[str] = Field(None, description="值")
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
class NodeVirtualCluster(BaseModel):
|
|
340
|
+
"""节点虚拟集群"""
|
|
341
|
+
virtual_cluster: VirtualCluster = Field(alias="virtual_cluster", description="虚拟集群")
|
|
342
|
+
nodes: List[str] = Field(description="节点列表")
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
class RunStatus(IntEnum):
|
|
346
|
+
"""运行状态"""
|
|
347
|
+
Waiting = 1
|
|
348
|
+
Running = 2
|
|
349
|
+
Success = 3
|
|
350
|
+
Failed = 4
|
|
351
|
+
Stopped = 5
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
class Run(BaseModel):
|
|
355
|
+
"""运行实例"""
|
|
356
|
+
id: int = Field(description="ID")
|
|
357
|
+
name: str = Field(description="名称")
|
|
358
|
+
description: str = Field(description="描述")
|
|
359
|
+
duration: int = Field(description="总耗时(s)")
|
|
360
|
+
pipeline_id: int = Field(alias="pipeline_id", description="工作流ID")
|
|
361
|
+
pipeline_name: str = Field(alias="pipeline_name", description="工作流名称")
|
|
362
|
+
pipeline_version_id: int = Field(alias="pipeline_version_id", description="工作流版本ID")
|
|
363
|
+
pipeline_version_name: str = Field(alias="pipeline_version_name", description="工作流版本名")
|
|
364
|
+
started_at: int = Field(alias="started_at", description="开始时间")
|
|
365
|
+
finished_at: int = Field(alias="finished_at", description="结束时间")
|
|
366
|
+
created_at: int = Field(alias="created_at", description="创建时间")
|
|
367
|
+
status: RunStatus = Field(description="状态码")
|
|
368
|
+
task_nodes: Optional[List[TaskNode]] = Field(default_factory=list, alias="task_nodes", description="节点信息")
|
|
369
|
+
params: Optional[List[Param]] = Field(default_factory=list, description="运行时入参")
|
|
370
|
+
username: str = Field(description="用户名")
|
|
371
|
+
node_virtual_clusters: Optional[List[NodeVirtualCluster]] = Field(default_factory=list,
|
|
372
|
+
alias="node_virtual_clusters",
|
|
373
|
+
description="节点虚拟集群")
|
|
374
|
+
project: Project = Field(description="所属项目")
|
|
375
|
+
avg_gpu_util: float = Field(alias="avg_gpu_util", description="平均GPU利用率")
|
|
376
|
+
total_gpu_time: float = Field(alias="total_gpu_time", description="总的gpu用时")
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
class ListRunsRequest(BaseModel):
|
|
380
|
+
"""查询运行实例列表请求"""
|
|
381
|
+
page_size: int = Field(20, alias="page_size", description="每页数量")
|
|
382
|
+
page_num: int = Field(1, alias="page_num", description="当前页码")
|
|
383
|
+
name: Optional[str] = Field(None, description="名称过滤")
|
|
384
|
+
user_id: Optional[int] = Field(None, alias="user_id", description="用户过滤")
|
|
385
|
+
status: Optional[RunStatus] = Field(None, description="状态过滤")
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
class ListRunsResponse(BaseModel):
|
|
389
|
+
"""查询运行实例列表返回"""
|
|
390
|
+
total: int = Field(description="总数")
|
|
391
|
+
page_size: int = Field(alias="page_size", description="每页数量")
|
|
392
|
+
page_num: int = Field(alias="page_num", description="当前页码")
|
|
393
|
+
data: Optional[List[Run]] = Field(default_factory=list, description="运行列表")
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
class NodeVirtualClusterSetting(BaseModel):
|
|
397
|
+
"""节点虚拟集群设置"""
|
|
398
|
+
virtual_cluster_id: int = Field(alias="virtual_cluster_id", description="虚拟集群ID")
|
|
399
|
+
nodes: List[str] = Field(description="节点列表")
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
class CreateRunRequest(BaseModel):
|
|
403
|
+
"""创建运行实例请求"""
|
|
404
|
+
pipeline_id: int = Field(alias="pipeline_id", description="工作流ID")
|
|
405
|
+
pipeline_version_id: int = Field(alias="pipeline_version_id", description="工作流版本ID")
|
|
406
|
+
name: str = Field(description="运行名称")
|
|
407
|
+
description: Optional[str] = Field(None, description="描述")
|
|
408
|
+
params: Optional[List[Param]] = Field(default_factory=list, description="运行时入参")
|
|
409
|
+
user_id: Optional[int] = Field(None, alias="user_id", description="用户ID")
|
|
410
|
+
use_cache: Optional[bool] = Field(False, alias="use_cache", description="是否使用缓存")
|
|
411
|
+
node_virtual_clusters: Optional[List[NodeVirtualClusterSetting]] = Field(default_factory=list,
|
|
412
|
+
alias="node_virtual_clusters",
|
|
413
|
+
description="节点虚拟集群")
|
|
414
|
+
project_id: int = Field(alias="project_id", description="所属项目ID")
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
class CreateRunResponse(BaseModel):
|
|
418
|
+
"""创建运行实例返回"""
|
|
419
|
+
id: int = Field(description="运行ID")
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
class GetRunTaskLogsResponse(BaseModel):
|
|
423
|
+
"""获取运行实例日志返回"""
|
|
424
|
+
log: str = Field(description="日志文本")
|
|
425
|
+
log_s3_url: str = Field(alias="log_s3_url", description="日志文件S3链接")
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
class GetRunTaskPodResponse(BaseModel):
|
|
429
|
+
"""获取运行实例Pod返回"""
|
|
430
|
+
pod: str = Field(description="Pod描述YAML")
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
class GetRunTaskEventsResponse(BaseModel):
|
|
434
|
+
"""获取运行实例Event返回"""
|
|
435
|
+
events: str = Field(description="事件文本")
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
class RunUserBrief(BaseModel):
|
|
439
|
+
"""运行实例用户简要信息"""
|
|
440
|
+
id: int = Field(description="用户ID")
|
|
441
|
+
name: str = Field(description="用户名")
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
class SelectRunUsersResponse(BaseModel):
|
|
445
|
+
"""选择运行实例用户返回"""
|
|
446
|
+
data: Optional[List[RunUserBrief]] = Field(default_factory=list, description="运行用户列表")
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
class RetryRunResponse(Run):
|
|
450
|
+
"""重试Run返回"""
|
|
451
|
+
pass
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
class StopRunResponse(Run):
|
|
455
|
+
"""停止Run返回"""
|
|
456
|
+
pass
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
class ResubmitRunResponse(Run):
|
|
460
|
+
"""重新提交Run返回"""
|
|
461
|
+
pass
|
aihub/services/artifact.py
CHANGED
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
# -*-coding:utf-8 -*-
|
|
3
3
|
"""制品管理服务模块
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
封装 **Artifact‑Management** 相关接口,核心能力包括:
|
|
6
|
+
|
|
7
|
+
- **创建制品** – 支持单文件或目录一次性打包上传
|
|
8
|
+
- **上传制品** – 自动分片、断点续传,兼容大文件
|
|
9
|
+
- **制品查询** – 按 *Run ID* / 路径精准过滤
|
|
10
|
+
- **制品下载** – 支持文件级与目录级批量下载
|
|
11
|
+
|
|
12
|
+
制品类型覆盖 *数据集、模型、指标、日志、检查点、图像、预测结果* 等
|
|
7
13
|
"""
|
|
14
|
+
|
|
8
15
|
from __future__ import annotations
|
|
9
16
|
|
|
10
17
|
import os
|
|
@@ -92,7 +99,7 @@ class ArtifactService:
|
|
|
92
99
|
return self._artifact.get_sts()
|
|
93
100
|
|
|
94
101
|
def get_by_run_id(
|
|
95
|
-
|
|
102
|
+
self, run_id: str, artifact_path: Optional[str] = None
|
|
96
103
|
) -> List[ArtifactResp]:
|
|
97
104
|
"""根据运行ID获取制品列表
|
|
98
105
|
|
|
@@ -109,11 +116,11 @@ class ArtifactService:
|
|
|
109
116
|
return self._artifact.get_by_run_id(run_id, artifact_path)
|
|
110
117
|
|
|
111
118
|
def create_artifact(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
self,
|
|
120
|
+
local_path: str,
|
|
121
|
+
artifact_path: Optional[str] = None,
|
|
122
|
+
run_id: Optional[str] = None,
|
|
123
|
+
artifact_type: ArtifactType = ArtifactType.other,
|
|
117
124
|
) -> None:
|
|
118
125
|
"""创建单个文件制品并上传
|
|
119
126
|
|
|
@@ -164,11 +171,11 @@ class ArtifactService:
|
|
|
164
171
|
return
|
|
165
172
|
|
|
166
173
|
def create_artifacts(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
self,
|
|
175
|
+
local_dir: str,
|
|
176
|
+
artifact_path: Optional[str] = None,
|
|
177
|
+
run_id: Optional[str] = None,
|
|
178
|
+
artifact_type: ArtifactType = ArtifactType.other,
|
|
172
179
|
) -> None:
|
|
173
180
|
"""创建目录制品并上传
|
|
174
181
|
|
|
@@ -217,7 +224,7 @@ class ArtifactService:
|
|
|
217
224
|
return
|
|
218
225
|
|
|
219
226
|
def download_artifacts(
|
|
220
|
-
|
|
227
|
+
self, run_id: str, artifact_path: Optional[str], local_dir: str
|
|
221
228
|
) -> None:
|
|
222
229
|
"""下载制品
|
|
223
230
|
|
|
@@ -305,7 +312,7 @@ class _Artifact:
|
|
|
305
312
|
return
|
|
306
313
|
|
|
307
314
|
def get_by_run_id(
|
|
308
|
-
|
|
315
|
+
self, run_id: str, artifact_path: Optional[str]
|
|
309
316
|
) -> List[ArtifactResp]:
|
|
310
317
|
"""根据运行ID获取制品列表
|
|
311
318
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# !/usr/bin/env python
|
|
2
|
+
# -*- coding:utf-8 -*-
|
|
3
|
+
"""数据仓库服务模块
|
|
4
|
+
|
|
5
|
+
本模块围绕 **“检索任务”** 提供增查接口,包括:
|
|
6
|
+
|
|
7
|
+
- **创建检索任务**
|
|
8
|
+
- **分页查询检索任务列表**
|
|
9
|
+
- **根据检索任务 ID 获取详情**
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import httpx
|
|
15
|
+
|
|
16
|
+
from ..exceptions import APIError
|
|
17
|
+
from ..models.common import APIWrapper
|
|
18
|
+
from ..models.data_warehouse import (
|
|
19
|
+
ListSearchRequest,
|
|
20
|
+
ListSearchResponse,
|
|
21
|
+
CreateSearchRequest,
|
|
22
|
+
CreateSearchResponse,
|
|
23
|
+
Search,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
_BASE = "/data-warehouse/api/v1"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class DataWarehouseService:
|
|
30
|
+
"""数据仓库服务类"""
|
|
31
|
+
|
|
32
|
+
def __init__(self, http: httpx.Client):
|
|
33
|
+
self._search = _Search(http)
|
|
34
|
+
|
|
35
|
+
def list_searches(self, payload: ListSearchRequest) -> ListSearchResponse:
|
|
36
|
+
"""分页查询检索任务
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
payload: 查询条件,包含分页信息、名称 / 状态 / 用户过滤条件等
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
ListSearchResponse: 分页结果
|
|
43
|
+
"""
|
|
44
|
+
return self._search.list(payload)
|
|
45
|
+
|
|
46
|
+
def get_search(self, search_id: int) -> Search:
|
|
47
|
+
"""根据检索任务ID获取详情
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
search_id: 检索任务ID
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
Search: 检索任务完整信息对象
|
|
54
|
+
"""
|
|
55
|
+
return self._search.get(search_id)
|
|
56
|
+
|
|
57
|
+
def create_search(self, payload: CreateSearchRequest) -> int:
|
|
58
|
+
"""创建检索任务,根据传入的检索类型及参数在后台创建任务,返回任务ID
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
payload: 创建检索任务请求体。字段含义见 `CreateSearchRequest`
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
int: 新建检索任务的ID
|
|
65
|
+
"""
|
|
66
|
+
return self._search.create(payload)
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def search(self) -> _Search:
|
|
70
|
+
return self._search
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class _Search:
|
|
74
|
+
|
|
75
|
+
def __init__(self, http: httpx.Client):
|
|
76
|
+
self._http = http
|
|
77
|
+
|
|
78
|
+
def list(self, payload: ListSearchRequest) -> ListSearchResponse:
|
|
79
|
+
resp = self._http.get(f"{_BASE}/searches", params=payload.model_dump(by_alias=True, exclude_none=True))
|
|
80
|
+
wrapper = APIWrapper[ListSearchResponse].model_validate(resp.json())
|
|
81
|
+
if wrapper.code != 0:
|
|
82
|
+
raise APIError(f"backend code {wrapper.code}: {wrapper.msg}")
|
|
83
|
+
return wrapper.data
|
|
84
|
+
|
|
85
|
+
def get(self, search_id: int) -> Search:
|
|
86
|
+
resp = self._http.get(f"{_BASE}/searches/{search_id}")
|
|
87
|
+
wrapper = APIWrapper[Search].model_validate(resp.json())
|
|
88
|
+
if wrapper.code != 0:
|
|
89
|
+
raise APIError(f"backend code {wrapper.code}: {wrapper.msg}")
|
|
90
|
+
return wrapper.data
|
|
91
|
+
|
|
92
|
+
def create(self, payload: CreateSearchRequest) -> int:
|
|
93
|
+
resp = self._http.post(f"{_BASE}/searches", json=payload.model_dump(by_alias=True, exclude_none=True))
|
|
94
|
+
wrapper = APIWrapper[CreateSearchResponse].model_validate(resp.json())
|
|
95
|
+
if wrapper.code != 0:
|
|
96
|
+
raise APIError(f"backend code {wrapper.code}: {wrapper.msg}")
|
|
97
|
+
return wrapper.data.id
|