|
|
|
@@ -0,0 +1,98 @@ |
|
|
|
package admin |
|
|
|
|
|
|
|
import ( |
|
|
|
"strings" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/modelarts" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
"code.gitea.io/gitea/modules/base" |
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
|
tplCloudBrains base.TplName = "admin/cloudbrain/list" |
|
|
|
) |
|
|
|
|
|
|
|
func CloudBrains(ctx *context.Context) { |
|
|
|
ctx.Data["Title"] = ctx.Tr("admin.cloudBrains") |
|
|
|
ctx.Data["PageIsAdmin"] = true |
|
|
|
ctx.Data["PageIsAdminCloudBrains"] = true |
|
|
|
|
|
|
|
listType := ctx.Query("listType") |
|
|
|
jobType := ctx.Query("jobType") |
|
|
|
jobStatus := ctx.Query("jobStatus") |
|
|
|
|
|
|
|
ctx.Data["ListType"] = listType |
|
|
|
ctx.Data["JobType"] = jobType |
|
|
|
ctx.Data["JobStatus"] = jobStatus |
|
|
|
|
|
|
|
page := ctx.QueryInt("page") |
|
|
|
if page <= 0 { |
|
|
|
page = 1 |
|
|
|
} |
|
|
|
debugType := modelarts.DebugType |
|
|
|
if listType == models.GPUResource { |
|
|
|
debugType = models.TypeCloudBrainOne |
|
|
|
} else if listType == models.NPUResource { |
|
|
|
debugType = models.TypeCloudBrainTwo |
|
|
|
} |
|
|
|
|
|
|
|
var jobTypes []string |
|
|
|
jobTypeNot := false |
|
|
|
if jobType == string(models.JobTypeDebug) { |
|
|
|
jobTypes = append(jobTypes, string(models.JobTypeSnn4imagenet), string(models.JobTypeBrainScore), string(models.JobTypeDebug)) |
|
|
|
} else if jobType != "all" && jobType != "" { |
|
|
|
jobTypes = append(jobTypes, jobType) |
|
|
|
} |
|
|
|
|
|
|
|
var jobStatuses []string |
|
|
|
jobStatusNot := false |
|
|
|
if jobStatus == "other" { |
|
|
|
jobStatusNot = true |
|
|
|
jobStatuses = append(jobStatuses, string(models.ModelArtsTrainJobWaiting), string(models.ModelArtsTrainJobFailed), string(models.ModelArtsRunning), string(models.ModelArtsTrainJobCompleted), |
|
|
|
string(models.ModelArtsStarting), string(models.ModelArtsRestarting), string(models.ModelArtsStartFailed), |
|
|
|
string(models.ModelArtsStopping), string(models.ModelArtsStopped)) |
|
|
|
} else if jobStatus != "all" && jobStatus != "" { |
|
|
|
jobStatuses = append(jobStatuses, jobStatus) |
|
|
|
} |
|
|
|
|
|
|
|
keyword := strings.Trim(ctx.Query("q"), " ") |
|
|
|
|
|
|
|
ciTasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{ |
|
|
|
ListOptions: models.ListOptions{ |
|
|
|
Page: page, |
|
|
|
PageSize: setting.UI.IssuePagingNum, |
|
|
|
}, |
|
|
|
Keyword: keyword, |
|
|
|
Type: debugType, |
|
|
|
JobTypeNot: jobTypeNot, |
|
|
|
JobStatusNot: jobStatusNot, |
|
|
|
JobStatus: jobStatuses, |
|
|
|
JobTypes: jobTypes, |
|
|
|
NeedRepoInfo: true, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("Get job failed:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
for i, task := range ciTasks { |
|
|
|
ciTasks[i].CanDebug = true |
|
|
|
ciTasks[i].CanDel = true |
|
|
|
ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource |
|
|
|
} |
|
|
|
|
|
|
|
pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5) |
|
|
|
pager.SetDefaultParams(ctx) |
|
|
|
pager.AddParam(ctx, "listType", "ListType") |
|
|
|
ctx.Data["Page"] = pager |
|
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
|
ctx.Data["Tasks"] = ciTasks |
|
|
|
ctx.Data["CanCreate"] = true |
|
|
|
ctx.Data["Keyword"] = keyword |
|
|
|
|
|
|
|
ctx.HTML(200, tplCloudBrains) |
|
|
|
|
|
|
|
} |