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:
commit
075f3cab09
|
@ -1733,6 +1733,8 @@ PayloadCreateTrainJob{
|
||||||
AiTask {
|
AiTask {
|
||||||
Name string `json:"name,optional"`
|
Name string `json:"name,optional"`
|
||||||
status string `json:"status,optional"`
|
status string `json:"status,optional"`
|
||||||
|
Cluster string `json:"cluster,optional"`
|
||||||
|
Card string `json:"card,optional"`
|
||||||
TimeElapsed int32 `json:"elapsed,optional"`
|
TimeElapsed int32 `json:"elapsed,optional"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -98,7 +98,9 @@ func (l *PageListTaskLogic) updateAitaskStatus(tasks []*types.TaskModel, ch chan
|
||||||
|
|
||||||
start, _ := time.ParseInLocation(constants.Layout, aiTask[0].StartTime, time.Local)
|
start, _ := time.ParseInLocation(constants.Layout, aiTask[0].StartTime, time.Local)
|
||||||
end, _ := time.ParseInLocation(constants.Layout, aiTask[0].EndTime, 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 {
|
for _, a := range aiTask {
|
||||||
s, _ := time.ParseInLocation(constants.Layout, a.StartTime, time.Local)
|
s, _ := time.ParseInLocation(constants.Layout, a.StartTime, time.Local)
|
||||||
e, _ := time.ParseInLocation(constants.Layout, a.EndTime, 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
|
status = a.Status
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if a.Status == constants.Completed {
|
||||||
|
count++
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task.Status = status
|
if count == len(aiTask) {
|
||||||
task.StartTime = start.Format(constants.Layout)
|
status = constants.Succeeded
|
||||||
task.EndTime = end.Format(constants.Layout)
|
}
|
||||||
|
|
||||||
|
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)
|
tx = l.svcCtx.DbEngin.Table("task").Updates(task)
|
||||||
if tx.Error != nil {
|
if tx.Error != nil {
|
||||||
|
|
|
@ -208,7 +208,7 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interfa
|
||||||
} else {
|
} else {
|
||||||
msg := fmt.Sprintf("clusterId: %v , submitted successfully, taskId: %v \n", s.ClusterId, s.TaskId)
|
msg := fmt.Sprintf("clusterId: %v , submitted successfully, taskId: %v \n", s.ClusterId, s.TaskId)
|
||||||
errmsg += msg
|
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 {
|
if err != nil {
|
||||||
return nil, errors.New("database add failed: " + err.Error())
|
return nil, errors.New("database add failed: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -2841,6 +2841,8 @@ type CenterTaskListResp struct {
|
||||||
type AiTask struct {
|
type AiTask struct {
|
||||||
Name string `json:"name,optional"`
|
Name string `json:"name,optional"`
|
||||||
Status string `json:"status,optional"`
|
Status string `json:"status,optional"`
|
||||||
|
Cluster string `json:"cluster,optional"`
|
||||||
|
Card string `json:"card,optional"`
|
||||||
TimeElapsed int32 `json:"elapsed,optional"`
|
TimeElapsed int32 `json:"elapsed,optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue