| @@ -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) | |||
| } | |||
| @@ -144,7 +144,7 @@ func init() { | |||
| new(WechatBindLog), | |||
| new(OrgStatistic), | |||
| new(SearchRecord), | |||
| new(AiModelManageConvert), | |||
| new(AiModelConvert), | |||
| ) | |||
| tablesStatistic = append(tablesStatistic, | |||
| @@ -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 | |||
| } | |||
| @@ -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) | |||
| @@ -75,7 +75,58 @@ | |||
| <span class="fitted" style="width: 90%;vertical-align: middle;">{{.Name}}</span> | |||
| </a> | |||
| </div> | |||
| <div class="one wide column padding0" style="padding-left: 2.2rem !important;"> | |||
| <span class="job-status" id="{{.ID}}"> | |||
| <span><i id="{{.ID}}-icon" style="vertical-align: middle;" class="{{.Status}}"></i><span id="{{.ID}}-text" style="margin-left: 0.4em;font-size: 12px;">{{.Status}}</span></span> | |||
| </span> | |||
| </div> | |||
| <div class="two wide column padding0"> | |||
| <span style="font-size: 12px;">{{.SrcEngine}}</span> | |||
| </div> | |||
| <div class="two wide column padding0"> | |||
| <span style="font-size: 12px;">{{.DestFormat}}</span> | |||
| </div> | |||
| <div class="two wide column padding0"> | |||
| <span style="font-size: 12px;" class="">{{TimeSinceUnix .CreatedUnix $.Lang}}</span> | |||
| </div> | |||
| <div class="two wide column padding0"> | |||
| <span style="font-size: 12px;" id="duration-{{.ID}}">{{.TrainJobDuration}}</span> | |||
| </div> | |||
| <div class="one wide column text center padding0"> | |||
| <a href="{{AppSubUrl}}/{{.UserName}}" title="{{.UserName}}"><img class="ui avatar image" src="{{.RelAvatarLink}}"></a> | |||
| </div> | |||
| <div class="three wide column text center padding0"> | |||
| <div class="ui compact buttons" > | |||
| <!-- 停止任务 --> | |||
| <form id="stopForm-{{.ID}}" style="margin-left:-1px;"> | |||
| {{$.CsrfTokenHtml}} | |||
| {{if .IsCanOper}} | |||
| <a id="ai-stop-{{.ID}}" class='ui basic ai_stop {{if eq .Status "STOPPED" "FAILED" "START_FAILED" "STOPPING" "CREATING" "STARTING" "SUCCEEDED"}}disabled {{else}}blue {{end}}button' data-repopath="{{$.RepoLink}}/modelmanage/convert_stop/{{.ID}}" data-jobid="{{.ID}}"> | |||
| {{$.i18n.Tr "repo.stop"}} | |||
| </a> | |||
| {{else}} | |||
| <a class="ui basic disabled button"> | |||
| {{$.i18n.Tr "repo.stop"}} | |||
| </a> | |||
| {{end}} | |||
| </form> | |||
| <!-- 删除任务 --> | |||
| <form id="delForm-{{.ID}}" action="{{$.RepoLink}}/modelmanage/delete_model_convert/{{.ID}}" method="post"> | |||
| <input type="hidden" name="debugListType" value="all"> | |||
| {{$.CsrfTokenHtml}} | |||
| {{if .IsCanDelete}} | |||
| <a id="ai-delete-{{.ID}}" class='ui basic ai_delete {{if eq .Status "STOPPED" "FAILED" "START_FAILED" "SUCCEEDED"}}blue {{else}}disabled {{end}}button' style="border-radius: .28571429rem;"> | |||
| {{$.i18n.Tr "repo.delete"}} | |||
| </a> | |||
| {{else}} | |||
| <a class="ui basic button disabled" style="border-radius: .28571429rem;"> | |||
| {{$.i18n.Tr "repo.delete"}} | |||
| </a> | |||
| {{end}} | |||
| </form> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| {{end}} | |||