|
|
@@ -143,7 +143,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
jobType := form.JobType |
|
|
|
codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath |
|
|
|
|
|
|
|
if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) { |
|
|
|
if jobType != string(models.JobTypeBenchmark) && jobType != string(models.JobTypeDebug) && jobType != string(models.JobTypeSnn4imagenet){ |
|
|
|
log.Error("jobtype error:", jobType) |
|
|
|
ctx.RenderWithErr("jobtype error", tplCloudBrainNew, &form) |
|
|
|
return |
|
|
@@ -160,10 +160,15 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
|
|
|
|
benchmarkPath := setting.JobPath + jobName + cloudbrain.BenchMarkMountPath |
|
|
|
if setting.IsBenchmarkEnabled && jobType == string(models.JobTypeBenchmark) { |
|
|
|
downloadBenchmarkCode(repo, jobName, benchmarkPath) |
|
|
|
downloadRateCode(repo, jobName, setting.BenchmarkCode, benchmarkPath) |
|
|
|
} |
|
|
|
|
|
|
|
err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, jobType) |
|
|
|
snn4imagenetPath := setting.JobPath + jobName + cloudbrain.Snn4imagenetMountPath |
|
|
|
if setting.IsSnn4imagenetEnabled && jobType == string(models.JobTypeSnn4imagenet) { |
|
|
|
downloadRateCode(repo, jobName, setting.Snn4imagenetCode, snn4imagenetPath) |
|
|
|
} |
|
|
|
|
|
|
|
err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType) |
|
|
|
if err != nil { |
|
|
|
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) |
|
|
|
return |
|
|
@@ -324,14 +329,14 @@ func downloadCode(repo *models.Repository, codePath string) error { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func downloadBenchmarkCode(repo *models.Repository, taskName string, benchmarkPath string) error { |
|
|
|
err := os.MkdirAll(benchmarkPath, os.ModePerm) |
|
|
|
func downloadRateCode(repo *models.Repository, taskName, gitPath, codePath string) error { |
|
|
|
err := os.MkdirAll(codePath, os.ModePerm) |
|
|
|
if err != nil { |
|
|
|
log.Error("mkdir benchmarkPath failed", err.Error()) |
|
|
|
log.Error("mkdir codePath failed", err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
command := "git clone " + setting.BenchmarkCode + " " + benchmarkPath |
|
|
|
command := "git clone " + gitPath + " " + codePath |
|
|
|
cmd := exec.Command("/bin/bash", "-c", command) |
|
|
|
output, err := cmd.Output() |
|
|
|
log.Info(string(output)) |
|
|
@@ -340,7 +345,7 @@ func downloadBenchmarkCode(repo *models.Repository, taskName string, benchmarkPa |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
fileName := benchmarkPath + cloudbrain.TaskInfoName |
|
|
|
fileName := codePath + cloudbrain.TaskInfoName |
|
|
|
f, err := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) |
|
|
|
if err != nil { |
|
|
|
log.Error("OpenFile failed", err.Error()) |
|
|
|