updated createdeploytask logic
Former-commit-id: b90f79d81f32bc7f78b9978717a076e807e42d17
This commit is contained in:
parent
37afd2a284
commit
bcb664c704
|
@ -95,7 +95,7 @@ func (l *CreateDeployTaskLogic) createDeployInstance(taskId int64, adapterId str
|
|||
return err
|
||||
}
|
||||
|
||||
_, err = l.svcCtx.Scheduler.AiStorages.SaveInferDeployInstance(taskId, ins.InstanceId, ins.InstanceName, aid, adapterName, cid, clusterName, ins.ModelName, ins.ModelType, ins.InferCard)
|
||||
_, err = l.svcCtx.Scheduler.AiStorages.SaveInferDeployInstance(taskId, ins.InstanceId, ins.InstanceName, aid, adapterName, cid, clusterName, ins.ModelName, ins.ModelType, ins.InferCard, ins.ClusterType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -52,7 +52,10 @@ func (l *DeployInstanceListLogic) DeployInstanceList(req *types.DeployInstanceLi
|
|||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
deployTasks := l.GenerateDeployTasks(tasklist)
|
||||
deployTasks, err := l.GenerateDeployTasks(tasklist)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
slices := make([][]*models.AiInferDeployInstance, len(deployTasks))
|
||||
for i := 0; i < len(deployTasks); i++ {
|
||||
slices[i] = deployTasks[i].Instances
|
||||
|
@ -83,12 +86,20 @@ func (l *DeployInstanceListLogic) DeployInstanceList(req *types.DeployInstanceLi
|
|||
return
|
||||
}
|
||||
|
||||
func (l *DeployInstanceListLogic) GenerateDeployTasks(tasklist []*models.AiDeployInstanceTask) []*DeployTask {
|
||||
func (l *DeployInstanceListLogic) GenerateDeployTasks(tasklist []*models.AiDeployInstanceTask) ([]*DeployTask, error) {
|
||||
var tasks []*DeployTask
|
||||
for _, t := range tasklist {
|
||||
list, err := l.svcCtx.Scheduler.AiStorages.GetInstanceListByDeployTaskId(t.Id)
|
||||
if err != nil {
|
||||
logx.Errorf("db GetInstanceListByDeployTaskId error")
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
if len(list) == 0 {
|
||||
err := l.svcCtx.Scheduler.AiStorages.DeleteDeployTaskById(t.Id)
|
||||
if err != nil {
|
||||
logx.Errorf("db DeleteByDeployTaskId error")
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
continue
|
||||
}
|
||||
deployTask := &DeployTask{
|
||||
|
@ -99,7 +110,7 @@ func (l *DeployInstanceListLogic) GenerateDeployTasks(tasklist []*models.AiDeplo
|
|||
}
|
||||
tasks = append(tasks, deployTask)
|
||||
}
|
||||
return tasks
|
||||
return tasks, nil
|
||||
}
|
||||
|
||||
type DeployTask struct {
|
||||
|
|
|
@ -374,7 +374,7 @@ func (s *AiStorage) AddNoticeInfo(adapterId string, adapterName string, clusterI
|
|||
}
|
||||
|
||||
func (s *AiStorage) SaveInferDeployInstance(taskId int64, instanceId string, instanceName string, adapterId int64,
|
||||
adapterName string, clusterId int64, clusterName string, modelName string, modelType string, inferCard string) (int64, error) {
|
||||
adapterName string, clusterId int64, clusterName string, modelName string, modelType string, inferCard string, clusterType string) (int64, error) {
|
||||
startTime := time.Now().Format(time.RFC3339)
|
||||
// 构建主任务结构体
|
||||
insModel := models.AiInferDeployInstance{
|
||||
|
@ -388,7 +388,8 @@ func (s *AiStorage) SaveInferDeployInstance(taskId int64, instanceId string, ins
|
|||
ModelName: modelName,
|
||||
ModelType: modelType,
|
||||
InferCard: inferCard,
|
||||
Status: constants.Stopped,
|
||||
ClusterType: clusterType,
|
||||
Status: constants.Deploying,
|
||||
CreateTime: startTime,
|
||||
UpdateTime: startTime,
|
||||
}
|
||||
|
@ -464,6 +465,15 @@ func (s *AiStorage) UpdateDeployTask(task *models.AiDeployInstanceTask, needUpda
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) DeleteDeployTaskById(id int64) error {
|
||||
tx := s.DbEngin.Delete(&models.AiDeployInstanceTask{}, id)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return tx.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *AiStorage) UpdateDeployTaskById(id int64) error {
|
||||
task, err := s.GetDeployTaskById(id)
|
||||
if err != nil {
|
||||
|
|
|
@ -1158,10 +1158,14 @@ func (o *OctopusLink) GetInferDeployInstance(ctx context.Context, id string) (*i
|
|||
url := strings.Replace(resp.Payload.Notebook.Tasks[0].Url, FORWARD_SLASH, "", -1)
|
||||
inferUrl := DOMAIN + url
|
||||
|
||||
var modelType string
|
||||
var modelName string
|
||||
var card string
|
||||
if resp.Payload.Notebook.Desc != "" {
|
||||
str := strings.Split(resp.Payload.Notebook.Desc, FORWARD_SLASH)
|
||||
if len(str) == 3 {
|
||||
modelType = str[0]
|
||||
modelName = str[1]
|
||||
card = str[2]
|
||||
}
|
||||
}
|
||||
|
@ -1171,6 +1175,8 @@ func (o *OctopusLink) GetInferDeployInstance(ctx context.Context, id string) (*i
|
|||
ins.ClusterName = o.platform
|
||||
ins.Status = resp.Payload.Notebook.Status
|
||||
ins.ClusterType = TYPE_OCTOPUS
|
||||
ins.ModelType = modelType
|
||||
ins.ModelName = modelName
|
||||
ins.InferUrl = inferUrl
|
||||
ins.InferCard = card
|
||||
|
||||
|
|
Loading…
Reference in New Issue