DEBUG
This commit is contained in:
@@ -69,48 +69,52 @@ func (model *Model) Inference(image_list []Image, callback func(Image)) {
|
||||
// 寻找一台就绪的推理机, 且已部署模型目标模型
|
||||
if err := configs.ORMDB().Where("type = ?", "推理").Where("status = ?", "就绪").Where("models LIKE ?", "%"+strconv.Itoa(model.ID)+"%").First(&server).Error; err != nil {
|
||||
// 寻找一台就绪的推理机, 且模型位置仍有空余
|
||||
if err := configs.ORMDB().Where("type = ?", "推理").Where("status = ?", "空闲").Where("length(models) < ?", 5).First(&server).Error; err != nil {
|
||||
if err := configs.ORMDB().Where("type = ?", "推理").Where("status = ?", "就绪").Where("length(models) < ?", 5).First(&server).Error; err != nil {
|
||||
log.Println("创建一台新的推理机: 当前禁止创建新服务器")
|
||||
return
|
||||
}
|
||||
// 上传目标模型到推理机
|
||||
log.Println("上传模型到推理机: 当前禁止上传模型")
|
||||
return
|
||||
}
|
||||
|
||||
var form = struct {
|
||||
Components []struct {
|
||||
ID int `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Props struct {
|
||||
Value string `json:"value"`
|
||||
}
|
||||
} `json:"components"`
|
||||
}{}
|
||||
// 检查当前是否为目标模型, 不是则执行切换模型 http://106.15.192.42:7860/config
|
||||
if err := goreq.Get(fmt.Sprintf("http://%s:%d/config", server.IP, server.Port)).Do().BindJSON(&form); err != nil {
|
||||
log.Println("获取推理机配置失败:", err)
|
||||
return
|
||||
}
|
||||
//var form = struct {
|
||||
// Components []struct {
|
||||
// ID int `json:"id"`
|
||||
// Type string `json:"type"`
|
||||
// Props struct {
|
||||
// Value string `json:"value"`
|
||||
// }
|
||||
// } `json:"components"`
|
||||
//}{}
|
||||
//// 检查当前是否为目标模型, 不是则执行切换模型 http://106.15.192.42:7860/config
|
||||
//if err := goreq.Get(fmt.Sprintf("http://%s:%d/config", server.IP, server.Port)).Do().BindJSON(&form); err != nil {
|
||||
// log.Println("获取推理机配置失败:", err)
|
||||
// return
|
||||
//}
|
||||
//var isSet = false
|
||||
//for _, component := range form.Components {
|
||||
// if component.Type == "dropdown" && component.ID == 1514 && component.Props.Value == model.Name {
|
||||
// log.Println("当前推理机已经部署了目标模型")
|
||||
// isSet = true
|
||||
// break
|
||||
// }
|
||||
//}
|
||||
//if !isSet {
|
||||
// log.Println("当前推理机未部署目标模型, 开始部署目标模型")
|
||||
// // 没有切换模型接口
|
||||
// return
|
||||
//}
|
||||
|
||||
var isSet = false
|
||||
for _, component := range form.Components {
|
||||
if component.Type == "dropdown" && component.ID == 1514 && component.Props.Value == model.Name {
|
||||
log.Println("当前推理机已经部署了目标模型")
|
||||
isSet = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !isSet {
|
||||
log.Println("当前推理机未部署目标模型, 开始部署目标模型")
|
||||
// 没有切换模型接口
|
||||
return
|
||||
}
|
||||
// 记录到推理机
|
||||
server.Models = append(server.Models, strconv.Itoa(model.ID))
|
||||
configs.ORMDB().Save(&server)
|
||||
|
||||
// 记录到模型
|
||||
model.ServerID = server.ID
|
||||
configs.ORMDB().Save(&model)
|
||||
} else {
|
||||
server.ID = model.ServerID
|
||||
configs.ORMDB().Take(&server)
|
||||
}
|
||||
|
||||
// 发送的参数
|
||||
|
@@ -181,7 +181,7 @@ func (server *Server) CheckStatus() error {
|
||||
}
|
||||
server.Status = "正常"
|
||||
case "推理":
|
||||
server.Status = "異常"
|
||||
server.Status = "就绪"
|
||||
default:
|
||||
server.Status = "異常"
|
||||
}
|
||||
|
Reference in New Issue
Block a user