339 lines
11 KiB
Go
339 lines
11 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
const (
|
|
MainTaskID = "1"
|
|
DataReturnTaskID = "4"
|
|
AITaskType = "AI"
|
|
DataReturnType = "DataReturn"
|
|
|
|
JobSetIDKey = "jobSetID"
|
|
LocalJobIDKey = "localJobID"
|
|
ResponseOK = "OK"
|
|
)
|
|
|
|
// SubtaskRequest 表示子任务请求
|
|
type SubtaskRequest struct {
|
|
UserID int `json:"userID"`
|
|
JobSetInfo JobSetInfo `json:"jobSetInfo"`
|
|
}
|
|
|
|
// JobSetInfo 表示任务集信息
|
|
type JobSetInfo struct {
|
|
Jobs []Job `json:"jobs"`
|
|
}
|
|
|
|
// Job 表示单个任务
|
|
type Job struct {
|
|
LocalJobID string `json:"localJobID"`
|
|
Name string `json:"name,omitempty"`
|
|
Description string `json:"description,omitempty"`
|
|
Type string `json:"type"`
|
|
Files *JobFiles `json:"files,omitempty"`
|
|
JobResources *JobResources `json:"jobResources,omitempty"`
|
|
TargetJob []TargetJob `json:"targetJob,omitempty"`
|
|
}
|
|
|
|
// JobFiles 表示任务关联的文件
|
|
type JobFiles struct {
|
|
Dataset FileBinding `json:"dataset"`
|
|
Model FileBinding `json:"model,omitempty"`
|
|
Image ImageBinding `json:"image"`
|
|
}
|
|
|
|
// FileBinding 表示文件绑定信息
|
|
type FileBinding struct {
|
|
Type string `json:"type"`
|
|
BindingID int `json:"bindingID"`
|
|
}
|
|
|
|
// ImageBinding 表示镜像绑定信息
|
|
type ImageBinding struct {
|
|
Type string `json:"type"`
|
|
ImageID int `json:"imageID"`
|
|
}
|
|
|
|
// JobResources 表示任务资源
|
|
type JobResources struct {
|
|
ScheduleStrategy string `json:"scheduleStrategy"`
|
|
Clusters []Cluster `json:"clusters"`
|
|
}
|
|
|
|
// Cluster 表示集群信息
|
|
type Cluster struct {
|
|
ClusterID string `json:"clusterID"`
|
|
Runtime Runtime `json:"runtime"`
|
|
Code CodeInfo `json:"code"`
|
|
Resources []ResourcesItem `json:"resources"`
|
|
}
|
|
|
|
// Runtime 表示运行时配置
|
|
type Runtime struct {
|
|
Envs map[string]string `json:"envs"`
|
|
Params map[string]string `json:"params"`
|
|
}
|
|
|
|
// CodeInfo 表示代码信息
|
|
type CodeInfo struct {
|
|
Type string `json:"type"`
|
|
BindingID int `json:"bindingID"`
|
|
}
|
|
|
|
// Resource 表示资源需求
|
|
type Resource struct {
|
|
Type string `json:"type"`
|
|
Name string `json:"name"`
|
|
Number int `json:"number"`
|
|
}
|
|
|
|
// TargetJob 表示目标任务
|
|
type TargetJob struct {
|
|
TargetJobID string `json:"targetJobID"`
|
|
InputParams InputParams `json:"inputParams"`
|
|
}
|
|
|
|
// InputParams 表示输入参数
|
|
type InputParams struct {
|
|
PackageName string `json:"PackageName"`
|
|
ClusterID string `json:"ClusterID"`
|
|
Output string `json:"Output"`
|
|
}
|
|
|
|
// SubmitTaskResponse 任务提交响应
|
|
type SubmitTaskResponse struct {
|
|
Code string `json:"code"` // 状态码(字符串类型)
|
|
Message string `json:"message"` // 消息
|
|
Data Data `json:"data"` // 响应数据
|
|
}
|
|
|
|
// Data 响应数据
|
|
type Data struct {
|
|
JobSetID string `json:"jobSetID"` // 任务集ID
|
|
Message string `json:"message"` // 数据层消息
|
|
}
|
|
|
|
type TaskQueryRequest struct {
|
|
JobSetID string `json:"jobSetID"` // 用户ID
|
|
LocalJobID string `json:"localJobID"` // 页码
|
|
}
|
|
|
|
// TaskDetailResponse 任务详情查询响应
|
|
type TaskDetailResponse struct {
|
|
Code string `json:"code"` // 状态码
|
|
Message string `json:"message"` // 消息
|
|
Data TaskDetailData `json:"data"` // 任务详情数据
|
|
}
|
|
|
|
// TaskDetailData 任务详情数据
|
|
type TaskDetailData struct {
|
|
Name string `json:"name"` // 任务名称
|
|
Description string `json:"description"` // 任务描述
|
|
StartTime string `json:"startTime"` // 开始时间
|
|
EndTime string `json:"endTime"` // 结束时间
|
|
Strategy int `json:"strategy"` // 策略
|
|
SynergyStatus int `json:"synergyStatus"` // 协同状态
|
|
ClusterInfos []ClusterItem `json:"clusterInfos"` // 集群信息列表
|
|
SubTaskInfos []SubTaskInfo `json:"subTaskInfos"` // 子任务信息列表
|
|
TaskTypeDict string `json:"taskTypeDict"` // 任务类型字典
|
|
AdapterTypeDict string `json:"adapterTypeDict"` // 适配器类型字典
|
|
}
|
|
|
|
// SubTaskInfo 子任务信息
|
|
type SubTaskInfo struct {
|
|
ID string `json:"id"` // 子任务ID
|
|
Name string `json:"name"` // 子任务名称
|
|
ClusterID string `json:"clusterId"` // 集群ID
|
|
ClusterName string `json:"clusterName"` // 集群名称
|
|
Status string `json:"status"` // 任务状态
|
|
Remark string `json:"remark"` // 备注
|
|
InferURL string `json:"inferUrl"` // 推理URL
|
|
WorkDir string `json:"workDir"` // 工作目录
|
|
AppName string `json:"appName"` // 应用名称
|
|
}
|
|
|
|
// TaskLogResponse 任务日志响应
|
|
type TaskLogResponse struct {
|
|
Code string `json:"code"`
|
|
Message string `json:"message"`
|
|
Data string `json:"data"`
|
|
}
|
|
|
|
// TaskResultDetailResponse 任务详情响应
|
|
type TaskResultDetailResponse struct {
|
|
Code string `json:"code"` // 状态码
|
|
Message string `json:"message"` // 消息
|
|
Data TaskResultDetailData `json:"data"` // 任务详情数据
|
|
}
|
|
|
|
// TaskResultDetailData 任务详情数据
|
|
type TaskResultDetailData struct {
|
|
PcmJobData PcmJobData `json:"pcmJobData"` // PCM任务数据
|
|
}
|
|
|
|
// PcmJobData PCM任务数据
|
|
type PcmJobData struct {
|
|
TaskID string `json:"taskID"` // 任务ID
|
|
JobSubmitInfo JobSubmitInfo `json:"jobSubmitInfo"` // 任务提交信息
|
|
ResultFiles []ResultFile `json:"resultFiles"` // 结果文件列表
|
|
Status string `json:"status"` // 任务状态
|
|
ErrorMsg string `json:"errorMsg"` // 错误消息
|
|
}
|
|
|
|
// JobSubmitInfo 任务提交信息
|
|
type JobSubmitInfo struct {
|
|
Type string `json:"type"` // 类型
|
|
Info JobSubmitInfoDetail `json:"info"` // 任务详情
|
|
}
|
|
|
|
// JobSubmitInfoDetail 任务提交详情
|
|
type JobSubmitInfoDetail struct {
|
|
Name string `json:"name"` // 任务名称
|
|
Description string `json:"description"` // 任务描述
|
|
JobResources JobResources `json:"jobResources"` // 任务资源
|
|
DataDistributes DataDistributes `json:"dataDistributes"` // 数据分布
|
|
}
|
|
|
|
// DataDistributes 数据分布
|
|
type DataDistributes struct {
|
|
Dataset []DatasetDistribute `json:"dataset"` // 数据集分布
|
|
Code []CodeDistribute `json:"code"` // 代码分布
|
|
Image []ImageDistribute `json:"image"` // 镜像分布
|
|
Model []ModelDistribute `json:"model"` // 模型分布
|
|
}
|
|
|
|
// DatasetDistribute 数据集分布
|
|
type DatasetDistribute struct {
|
|
DataName string `json:"dataName"` // 数据名称
|
|
PackageID int `json:"packageID"` // 包ID
|
|
Clusters []ClusterStorage `json:"clusters"` // 集群存储
|
|
}
|
|
|
|
// CodeDistribute 代码分布
|
|
type CodeDistribute struct {
|
|
DataName string `json:"dataName"` // 数据名称
|
|
PackageID int `json:"packageID"` // 包ID
|
|
Output string `json:"output"` // 输出路径
|
|
Clusters []ClusterStorage `json:"clusters"` // 集群存储
|
|
}
|
|
|
|
// ImageDistribute 镜像分布
|
|
type ImageDistribute struct {
|
|
DataName string `json:"dataName"` // 数据名称
|
|
PackageID int `json:"packageID"` // 包ID
|
|
Clusters []ClusterStorage `json:"clusters"` // 集群存储
|
|
}
|
|
|
|
// ModelDistribute 模型分布
|
|
type ModelDistribute struct {
|
|
DataName string `json:"dataName"` // 数据名称
|
|
PackageID int `json:"packageID"` // 包ID
|
|
Clusters []ClusterStorage `json:"clusters"` // 集群存储
|
|
}
|
|
|
|
// ClusterStorage 集群存储信息
|
|
type ClusterStorage struct {
|
|
ClusterID string `json:"clusterID"` // 集群ID
|
|
StorageID int `json:"storageID"` // 存储ID
|
|
JsonData string `json:"jsonData"` // JSON数据
|
|
}
|
|
|
|
// ResultFile 结果文件
|
|
type ResultFile struct {
|
|
ClusterID string `json:"clusterID"` // 集群ID
|
|
Objects []ResultObject `json:"objects"` // 结果对象列表
|
|
}
|
|
|
|
// ResultObject 结果对象
|
|
type ResultObject struct {
|
|
ObjectID int `json:"objectID"` // 对象ID
|
|
PackageID int `json:"packageID"` // 包ID
|
|
Path string `json:"path"` // 路径
|
|
Size string `json:"size"` // 大小
|
|
FileHash string `json:"fileHash"` // 文件哈希
|
|
Redundancy Redundancy `json:"redundancy"` // 冗余配置
|
|
CreateTime time.Time `json:"createTime"` // 创建时间
|
|
UpdateTime time.Time `json:"updateTime"` // 更新时间
|
|
}
|
|
|
|
type InferenceTaskDetailResponse struct {
|
|
Code string `json:"code"` // 状态码
|
|
Message string `json:"message"` // 消息
|
|
Data InferenceTaskDetailData `json:"data"` // 任务详情数据
|
|
}
|
|
|
|
type InferenceTaskDetailData struct {
|
|
Type string `json:"type"`
|
|
InstanceName string `json:"instanceName"`
|
|
InstanceId string `json:"instanceId"`
|
|
ModelName string `json:"modelName"`
|
|
ModelType string `json:"modelType"`
|
|
InferCard string `json:"inferCard"`
|
|
InferUrl string `json:"inferUrl"`
|
|
ClusterName string `json:"clusterName"`
|
|
ClusterType string `json:"clusterType"`
|
|
Status string `json:"status"`
|
|
CreatedTime string `json:"createdTime"`
|
|
}
|
|
|
|
// InferenceSubmitTaskResponse 推理任务提交响应
|
|
type InferenceSubmitTaskResponse struct {
|
|
Code int `json:"code"` // 状态码
|
|
Msg string `json:"msg"` // 消息
|
|
Data InferenceSubmitTaskResponseData `json:"data"` // 响应数据
|
|
}
|
|
|
|
// InferenceSubmitTaskResponseData 推理任务提交响应数据
|
|
type InferenceSubmitTaskResponseData struct {
|
|
TaskInfo InferenceTaskInfo `json:"taskInfo"` // 任务信息
|
|
ResultInfo InferenceResultInfo `json:"resultInfo"` // 结果信息
|
|
}
|
|
|
|
// InferenceTaskInfo 推理任务信息
|
|
type InferenceTaskInfo struct {
|
|
UserID int `json:"userID"` // 用户ID
|
|
JobSetInfo InferenceJobSetInfo `json:"jobSetInfo"` // 任务集信息
|
|
}
|
|
|
|
// InferenceJobSetInfo 推理任务集信息
|
|
type InferenceJobSetInfo struct {
|
|
Jobs []InferenceJob `json:"jobs"` // 任务列表
|
|
}
|
|
|
|
// InferenceJob 推理任务
|
|
type InferenceJob struct {
|
|
LocalJobID string `json:"localJobID"` // 本地任务ID
|
|
Name string `json:"name"` // 任务名称
|
|
Description string `json:"description"` // 任务描述
|
|
Type string `json:"type"` // 任务类型
|
|
Files *InferenceJobFiles `json:"files"` // 文件信息
|
|
JobResources *InferenceJobResources `json:"jobResources"` // 资源信息
|
|
}
|
|
|
|
// InferenceJobFiles 推理任务文件
|
|
type InferenceJobFiles struct {
|
|
Model FileBinding `json:"model"` // 模型绑定
|
|
SubModel *FileBinding `json:"sub_model,omitempty"` // 增量模型绑定(可选)
|
|
Image ImageBinding `json:"image"` // 镜像绑定
|
|
}
|
|
|
|
// InferenceJobResources 推理任务资源
|
|
type InferenceJobResources struct {
|
|
ScheduleStrategy string `json:"scheduleStrategy"` // 调度策略
|
|
Clusters []InferenceCluster `json:"clusters"` // 集群列表
|
|
}
|
|
|
|
// InferenceCluster 推理集群信息
|
|
type InferenceCluster struct {
|
|
ClusterID string `json:"clusterID"` // 集群ID
|
|
Runtime Runtime `json:"runtime"` // 运行时配置
|
|
Code CodeInfo `json:"code"` // 代码信息
|
|
Resources []ResourcesItem `json:"resources"` // 资源列表
|
|
}
|
|
|
|
// InferenceResultInfo 推理结果信息
|
|
type InferenceResultInfo struct {
|
|
LocalJobID string `json:"localJobID"` // 本地任务ID
|
|
JobSetID string `json:"jobSetID"` // 任务集ID
|
|
}
|