|
|
|
@@ -8,7 +8,6 @@ import ( |
|
|
|
"io" |
|
|
|
"net/http" |
|
|
|
"os" |
|
|
|
"os/exec" |
|
|
|
"regexp" |
|
|
|
"sort" |
|
|
|
"strconv" |
|
|
|
@@ -263,19 +262,19 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
gpuType = gpuInfo.Value |
|
|
|
} |
|
|
|
} |
|
|
|
downloadRateCode(repo, jobName, setting.BenchmarkCode, benchmarkPath, form.BenchmarkCategory, gpuType) |
|
|
|
downloadRateCode(repo, jobName, setting.BenchmarkOwner, setting.BrainScoreName, 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.Snn4imagenetCode, snn4imagenetPath, "", "") |
|
|
|
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.BrainScoreCode, brainScorePath, "", "") |
|
|
|
downloadRateCode(repo, jobName, setting.BrainScoreOwner, setting.BrainScoreName, brainScorePath, "", "") |
|
|
|
uploadCodeToMinio(brainScorePath + "/", jobName, cloudbrain.BrainScoreMountPath + "/") |
|
|
|
} |
|
|
|
|
|
|
|
@@ -700,19 +699,21 @@ func downloadCode(repo *models.Repository, codePath string) error { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func downloadRateCode(repo *models.Repository, taskName, gitPath, codePath, benchmarkCategory, gpuType string) error { |
|
|
|
func downloadRateCode(repo *models.Repository, taskName, rateOwnerName, rateRepoName, codePath, benchmarkCategory, gpuType string) error { |
|
|
|
err := os.MkdirAll(codePath, os.ModePerm) |
|
|
|
if err != nil { |
|
|
|
log.Error("mkdir codePath failed", err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
command := "git clone " + gitPath + " " + codePath |
|
|
|
cmd := exec.Command("/bin/bash", "-c", command) |
|
|
|
_, err = cmd.Output() |
|
|
|
|
|
|
|
repoExt, err := models.GetRepositoryByOwnerAndName(rateOwnerName, rateRepoName) |
|
|
|
if err != nil { |
|
|
|
log.Error("exec.Command(%s) failed:%v", command, err) |
|
|
|
log.Error("GetRepositoryByOwnerAndName(%s) failed", rateRepoName, err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
if err := git.Clone(repoExt.RepoPath(), codePath, git.CloneRepoOptions{}); err != nil { |
|
|
|
log.Error("Failed to clone repository: %s (%v)", repoExt.FullName(), err) |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
|