updated scheduleResult

Former-commit-id: 5158fe0420e1921b63fce8b21c6477341801d243
This commit is contained in:
tzwang 2024-05-15 18:29:20 +08:00
parent 95b2258e2c
commit a336b737f0
3 changed files with 12 additions and 10 deletions

View File

@ -73,6 +73,7 @@ func (l *ScheduleSubmitLogic) ScheduleSubmit(req *types.ScheduleReq) (resp *type
scheResult := &types.ScheduleResult{}
scheResult.ClusterId = r.ClusterId
scheResult.TaskId = strconv.FormatInt(id, 10)
scheResult.JobId = r.JobId
scheResult.Strategy = r.Strategy
scheResult.Card = strings.ToUpper(r.Card)
scheResult.Replica = r.Replica
@ -82,7 +83,7 @@ func (l *ScheduleSubmitLogic) ScheduleSubmit(req *types.ScheduleReq) (resp *type
clusterName, _ := l.svcCtx.Scheduler.AiStorages.GetClusterNameById(r.ClusterId)
err := l.svcCtx.Scheduler.AiStorages.SaveAiTask(id, opt, r.ClusterId, clusterName, r.TaskId, constants.Saved, r.Msg)
err := l.svcCtx.Scheduler.AiStorages.SaveAiTask(id, opt, r.ClusterId, clusterName, r.JobId, constants.Saved, r.Msg)
if err != nil {
return nil, err
}

View File

@ -73,10 +73,11 @@ func (s *AiStorage) GetAdaptersByType(adapterType string) ([]*types.AdapterInfo,
func (s *AiStorage) GetAiTasksByAdapterId(adapterId string) ([]*models.TaskAi, error) {
var resp []*models.TaskAi
tx := s.DbEngin.Raw("select * from task_ai where `adapter_id` = ? ", adapterId).Order("commit_time desc").Scan(&resp)
if tx.Error != nil {
logx.Errorf(tx.Error.Error())
return nil, tx.Error
db := s.DbEngin.Model(&models.TaskAi{}).Table("task_ai")
db = db.Where("adapter_id = ?", adapterId)
err := db.Order("commit_time desc").Find(&resp).Error
if err != nil {
return nil, err
}
return resp, nil
}

View File

@ -43,7 +43,7 @@ type AiScheduler struct {
}
type AiResult struct {
TaskId string
JobId string
ClusterId string
Strategy string
Replica int32
@ -215,9 +215,9 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interfa
return nil, errors.New("database add failed: " + err.Error())
}
} else {
msg := fmt.Sprintf("clusterId: %v , submitted successfully, taskId: %v \n", s.ClusterId, s.TaskId)
msg := fmt.Sprintf("clusterId: %v , submitted successfully, jobId: %v \n", s.ClusterId, s.JobId)
errmsg += msg
err := as.AiStorages.SaveAiTask(taskId, as.option, s.ClusterId, clusterName, s.TaskId, constants.Saved, msg)
err := as.AiStorages.SaveAiTask(taskId, as.option, s.ClusterId, clusterName, s.JobId, constants.Saved, msg)
if err != nil {
return nil, errors.New("database add failed: " + err.Error())
}
@ -298,7 +298,7 @@ func convertType(in interface{}) (*AiResult, error) {
case *hpcAC.SubmitTaskAiResp:
resp := (in).(*hpcAC.SubmitTaskAiResp)
if resp.Code == "0" {
result.TaskId = resp.Data
result.JobId = resp.Data
} else {
result.Msg = resp.Msg
}
@ -307,7 +307,7 @@ func convertType(in interface{}) (*AiResult, error) {
resp := (in).(*octopus.CreateTrainJobResp)
if resp.Success {
result.TaskId = resp.Payload.JobId
result.JobId = resp.Payload.JobId
} else {
result.Msg = resp.Error.Message
}