450 lines
16 KiB
Go
450 lines
16 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"`
|
||
JobSetID string `json:"jobSetID,omitempty"` // 停止任务时需要
|
||
Files *JobFiles `json:"files,omitempty"`
|
||
JobResources *JobResources `json:"jobResources,omitempty"`
|
||
TargetJob []TargetJob `json:"targetJob,omitempty"`
|
||
OnlyCreate bool `json:"onlyCreate,omitempty"`
|
||
}
|
||
|
||
// JobFiles 表示任务关联的文件
|
||
type JobFiles struct {
|
||
Dataset FileBinding `json:"dataset"`
|
||
Model FileBinding `json:"model,omitempty"`
|
||
Image ImageBinding `json:"image"`
|
||
SubModel FileBinding `json:"sub_model,omitempty"`
|
||
}
|
||
|
||
// 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"` // 更新时间
|
||
}
|
||
|
||
// InferenceTaskStatusRequest 推理任务状态查询请求
|
||
type InferenceTaskStatusRequest struct {
|
||
LocalJobID string `json:"localJobID" binding:"required"` // 本地任务ID
|
||
JobSetID string `json:"jobSetID" binding:"required"` // 任务集ID
|
||
}
|
||
|
||
// InferenceTaskStatusResponse 推理任务状态查询响应
|
||
type InferenceTaskStatusResponse struct {
|
||
Code int `json:"code"` // 状态码
|
||
Msg string `json:"msg"` // 消息
|
||
Data InferenceTaskStatusData `json:"data"` // 任务状态数据
|
||
}
|
||
|
||
// InferenceTaskStatusData 推理任务状态数据
|
||
type InferenceTaskStatusData struct {
|
||
Status string `json:"status"` // 任务状态
|
||
URL string `json:"url"` // 推理URL
|
||
}
|
||
|
||
// InferenceAsyncSubmitResponse 异步提交推理任务响应
|
||
type InferenceAsyncSubmitResponse struct {
|
||
Code int `json:"code"`
|
||
Msg string `json:"msg"`
|
||
Data InferenceAsyncSubmitRespData `json:"data"`
|
||
}
|
||
|
||
type InferenceAsyncSubmitRespData struct {
|
||
TaskID string `json:"task_id"`
|
||
}
|
||
|
||
// InferenceAsyncTaskStatusRequest 异步任务查询请求
|
||
type InferenceAsyncTaskStatusRequest struct {
|
||
TaskID string `json:"task_id" binding:"required"`
|
||
}
|
||
|
||
// InferenceAsyncTaskStatusResponse 异步任务查询响应
|
||
type InferenceAsyncTaskStatusResponse struct {
|
||
Code int `json:"code"`
|
||
Msg string `json:"msg"`
|
||
Data InferenceAsyncTaskStatusData `json:"data"`
|
||
}
|
||
|
||
type InferenceAsyncTaskStatusData struct {
|
||
TaskID string `json:"task_id"`
|
||
Status string `json:"status"` // PENDING/RUNNING/SUBMITTING/COMPLETED/FAILED
|
||
Progress string `json:"progress,omitempty"` // 进度描述
|
||
JobSetID string `json:"job_set_id,omitempty"`
|
||
Error string `json:"error,omitempty"`
|
||
Result *InferenceSubmitTaskResponse `json:"result,omitempty"` // 任务完成后的结果
|
||
}
|
||
|
||
// StopInferenceTaskRequest 停止推理任务请求
|
||
type StopInferenceTaskRequest struct {
|
||
LocalJobID string `json:"localJobID" binding:"required"` // 本地任务ID
|
||
JobSetID string `json:"jobSetID" binding:"required"` // 任务集ID
|
||
}
|
||
|
||
// StopInferenceTaskResponse 停止推理任务响应
|
||
type StopInferenceTaskResponse struct {
|
||
Code int `json:"code"` // 状态码
|
||
Message string `json:"message"` // 消息
|
||
}
|
||
|
||
// ReSubmitTaskResponse 重启推理任务响应
|
||
type ReSubmitTaskResponse struct {
|
||
Code int `json:"code"` // 状态码
|
||
Message string `json:"message"` // 消息
|
||
Data ReSubmitTaskData `json:"data"` // 响应数据
|
||
}
|
||
|
||
// ReSubmitTaskData 重启推理任务响应数据
|
||
type ReSubmitTaskData struct {
|
||
JobSetID string `json:"jobSetID"` // 任务集ID(来自第三方接口返回)
|
||
LocalJobID string `json:"localJobID"` // 本地任务ID(来自入参 jobs)
|
||
}
|
||
|
||
// StopInferenceSubmitRequest 停止推理任务提交给第三方的请求
|
||
type StopInferenceSubmitRequest struct {
|
||
UserID int `json:"userID"` // 用户ID
|
||
JobSetInfo JobSetInfo `json:"jobSetInfo"` // 任务集信息
|
||
}
|
||
|
||
// StopInferenceSubmitResponse 停止推理任务第三方接口响应
|
||
type StopInferenceSubmitResponse struct {
|
||
Code string `json:"code"` // 状态码
|
||
Message string `json:"message"` // 消息
|
||
Data StopInferenceSubmitData `json:"data"` // 数据
|
||
}
|
||
|
||
// StopInferenceSubmitData 停止推理任务响应数据
|
||
type StopInferenceSubmitData struct {
|
||
JobSetID string `json:"jobSetID"` // 任务集ID
|
||
FilesUploadScheme FilesUploadScheme `json:"filesUploadScheme"` // 文件上传方案
|
||
Message string `json:"message"` // 消息
|
||
}
|
||
|
||
// FilesUploadScheme 文件上传方案
|
||
type FilesUploadScheme struct {
|
||
LocalFileUploadSchemes []interface{} `json:"localFileUploadSchemes"` // 本地文件上传方案
|
||
}
|
||
|
||
// InferenceTaskDetailResponse 推理任务详情响应(第三方接口返回的原始格式)
|
||
type InferenceTaskDetailResponse struct {
|
||
Code string `json:"code"` // 状态码
|
||
Message string `json:"message"` // 消息
|
||
Data InferenceTaskDetailData `json:"data"` // 任务详情数据
|
||
}
|
||
|
||
// InferenceTaskDetailData 推理任务详情数据(第三方接口返回的原始格式)
|
||
type InferenceTaskDetailData struct {
|
||
Type string `json:"type"` // 类型
|
||
Instance InferenceInstance `json:"instance"` // 实例信息
|
||
}
|
||
|
||
// InferenceInstance 推理实例信息
|
||
type InferenceInstance struct {
|
||
InstanceName string `json:"InstanceName"` // 实例名称
|
||
InstanceId string `json:"InstanceId"` // 实例ID
|
||
ModelName string `json:"ModelName"` // 模型名称
|
||
ModelType string `json:"ModelType"` // 模型类型
|
||
InferCard string `json:"InferCard"` // 推理卡类型
|
||
InferUrl string `json:"InferUrl"` // 推理URL
|
||
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 SubtaskRequest `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
|
||
}
|