| @@ -49,43 +49,6 @@ func MustEnableCloudbrain(ctx *context.Context) { | |||||
| return | return | ||||
| } | } | ||||
| } | } | ||||
| func CloudBrainIndex(ctx *context.Context) { | |||||
| MustEnableCloudbrain(ctx) | |||||
| repo := ctx.Repo.Repository | |||||
| page := ctx.QueryInt("page") | |||||
| if page <= 0 { | |||||
| page = 1 | |||||
| } | |||||
| ciTasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{ | |||||
| ListOptions: models.ListOptions{ | |||||
| Page: page, | |||||
| PageSize: setting.UI.IssuePagingNum, | |||||
| }, | |||||
| RepoID: repo.ID, | |||||
| Type: models.TypeCloudBrainOne, | |||||
| }) | |||||
| if err != nil { | |||||
| ctx.ServerError("Cloudbrain", err) | |||||
| return | |||||
| } | |||||
| for i, task := range ciTasks { | |||||
| ciTasks[i].CanDebug = cloudbrain.CanCreateOrDebugJob(ctx) | |||||
| ciTasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain) | |||||
| ciTasks[i].Cloudbrain.ComputeResource = modelarts.GPUResource | |||||
| } | |||||
| pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5) | |||||
| pager.SetDefaultParams(ctx) | |||||
| ctx.Data["Page"] = pager | |||||
| ctx.Data["PageIsCloudBrain"] = true | |||||
| ctx.Data["Tasks"] = ciTasks | |||||
| ctx.Data["CanCreate"] = cloudbrain.CanCreateOrDebugJob(ctx) | |||||
| ctx.HTML(200, tplCloudBrainIndex) | |||||
| } | |||||
| func cutString(str string, lens int) string { | func cutString(str string, lens int) string { | ||||
| if len(str) < lens { | if len(str) < lens { | ||||
| @@ -103,45 +103,6 @@ func MustEnableModelArts(ctx *context.Context) { | |||||
| } | } | ||||
| } | } | ||||
| func NotebookIndex(ctx *context.Context) { | |||||
| MustEnableModelArts(ctx) | |||||
| repo := ctx.Repo.Repository | |||||
| page := ctx.QueryInt("page") | |||||
| if page <= 0 { | |||||
| page = 1 | |||||
| } | |||||
| ciTasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{ | |||||
| ListOptions: models.ListOptions{ | |||||
| Page: page, | |||||
| PageSize: setting.UI.IssuePagingNum, | |||||
| }, | |||||
| RepoID: repo.ID, | |||||
| Type: models.TypeCloudBrainTwo, | |||||
| JobType: string(models.JobTypeDebug), | |||||
| }) | |||||
| if err != nil { | |||||
| ctx.ServerError("Cloudbrain", err) | |||||
| return | |||||
| } | |||||
| for i, task := range ciTasks { | |||||
| ciTasks[i].CanDebug = cloudbrain.CanCreateOrDebugJob(ctx) | |||||
| ciTasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain) | |||||
| ciTasks[i].Cloudbrain.ComputeResource = modelarts.NPUResource | |||||
| } | |||||
| pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5) | |||||
| pager.SetDefaultParams(ctx) | |||||
| ctx.Data["Page"] = pager | |||||
| ctx.Data["PageIsCloudBrain"] = true | |||||
| ctx.Data["Tasks"] = ciTasks | |||||
| ctx.Data["CanCreate"] = cloudbrain.CanCreateOrDebugJob(ctx) | |||||
| ctx.HTML(200, tplModelArtsNotebookIndex) | |||||
| } | |||||
| func NotebookNew(ctx *context.Context) { | func NotebookNew(ctx *context.Context) { | ||||
| ctx.Data["PageIsCloudBrain"] = true | ctx.Data["PageIsCloudBrain"] = true | ||||
| @@ -960,7 +960,6 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| }, context.RepoRef()) | }, context.RepoRef()) | ||||
| m.Group("/cloudbrain", func() { | m.Group("/cloudbrain", func() { | ||||
| m.Get("", reqRepoCloudBrainReader, repo.CloudBrainIndex) | |||||
| m.Group("/:jobid", func() { | m.Group("/:jobid", func() { | ||||
| m.Get("", reqRepoCloudBrainReader, repo.CloudBrainShow) | m.Get("", reqRepoCloudBrainReader, repo.CloudBrainShow) | ||||
| m.Get("/debug", reqRepoCloudBrainWriter, repo.CloudBrainDebug) | m.Get("/debug", reqRepoCloudBrainWriter, repo.CloudBrainDebug) | ||||
| @@ -998,7 +997,6 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| m.Group("/modelarts", func() { | m.Group("/modelarts", func() { | ||||
| m.Group("/notebook", func() { | m.Group("/notebook", func() { | ||||
| m.Get("", reqRepoCloudBrainReader, repo.NotebookIndex) | |||||
| m.Group("/:jobid", func() { | m.Group("/:jobid", func() { | ||||
| m.Get("", reqRepoCloudBrainReader, repo.NotebookShow) | m.Get("", reqRepoCloudBrainReader, repo.NotebookShow) | ||||
| m.Get("/debug", reqRepoCloudBrainWriter, repo.NotebookDebug) | m.Get("/debug", reqRepoCloudBrainWriter, repo.NotebookDebug) | ||||