diff --git a/api/desc/ai/pcm-ai.api b/api/desc/ai/pcm-ai.api index b0cf10fe..5e651a24 100644 --- a/api/desc/ai/pcm-ai.api +++ b/api/desc/ai/pcm-ai.api @@ -1733,6 +1733,8 @@ PayloadCreateTrainJob{ AiTask { Name string `json:"name,optional"` status string `json:"status,optional"` + Cluster string `json:"cluster,optional"` + Card string `json:"card,optional"` TimeElapsed int32 `json:"elapsed,optional"` } ) diff --git a/api/internal/logic/core/pagelisttasklogic.go b/api/internal/logic/core/pagelisttasklogic.go index 0792be9a..ff78fad4 100644 --- a/api/internal/logic/core/pagelisttasklogic.go +++ b/api/internal/logic/core/pagelisttasklogic.go @@ -98,7 +98,9 @@ func (l *PageListTaskLogic) updateAitaskStatus(tasks []*types.TaskModel, ch chan start, _ := time.ParseInLocation(constants.Layout, aiTask[0].StartTime, time.Local) end, _ := time.ParseInLocation(constants.Layout, aiTask[0].EndTime, time.Local) - var status = constants.Succeeded + + var status string + var count int for _, a := range aiTask { s, _ := time.ParseInLocation(constants.Layout, a.StartTime, time.Local) e, _ := time.ParseInLocation(constants.Layout, a.EndTime, time.Local) @@ -120,11 +122,22 @@ func (l *PageListTaskLogic) updateAitaskStatus(tasks []*types.TaskModel, ch chan status = a.Status continue } + + if a.Status == constants.Completed { + count++ + continue + } } - task.Status = status - task.StartTime = start.Format(constants.Layout) - task.EndTime = end.Format(constants.Layout) + if count == len(aiTask) { + status = constants.Succeeded + } + + if status != "" { + task.Status = status + task.StartTime = start.Format(constants.Layout) + task.EndTime = end.Format(constants.Layout) + } tx = l.svcCtx.DbEngin.Table("task").Updates(task) if tx.Error != nil { diff --git a/api/internal/scheduler/schedulers/aiScheduler.go b/api/internal/scheduler/schedulers/aiScheduler.go index 19f67b83..75f435d0 100644 --- a/api/internal/scheduler/schedulers/aiScheduler.go +++ b/api/internal/scheduler/schedulers/aiScheduler.go @@ -208,7 +208,7 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interfa } else { msg := fmt.Sprintf("clusterId: %v , submitted successfully, taskId: %v \n", s.ClusterId, s.TaskId) errmsg += msg - err := as.AiStorages.SaveAiTask(taskId, as.option, s.ClusterId, s.TaskId, constants.Succeeded, msg) + err := as.AiStorages.SaveAiTask(taskId, as.option, s.ClusterId, s.TaskId, constants.Saved, msg) if err != nil { return nil, errors.New("database add failed: " + err.Error()) } diff --git a/api/internal/types/types.go b/api/internal/types/types.go index c66655db..cb6cc671 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -2841,6 +2841,8 @@ type CenterTaskListResp struct { type AiTask struct { Name string `json:"name,optional"` Status string `json:"status,optional"` + Cluster string `json:"cluster,optional"` + Card string `json:"card,optional"` TimeElapsed int32 `json:"elapsed,optional"` }