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 := &types.ScheduleResult{}
scheResult.ClusterId = r.ClusterId scheResult.ClusterId = r.ClusterId
scheResult.TaskId = strconv.FormatInt(id, 10) scheResult.TaskId = strconv.FormatInt(id, 10)
scheResult.JobId = r.JobId
scheResult.Strategy = r.Strategy scheResult.Strategy = r.Strategy
scheResult.Card = strings.ToUpper(r.Card) scheResult.Card = strings.ToUpper(r.Card)
scheResult.Replica = r.Replica 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) 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 { if err != nil {
return nil, err 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) { func (s *AiStorage) GetAiTasksByAdapterId(adapterId string) ([]*models.TaskAi, error) {
var resp []*models.TaskAi var resp []*models.TaskAi
tx := s.DbEngin.Raw("select * from task_ai where `adapter_id` = ? ", adapterId).Order("commit_time desc").Scan(&resp) db := s.DbEngin.Model(&models.TaskAi{}).Table("task_ai")
if tx.Error != nil { db = db.Where("adapter_id = ?", adapterId)
logx.Errorf(tx.Error.Error()) err := db.Order("commit_time desc").Find(&resp).Error
return nil, tx.Error if err != nil {
return nil, err
} }
return resp, nil return resp, nil
} }

View File

@ -43,7 +43,7 @@ type AiScheduler struct {
} }
type AiResult struct { type AiResult struct {
TaskId string JobId string
ClusterId string ClusterId string
Strategy string Strategy string
Replica int32 Replica int32
@ -215,9 +215,9 @@ func (as *AiScheduler) AssignTask(clusters []*strategy.AssignedCluster) (interfa
return nil, errors.New("database add failed: " + err.Error()) return nil, errors.New("database add failed: " + err.Error())
} }
} else { } 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 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 { if err != nil {
return nil, errors.New("database add failed: " + err.Error()) return nil, errors.New("database add failed: " + err.Error())
} }
@ -298,7 +298,7 @@ func convertType(in interface{}) (*AiResult, error) {
case *hpcAC.SubmitTaskAiResp: case *hpcAC.SubmitTaskAiResp:
resp := (in).(*hpcAC.SubmitTaskAiResp) resp := (in).(*hpcAC.SubmitTaskAiResp)
if resp.Code == "0" { if resp.Code == "0" {
result.TaskId = resp.Data result.JobId = resp.Data
} else { } else {
result.Msg = resp.Msg result.Msg = resp.Msg
} }
@ -307,7 +307,7 @@ func convertType(in interface{}) (*AiResult, error) {
resp := (in).(*octopus.CreateTrainJobResp) resp := (in).(*octopus.CreateTrainJobResp)
if resp.Success { if resp.Success {
result.TaskId = resp.Payload.JobId result.JobId = resp.Payload.JobId
} else { } else {
result.Msg = resp.Error.Message result.Msg = resp.Error.Message
} }