Merge pull request 'fix ai task time bugs' (#169) from tzwang/pcm-coordinator:master into master

Former-commit-id: 8908c540c224842bd33d2f4c812a5be9e24552a9
This commit is contained in:
tzwang 2024-05-13 15:29:52 +08:00
commit 075f3cab09
4 changed files with 22 additions and 5 deletions

View File

@ -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"`
}
)

View File

@ -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 {

View File

@ -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())
}

View File

@ -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"`
}