|
|
|
@@ -249,7 +249,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeSnn4imagenet) && jobType != string(models.JobTypeBrainScore) && jobType != string(models.JobTypeTrain) { |
|
|
|
if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeTrain) { |
|
|
|
log.Error("jobtype error:", jobType, ctx.Data["MsgID"]) |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("jobtype error", tpl, &form) |
|
|
|
@@ -1646,7 +1646,7 @@ func CloudBrainBenchmarkIndex(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
var jobTypes []string |
|
|
|
jobTypes = append(jobTypes, string(models.JobTypeBenchmark)) |
|
|
|
jobTypes = append(jobTypes, string(models.JobTypeBenchmark), string(models.JobTypeBrainScore), string(models.JobTypeSnn4imagenet)) |
|
|
|
ciTasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{ |
|
|
|
ListOptions: models.ListOptions{ |
|
|
|
Page: page, |
|
|
|
@@ -1676,7 +1676,12 @@ func CloudBrainBenchmarkIndex(ctx *context.Context) { |
|
|
|
} |
|
|
|
ciTasks[i].TrainJobDuration = models.ConvertDurationToStr(ciTasks[i].Duration) |
|
|
|
} |
|
|
|
|
|
|
|
if ciTasks[i].JobType == string(models.JobTypeBenchmark) { |
|
|
|
ciTasks[i].BenchmarkType = ctx.Tr("cloudbrain.benchmark.algorithm") |
|
|
|
} else if ciTasks[i].JobType == string(models.JobTypeSnn4imagenet) || ciTasks[i].JobType == string(models.JobTypeBrainScore) { |
|
|
|
ciTasks[i].BenchmarkType = ctx.Tr("cloudbrain.benchmark.model") |
|
|
|
ciTasks[i].BenchmarkTypeName = ciTasks[i].JobType |
|
|
|
} |
|
|
|
ciTasks[i].BenchmarkTypeName = "" |
|
|
|
if task.BenchmarkTypeID > 0 { |
|
|
|
for _, benchmarkType := range GetBenchmarkTypes(ctx).BenchmarkType { |
|
|
|
@@ -1813,6 +1818,16 @@ func getBenchmarkResourceSpec(resourceSpecID int) (int, error) { |
|
|
|
} |
|
|
|
|
|
|
|
func CloudBrainBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
jobType := form.JobType |
|
|
|
if jobType == string(models.JobTypeBenchmark) { |
|
|
|
BenchMarkAlgorithmCreate(ctx, form) |
|
|
|
} else { |
|
|
|
ModelBenchmarkCreate(ctx, form) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func BenchMarkAlgorithmCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
|
displayJobName := form.DisplayJobName |
|
|
|
jobName := util.ConvertDisplayJobNameToJobName(displayJobName) |
|
|
|
@@ -1965,6 +1980,99 @@ func CloudBrainBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainF |
|
|
|
ctx.RenderWithErr(err.Error(), tplCloudBrainBenchmarkNew, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain/benchmark") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func ModelBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
|
displayJobName := form.DisplayJobName |
|
|
|
jobName := util.ConvertDisplayJobNameToJobName(displayJobName) |
|
|
|
image := form.Image |
|
|
|
uuid := form.Attachment |
|
|
|
jobType := form.JobType |
|
|
|
gpuQueue := form.GpuType |
|
|
|
codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath |
|
|
|
resourceSpecId := form.ResourceSpecId |
|
|
|
branchName := cloudbrain.DefaultBranchName |
|
|
|
repo := ctx.Repo.Repository |
|
|
|
|
|
|
|
tpl := tplCloudBrainBenchmarkNew |
|
|
|
command := cloudbrain.Command |
|
|
|
|
|
|
|
tasks, err := models.GetCloudbrainsByDisplayJobName(repo.ID, jobType, displayJobName) |
|
|
|
if err == nil { |
|
|
|
if len(tasks) != 0 { |
|
|
|
log.Error("the job name did already exist", ctx.Data["MsgID"]) |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("the job name did already exist", tpl, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
} else { |
|
|
|
if !models.IsErrJobNotExist(err) { |
|
|
|
log.Error("system error, %v", err, ctx.Data["MsgID"]) |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("system error", tpl, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if !jobNamePattern.MatchString(displayJobName) { |
|
|
|
ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tpl, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if jobType != string(models.JobTypeSnn4imagenet) && jobType != string(models.JobTypeBrainScore) { |
|
|
|
log.Error("jobtype error:", jobType, ctx.Data["MsgID"]) |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("jobtype error", tpl, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
count, err := models.GetCloudbrainCountByUserID(ctx.User.ID, jobType) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetCloudbrainCountByUserID failed:%v", err, ctx.Data["MsgID"]) |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("system error", tpl, &form) |
|
|
|
return |
|
|
|
} else { |
|
|
|
if count >= 1 { |
|
|
|
log.Error("the user already has running or waiting task", ctx.Data["MsgID"]) |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("you have already a running or waiting task, can not create more", tpl, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
downloadCode(repo, codePath, branchName) |
|
|
|
uploadCodeToMinio(codePath+"/", jobName, cloudbrain.CodeMountPath+"/") |
|
|
|
|
|
|
|
modelPath := setting.JobPath + jobName + cloudbrain.ModelMountPath + "/" |
|
|
|
mkModelPath(modelPath) |
|
|
|
uploadCodeToMinio(modelPath, jobName, cloudbrain.ModelMountPath+"/") |
|
|
|
|
|
|
|
snn4imagenetPath := setting.JobPath + jobName + cloudbrain.Snn4imagenetMountPath |
|
|
|
if setting.IsSnn4imagenetEnabled && jobType == string(models.JobTypeSnn4imagenet) { |
|
|
|
downloadRateCode(repo, jobName, setting.Snn4imagenetOwner, setting.Snn4imagenetName, snn4imagenetPath, "", "") |
|
|
|
uploadCodeToMinio(snn4imagenetPath+"/", jobName, cloudbrain.Snn4imagenetMountPath+"/") |
|
|
|
} |
|
|
|
|
|
|
|
brainScorePath := setting.JobPath + jobName + cloudbrain.BrainScoreMountPath |
|
|
|
if setting.IsBrainScoreEnabled && jobType == string(models.JobTypeBrainScore) { |
|
|
|
downloadRateCode(repo, jobName, setting.BrainScoreOwner, setting.BrainScoreName, brainScorePath, "", "") |
|
|
|
uploadCodeToMinio(brainScorePath+"/", jobName, cloudbrain.BrainScoreMountPath+"/") |
|
|
|
} |
|
|
|
|
|
|
|
err = cloudbrain.GenerateTask(ctx, displayJobName, jobName, image, command, uuid, storage.GetMinioPath(jobName, cloudbrain.CodeMountPath+"/"), |
|
|
|
storage.GetMinioPath(jobName, cloudbrain.ModelMountPath+"/"), |
|
|
|
storage.GetMinioPath(jobName, cloudbrain.BenchMarkMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.Snn4imagenetMountPath+"/"), |
|
|
|
storage.GetMinioPath(jobName, cloudbrain.BrainScoreMountPath+"/"), jobType, gpuQueue, form.Description, branchName, form.BootFile, form.Params, |
|
|
|
0, 0, resourceSpecId) |
|
|
|
if err != nil { |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr(err.Error(), tpl, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain/benchmark") |
|
|
|
} |
|
|
|
|