| @@ -43,10 +43,10 @@ func UpdateTaskStatus(svc *svc.ServiceContext, tasklist []*types.TaskModel) { | |||
| } | |||
| // Update Infer Task Status | |||
| if task.TaskTypeDict == "11" || task.TaskTypeDict == "12" { | |||
| updateInferTaskStatus(svc, *task) | |||
| return | |||
| } | |||
| //if task.TaskTypeDict == "11" || task.TaskTypeDict == "12" { | |||
| // updateInferTaskStatus(svc, *task) | |||
| // return | |||
| //} | |||
| aiTask, err := svc.Scheduler.AiStorages.GetAiTaskListById(task.Id) | |||
| if err != nil { | |||
| @@ -111,58 +111,58 @@ func UpdateTaskStatus(svc *svc.ServiceContext, tasklist []*types.TaskModel) { | |||
| return | |||
| } | |||
| start, _ := time.ParseInLocation(constants.Layout, aiTask[0].StartTime, time.Local) | |||
| end, _ := time.ParseInLocation(constants.Layout, aiTask[0].EndTime, time.Local) | |||
| 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) | |||
| if s.Before(start) { | |||
| start = s | |||
| } | |||
| if e.After(end) { | |||
| end = e | |||
| } | |||
| if a.Status == constants.Failed { | |||
| status = a.Status | |||
| break | |||
| } | |||
| if a.Status == constants.Pending { | |||
| status = a.Status | |||
| continue | |||
| } | |||
| if a.Status == constants.Running { | |||
| status = a.Status | |||
| continue | |||
| } | |||
| if a.Status == constants.Completed { | |||
| count++ | |||
| continue | |||
| } | |||
| } | |||
| //start, _ := time.ParseInLocation(constants.Layout, aiTask[0].StartTime, time.Local) | |||
| //end, _ := time.ParseInLocation(constants.Layout, aiTask[0].EndTime, time.Local) | |||
| // | |||
| //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) | |||
| // | |||
| // if s.Before(start) { | |||
| // start = s | |||
| // } | |||
| // | |||
| // if e.After(end) { | |||
| // end = e | |||
| // } | |||
| // | |||
| // if a.Status == constants.Failed { | |||
| // status = a.Status | |||
| // break | |||
| // } | |||
| // | |||
| // if a.Status == constants.Pending { | |||
| // status = a.Status | |||
| // continue | |||
| // } | |||
| // | |||
| // if a.Status == constants.Running { | |||
| // status = a.Status | |||
| // continue | |||
| // } | |||
| // | |||
| // if a.Status == constants.Completed { | |||
| // count++ | |||
| // continue | |||
| // } | |||
| //} | |||
| //if count == len(aiTask) { | |||
| // status = constants.Succeeded | |||
| //} | |||
| if status != "" { | |||
| task.Status = status | |||
| task.StartTime = start.Format(constants.Layout) | |||
| task.EndTime = end.Format(constants.Layout) | |||
| } | |||
| err = svc.Scheduler.AiStorages.UpdateTask(task) | |||
| if err != nil { | |||
| return | |||
| } | |||
| //if status != "" { | |||
| // task.Status = status | |||
| // task.StartTime = start.Format(constants.Layout) | |||
| // task.EndTime = end.Format(constants.Layout) | |||
| //} | |||
| // | |||
| //err = svc.Scheduler.AiStorages.UpdateTask(task) | |||
| //if err != nil { | |||
| // return | |||
| //} | |||
| } | |||
| func reportStatusMessages(svc *svc.ServiceContext, task *types.TaskModel, aiTask *models.TaskAi) error { | |||
| @@ -203,7 +203,7 @@ func updateInferTaskStatus(svc *svc.ServiceContext, task types.TaskModel) { | |||
| } | |||
| if len(aiTask) == 0 { | |||
| //task.Status = constants.Failed | |||
| task.Status = constants.Failed | |||
| err = svc.Scheduler.AiStorages.UpdateTask(&task) | |||
| if err != nil { | |||
| return | |||
| @@ -295,8 +295,6 @@ func updateInferTaskStatus(svc *svc.ServiceContext, task types.TaskModel) { | |||
| } | |||
| func UpdateAiTask(svc *svc.ServiceContext, aiTaskList ...*models.TaskAi) { | |||
| svc.Scheduler.AiService.TaskSyncLock.Lock() | |||
| defer svc.Scheduler.AiService.TaskSyncLock.Unlock() | |||
| var wg sync.WaitGroup | |||
| for _, aitask := range aiTaskList { | |||
| t := aitask | |||
| @@ -362,6 +360,8 @@ func UpdateAiTask(svc *svc.ServiceContext, aiTaskList ...*models.TaskAi) { | |||
| } | |||
| func UpdateAiTaskStatus(svc *svc.ServiceContext, tasklist []*types.TaskModel) { | |||
| svc.Scheduler.AiService.TaskSyncLock.Lock() | |||
| defer svc.Scheduler.AiService.TaskSyncLock.Unlock() | |||
| list := make([]*types.TaskModel, len(tasklist)) | |||
| copy(list, tasklist) | |||
| for i := len(list) - 1; i >= 0; i-- { | |||