Browse Source

benchmark

tags/v1.21.12.1
yuyuanshifu 4 years ago
parent
commit
0389b80960
4 changed files with 40 additions and 3 deletions
  1. +9
    -1
      modules/cloudbrain/cloudbrain.go
  2. +2
    -0
      modules/setting/setting.go
  3. +25
    -2
      routers/repo/cloudbrain.go
  4. +4
    -0
      templates/repo/cloudbrain/new.tmpl

+ 9
- 1
modules/cloudbrain/cloudbrain.go View File

@@ -14,13 +14,14 @@ const (
CodeMountPath = "/code"
DataSetMountPath = "/dataset"
ModelMountPath = "/model"
BenchMarkMountPath = "/benchmark"

SubTaskName = "task1"

Success = "S000"
)

func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath string) error {
func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath string) error {
dataActualPath := setting.Attachment.Minio.RealPath +
setting.Attachment.Minio.Bucket + "/" +
setting.Attachment.Minio.BasePath +
@@ -69,6 +70,13 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath,
ReadOnly: false,
},
},
{
HostPath: models.StHostPath{
Path: benchmarkPath,
MountPath: BenchMarkMountPath,
ReadOnly: true,
},
},
},
})
if err != nil {


+ 2
- 0
modules/setting/setting.go View File

@@ -438,6 +438,7 @@ var (
JobPath string
JobType string
DebugServerHost string
BenchmarkCode string
)

// DateLang transforms standard language locale name to corresponding value in datetime plugin.
@@ -1113,6 +1114,7 @@ func NewContext() {
JobPath = sec.Key("JOB_PATH").MustString("/datasets/minio/data/opendata/jobs/")
DebugServerHost = sec.Key("DEBUG_SERVER_HOST").MustString("http://192.168.202.73")
JobType = sec.Key("JOB_TYPE").MustString("debug_openi")
BenchmarkCode = sec.Key("BENCHMARKCODE").MustString("https://yangzhx:justfortest123@git.openi.org.cn/yangzhx/detection_benchmark_script.git")
}

func loadInternalToken(sec *ini.Section) string {


+ 25
- 2
routers/repo/cloudbrain.go View File

@@ -4,6 +4,7 @@ import (
"code.gitea.io/gitea/modules/git"
"errors"
"os"
"os/exec"
"strconv"
"strings"
"time"
@@ -109,6 +110,7 @@ func CloudBrainNew(ctx *context.Context) {
ctx.Data["code_path"] = cloudbrain.CodeMountPath
ctx.Data["dataset_path"] = cloudbrain.DataSetMountPath
ctx.Data["model_path"] = cloudbrain.ModelMountPath
ctx.Data["benchmark_path"] = cloudbrain.BenchMarkMountPath
ctx.HTML(200, tplCloudBrainNew)
}

@@ -122,14 +124,17 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {
repo := ctx.Repo.Repository
downloadCode(repo, codePath)

modelPath := setting.JobPath + jobName + "/model"
modelPath := setting.JobPath + jobName + cloudbrain.ModelMountPath
err := os.MkdirAll(modelPath, os.ModePerm)
if err != nil {
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form)
return
}

err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath)
benchmarkPath := setting.JobPath + jobName + cloudbrain.BenchMarkMountPath
downloadBenchmarkCode(benchmarkPath)

err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath)
if err != nil {
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form)
return
@@ -255,3 +260,21 @@ func downloadCode(repo *models.Repository, codePath string) error {

return nil
}

func downloadBenchmarkCode(benchmarkPath string) error {
err := os.MkdirAll(benchmarkPath, os.ModePerm)
if err != nil {
log.Error("mkdir benchmarkPath failed", err.Error())
return err
}

command := "git clone " + setting.BenchmarkCode + " " + benchmarkPath
cmd := exec.Command("/bin/bash", "-c", command)
output, err := cmd.Output()
log.Info(string(output))
if err != nil {
log.Error("exec.Command(%s) failed:%v", command, err)
return err
}
return nil
}

+ 4
- 0
templates/repo/cloudbrain/new.tmpl View File

@@ -148,6 +148,10 @@
<label>代码存放路径</label>
<input name="code_path" id="cloudbrain_code_path" value="{{.code_path}}" tabindex="3" autofocus required maxlength="255" readonly="readonly">
</div>
<div class="inline required field">
<label>benchmark脚本存放路径</label>
<input name="benchmark_path" id="cloudbrain_benchmark_path" value="{{.benchmark_path}}" tabindex="3" autofocus required maxlength="255" readonly="readonly">
</div>
<div class="inline required field" hidden>
<label>启动命令</label>
<textarea name="command" rows="10" readonly="readonly">{{.command}}</textarea>


Loading…
Cancel
Save