|
|
@@ -206,7 +206,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
|
displayJobName := form.DisplayJobName |
|
|
|
jobName := util.ConvertDisplayJobNameToJobName(displayJobName) |
|
|
|
image := form.Image |
|
|
|
image := strings.TrimSpace(form.Image) |
|
|
|
uuid := form.Attachment |
|
|
|
jobType := form.JobType |
|
|
|
gpuQueue := form.GpuType |
|
|
@@ -283,30 +283,6 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
mkModelPath(modelPath) |
|
|
|
uploadCodeToMinio(modelPath, jobName, cloudbrain.ModelMountPath+"/") |
|
|
|
|
|
|
|
benchmarkPath := setting.JobPath + jobName + cloudbrain.BenchMarkMountPath |
|
|
|
if setting.IsBenchmarkEnabled && jobType == string(models.JobTypeBenchmark) { |
|
|
|
var gpuType string |
|
|
|
for _, gpuInfo := range gpuInfos.GpuInfo { |
|
|
|
if gpuInfo.Queue == gpuQueue { |
|
|
|
gpuType = gpuInfo.Value |
|
|
|
} |
|
|
|
} |
|
|
|
downloadRateCode(repo, jobName, setting.BenchmarkOwner, setting.BenchmarkName, benchmarkPath, form.BenchmarkCategory, gpuType) |
|
|
|
uploadCodeToMinio(benchmarkPath+"/", jobName, cloudbrain.BenchMarkMountPath+"/") |
|
|
|
} |
|
|
|
|
|
|
|
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+"/"), |
|
|
@@ -482,6 +458,17 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName, jobType models.Jo |
|
|
|
ctx.Data["resource_type"] = resourceType.Value |
|
|
|
} |
|
|
|
} |
|
|
|
} else if cloudbrain.IsBenchmarkJob(task.JobType) { |
|
|
|
if benchmarkGpuInfos == nil { |
|
|
|
json.Unmarshal([]byte(setting.BenchmarkGpuTypes), &benchmarkGpuInfos) |
|
|
|
} |
|
|
|
|
|
|
|
for _, resourceType := range benchmarkGpuInfos.GpuInfo { |
|
|
|
if resourceType.Queue == jobRes.Config.GpuType { |
|
|
|
ctx.Data["resource_type"] = resourceType.Value |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
if gpuInfos == nil { |
|
|
|
json.Unmarshal([]byte(setting.GpuTypes), &gpuInfos) |
|
|
@@ -1241,7 +1228,7 @@ func downloadCode(repo *models.Repository, codePath, branchName string) error { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func downloadRateCode(repo *models.Repository, taskName, rateOwnerName, rateRepoName, codePath, benchmarkCategory, gpuType string) error { |
|
|
|
func downloadRateCode(repo *models.Repository, taskName, rateOwnerName, rateRepoName, codePath, benchmarkCategory, gpuType, userName string) error { |
|
|
|
err := os.MkdirAll(codePath, os.ModePerm) |
|
|
|
if err != nil { |
|
|
|
log.Error("mkdir codePath failed", err.Error()) |
|
|
@@ -1269,7 +1256,7 @@ func downloadRateCode(repo *models.Repository, taskName, rateOwnerName, rateRepo |
|
|
|
defer f.Close() |
|
|
|
|
|
|
|
data, err := json.Marshal(models.TaskInfo{ |
|
|
|
Username: repo.Owner.Name, |
|
|
|
Username: userName, |
|
|
|
TaskName: taskName, |
|
|
|
CodeName: repo.Name, |
|
|
|
BenchmarkCategory: strings.Split(benchmarkCategory, ","), |
|
|
@@ -1845,7 +1832,7 @@ func BenchMarkAlgorithmCreate(ctx *context.Context, form auth.CreateCloudBrainFo |
|
|
|
ctx.Data["PageIsCloudBrain"] = true |
|
|
|
displayJobName := form.DisplayJobName |
|
|
|
jobName := util.ConvertDisplayJobNameToJobName(displayJobName) |
|
|
|
image := form.Image |
|
|
|
image := strings.TrimSpace(form.Image) |
|
|
|
gpuQueue := form.GpuType |
|
|
|
command := cloudbrain.CommandBenchmark |
|
|
|
codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath |
|
|
@@ -1970,7 +1957,7 @@ func BenchMarkAlgorithmCreate(ctx *context.Context, form auth.CreateCloudBrainFo |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if err := downloadRateCode(repo, jobName, childInfo.Owner, childInfo.RepoName, benchmarkPath, form.BenchmarkCategory, gpuType); err != nil { |
|
|
|
if err := downloadRateCode(repo, jobName, childInfo.Owner, childInfo.RepoName, benchmarkPath, form.BenchmarkCategory, gpuType, ctx.User.Name); err != nil { |
|
|
|
log.Error("downloadRateCode failed, %v", err, ctx.Data["MsgID"]) |
|
|
|
//cloudBrainNewDataPrepare(ctx) |
|
|
|
//ctx.RenderWithErr("system error", tplCloudBrainBenchmarkNew, &form) |
|
|
@@ -2068,7 +2055,7 @@ func ModelBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainForm) |
|
|
|
|
|
|
|
snn4imagenetPath := setting.JobPath + jobName + cloudbrain.Snn4imagenetMountPath |
|
|
|
if setting.IsSnn4imagenetEnabled && jobType == string(models.JobTypeSnn4imagenet) { |
|
|
|
downloadRateCode(repo, jobName, setting.Snn4imagenetOwner, setting.Snn4imagenetName, snn4imagenetPath, "", "") |
|
|
|
downloadRateCode(repo, jobName, setting.Snn4imagenetOwner, setting.Snn4imagenetName, snn4imagenetPath, "", "", ctx.User.Name) |
|
|
|
uploadCodeToMinio(snn4imagenetPath+"/", jobName, cloudbrain.Snn4imagenetMountPath+"/") |
|
|
|
command = fmt.Sprintf(cloudbrain.Snn4imagenetCommand, displayJobName, trimSpaceNewlineInString(form.Description)) |
|
|
|
|
|
|
@@ -2076,7 +2063,7 @@ func ModelBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainForm) |
|
|
|
benchmarkChildTypeID := 0 |
|
|
|
brainScorePath := setting.JobPath + jobName + cloudbrain.BrainScoreMountPath |
|
|
|
if setting.IsBrainScoreEnabled && jobType == string(models.JobTypeBrainScore) { |
|
|
|
downloadRateCode(repo, jobName, setting.BrainScoreOwner, setting.BrainScoreName, brainScorePath, "", "") |
|
|
|
downloadRateCode(repo, jobName, setting.BrainScoreOwner, setting.BrainScoreName, brainScorePath, "", "", ctx.User.Name) |
|
|
|
uploadCodeToMinio(brainScorePath+"/", jobName, cloudbrain.BrainScoreMountPath+"/") |
|
|
|
benchmarkChildTypeID = form.BenchmarkChildTypeID |
|
|
|
command = fmt.Sprintf(cloudbrain.BrainScoreCommand, getBrainRegion(benchmarkChildTypeID), displayJobName, trimSpaceNewlineInString(form.Description)) |
|
|
@@ -2136,7 +2123,7 @@ func CloudBrainTrainJobNew(ctx *context.Context) { |
|
|
|
|
|
|
|
func getTrainJobCommand(form auth.CreateCloudBrainForm) (string, error) { |
|
|
|
var command string |
|
|
|
bootFile := form.BootFile |
|
|
|
bootFile := strings.TrimSpace(form.BootFile) |
|
|
|
params := form.Params |
|
|
|
|
|
|
|
if !strings.HasSuffix(bootFile, ".py") { |
|
|
|