|
|
|
@@ -7,6 +7,7 @@ import ( |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants" |
|
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models" |
|
|
|
"google.golang.org/grpc/codes" |
|
|
|
"google.golang.org/grpc/status" |
|
|
|
"net/http" |
|
|
|
@@ -19,7 +20,7 @@ func UpdateTaskStatus(svc *svc.ServiceContext, tasklist []*types.TaskModel) { |
|
|
|
list := make([]*types.TaskModel, len(tasklist)) |
|
|
|
copy(list, tasklist) |
|
|
|
for i := len(list) - 1; i >= 0; i-- { |
|
|
|
if list[i].AdapterTypeDict != "1" || list[i].Status == constants.Succeeded || list[i].Status == constants.Failed { |
|
|
|
if list[i].AdapterTypeDict != "1" || list[i].Status == constants.Succeeded || list[i].Status == constants.Failed || list[i].Status == constants.Cancelled { |
|
|
|
list = append(list[:i], list[i+1:]...) |
|
|
|
} |
|
|
|
} |
|
|
|
@@ -240,38 +241,7 @@ func updateInferTaskStatus(svc *svc.ServiceContext, task types.TaskModel) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func UpdateAiTaskStatus(svc *svc.ServiceContext, tasklist []*types.TaskModel) { |
|
|
|
list := make([]*types.TaskModel, len(tasklist)) |
|
|
|
copy(list, tasklist) |
|
|
|
for i := len(list) - 1; i >= 0; i-- { |
|
|
|
if list[i].AdapterTypeDict != "1" || list[i].Status == constants.Succeeded || list[i].Status == constants.Failed { |
|
|
|
list = append(list[:i], list[i+1:]...) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if len(list) == 0 { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
task := list[0] |
|
|
|
for i := range list { |
|
|
|
earliest, _ := time.Parse(constants.Layout, task.UpdatedTime) |
|
|
|
latest, _ := time.Parse(constants.Layout, list[i].UpdatedTime) |
|
|
|
if latest.Before(earliest) { |
|
|
|
task = list[i] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
aiTaskList, err := svc.Scheduler.AiStorages.GetAiTaskListById(task.Id) |
|
|
|
if err != nil { |
|
|
|
logx.Errorf(err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if len(aiTaskList) == 0 { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func UpdateAiTask(svc *svc.ServiceContext, aiTaskList ...*models.TaskAi) { |
|
|
|
var wg sync.WaitGroup |
|
|
|
for _, aitask := range aiTaskList { |
|
|
|
t := aitask |
|
|
|
@@ -336,6 +306,41 @@ func UpdateAiTaskStatus(svc *svc.ServiceContext, tasklist []*types.TaskModel) { |
|
|
|
wg.Wait() |
|
|
|
} |
|
|
|
|
|
|
|
func UpdateAiTaskStatus(svc *svc.ServiceContext, tasklist []*types.TaskModel) { |
|
|
|
list := make([]*types.TaskModel, len(tasklist)) |
|
|
|
copy(list, tasklist) |
|
|
|
for i := len(list) - 1; i >= 0; i-- { |
|
|
|
if list[i].AdapterTypeDict != "1" || list[i].Status == constants.Succeeded || list[i].Status == constants.Failed { |
|
|
|
list = append(list[:i], list[i+1:]...) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if len(list) == 0 { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
task := list[0] |
|
|
|
for i := range list { |
|
|
|
earliest, _ := time.Parse(constants.Layout, task.UpdatedTime) |
|
|
|
latest, _ := time.Parse(constants.Layout, list[i].UpdatedTime) |
|
|
|
if latest.Before(earliest) { |
|
|
|
task = list[i] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
aiTaskList, err := svc.Scheduler.AiStorages.GetAiTaskListById(task.Id) |
|
|
|
if err != nil { |
|
|
|
logx.Errorf(err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if len(aiTaskList) == 0 { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
UpdateAiTask(svc, aiTaskList...) |
|
|
|
} |
|
|
|
|
|
|
|
func UpdateTrainingTaskStatus(svc *svc.ServiceContext, list []*types.AdapterInfo) { |
|
|
|
var wg sync.WaitGroup |
|
|
|
for _, adapter := range list { |
|
|
|
|