diff --git a/models/ai_model_manage.go b/models/ai_model_manage.go index 53732350b..a150a22fd 100644 --- a/models/ai_model_manage.go +++ b/models/ai_model_manage.go @@ -39,18 +39,19 @@ type AiModelManage struct { IsCanDelete bool } -type AiModelManageConvert struct { - ID string `xorm:"pk"` - Name string `xorm:"INDEX NOT NULL"` - Status int `xorm:"NOT NULL DEFAULT 0"` - SrcEngine int `xorm:"NOT NULL DEFAULT 0"` - RepoId int64 `xorm:"INDEX NULL"` - ModelId string `xorm:"NOT NULL"` - ModelVersion string `xorm:"NOT NULL"` - DestFormat int `xorm:"NOT NULL DEFAULT 0"` - NetOutputFormat int `xorm:"NULL"` - UserId int64 `xorm:"NOT NULL"` - RunTime int64 `xorm:"NULL"` +type AiModelConvert struct { + ID string `xorm:"pk"` + Name string `xorm:"INDEX NOT NULL"` + Status string `xorm:"NULL"` + SrcEngine int `xorm:"NOT NULL DEFAULT 0"` + RepoId int64 `xorm:"INDEX NULL"` + ModelId string `xorm:"NOT NULL"` + ModelVersion string `xorm:"NOT NULL"` + DestFormat int `xorm:"NOT NULL DEFAULT 0"` + NetOutputFormat int `xorm:"NULL"` + UserId int64 `xorm:"NOT NULL"` + RunTime int64 `xorm:"NULL"` + TrainJobDuration string InputShape string `xorm:"varchar(2000)"` InputDataFormat string `xorm:"NOT NULL"` Description string `xorm:"varchar(2000)"` @@ -75,7 +76,7 @@ type AiModelQueryOptions struct { Status int } -func SaveModelConvert(modelConvert *AiModelManageConvert) error { +func SaveModelConvert(modelConvert *AiModelConvert) error { sess := x.NewSession() defer sess.Close() re, err := sess.Insert(modelConvert) @@ -100,11 +101,11 @@ func SaveModelToDb(model *AiModelManage) error { return nil } -func QueryModelConvertById(id string) (*AiModelManageConvert, error) { +func QueryModelConvertById(id string) (*AiModelConvert, error) { sess := x.NewSession() defer sess.Close() - sess.Select("*").Table(new(AiModelManageConvert)).Where("id='" + id + "'") - aiModelManageConvertList := make([]*AiModelManageConvert, 0) + sess.Select("*").Table(new(AiModelConvert)).Where("id='" + id + "'") + aiModelManageConvertList := make([]*AiModelConvert, 0) err := sess.Find(&aiModelManageConvertList) if err == nil { if len(aiModelManageConvertList) == 1 { @@ -132,7 +133,7 @@ func QueryModelById(id string) (*AiModelManage, error) { func DeleteModelConvertById(id string) error { sess := x.NewSession() defer sess.Close() - re, err := sess.Delete(&AiModelManageConvert{ + re, err := sess.Delete(&AiModelConvert{ ID: id, }) if err != nil { @@ -264,7 +265,7 @@ func QueryModel(opts *AiModelQueryOptions) ([]*AiModelManage, int64, error) { return aiModelManages, count, nil } -func QueryModelConvert(opts *AiModelQueryOptions) ([]*AiModelManageConvert, int64, error) { +func QueryModelConvert(opts *AiModelQueryOptions) ([]*AiModelConvert, int64, error) { sess := x.NewSession() defer sess.Close() var cond = builder.NewCond() @@ -278,12 +279,7 @@ func QueryModelConvert(opts *AiModelQueryOptions) ([]*AiModelManageConvert, int6 builder.Eq{"ai_model_manage_convert.user_id": opts.UserID}, ) } - if (opts.Status) >= 0 { - cond = cond.And( - builder.Eq{"ai_model_manage_convert.status": opts.Status}, - ) - } - count, err := sess.Where(cond).Count(new(AiModelManageConvert)) + count, err := sess.Where(cond).Count(new(AiModelConvert)) if err != nil { return nil, 0, fmt.Errorf("Count: %v", err) } @@ -298,8 +294,8 @@ func QueryModelConvert(opts *AiModelQueryOptions) ([]*AiModelManageConvert, int6 sess.Limit(opts.PageSize, start) } sess.OrderBy("ai_model_manage_convert.created_unix DESC") - aiModelManageConvert := make([]*AiModelManageConvert, 0, setting.UI.IssuePagingNum) - if err := sess.Table(new(AiModelManageConvert)).Where(cond). + aiModelManageConvert := make([]*AiModelConvert, 0, setting.UI.IssuePagingNum) + if err := sess.Table(new(AiModelConvert)).Where(cond). Find(&aiModelManageConvert); err != nil { return nil, 0, fmt.Errorf("Find: %v", err) } diff --git a/models/models.go b/models/models.go index 962cb3ce9..7a328b1cb 100755 --- a/models/models.go +++ b/models/models.go @@ -144,7 +144,7 @@ func init() { new(WechatBindLog), new(OrgStatistic), new(SearchRecord), - new(AiModelManageConvert), + new(AiModelConvert), ) tablesStatistic = append(tablesStatistic, diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index 840952a24..eb71c3809 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -164,7 +164,7 @@ func SaveModelConvert(ctx *context.Context) { uuid := uuid.NewV4() id := uuid.String() - modelConvert := &models.AiModelManageConvert{ + modelConvert := &models.AiModelConvert{ ID: id, Name: name, Description: desc, @@ -262,7 +262,7 @@ func downloadModelFromCloudBrainOne(modelUUID string, jobName string, parentDir func DeleteModelConvert(ctx *context.Context) { log.Info("delete model convert start.") - id := ctx.Query("ID") + id := ctx.Params(":id") err := models.DeleteModelConvertById(id) if err != nil { ctx.JSON(500, err.Error()) @@ -273,6 +273,11 @@ func DeleteModelConvert(ctx *context.Context) { } } +func StopModelConvert(ctx *context.Context) { + id := ctx.Params(":id") + log.Info("stop model convert start.id=" + id) +} + func DeleteModel(ctx *context.Context) { log.Info("delete model start.") id := ctx.Query("ID") @@ -679,7 +684,7 @@ func ConvertModelTemplate(ctx *context.Context) { ctx.Data["MODEL_COUNT"] = 0 ctx.Data["ModelManageAccess"] = ctx.Repo.CanWrite(models.UnitTypeModelManage) ctx.Data["TRAIN_COUNT"] = 0 - + ShowModelConvertPageInfo(ctx) ctx.HTML(200, tplModelManageConvertIndex) } @@ -757,6 +762,8 @@ func ShowModelConvertPageInfo(ctx *context.Context) { model.UserRelAvatarLink = value.RelAvatarLink() } } + pager := context.NewPagination(int(count), page, pageSize, 5) + ctx.Data["Page"] = pager ctx.Data["Tasks"] = modelResult } diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 035ee264d..1b0567769 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -1080,7 +1080,8 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/create_model_convert", reqRepoModelManageWriter, repo.SaveModelConvert) m.Post("/create_new_model", repo.SaveNewNameModel) m.Delete("/delete_model", repo.DeleteModel) - m.Delete("/delete_model_convert", repo.DeleteModelConvert) + m.Post("/delete_model_convert/:id", repo.DeleteModelConvert) + m.Post("/convert_stop/:id", repo.StopModelConvert) m.Put("/modify_model", repo.ModifyModelInfo) m.Get("/show_model", reqRepoModelManageReader, repo.ShowModelTemplate) m.Get("/convert_model", reqRepoModelManageReader, repo.ConvertModelTemplate) diff --git a/templates/repo/modelmanage/convertIndex.tmpl b/templates/repo/modelmanage/convertIndex.tmpl index 6d8149d3f..9fd5eae2a 100644 --- a/templates/repo/modelmanage/convertIndex.tmpl +++ b/templates/repo/modelmanage/convertIndex.tmpl @@ -75,7 +75,58 @@ {{.Name}} - +
+ + {{.Status}} + +
+
+ {{.SrcEngine}} +
+
+ {{.DestFormat}} +
+
+ {{TimeSinceUnix .CreatedUnix $.Lang}} +
+
+ {{.TrainJobDuration}} +
+
+ +
+
+
+ +
+ {{$.CsrfTokenHtml}} + {{if .IsCanOper}} + + {{$.i18n.Tr "repo.stop"}} + + {{else}} + + {{$.i18n.Tr "repo.stop"}} + + {{end}} +
+ + +
+ + {{$.CsrfTokenHtml}} + {{if .IsCanDelete}} + + {{$.i18n.Tr "repo.delete"}} + + {{else}} + + {{$.i18n.Tr "repo.delete"}} + + {{end}} +
+
+
{{end}}