Browse Source

Merge branch 'benchmark-cate' of git.pcl.ac.cn:yoyoyard/opendata into bench

master
Gitea 4 years ago
parent
commit
3a513a34d2
5 changed files with 30 additions and 4 deletions
  1. +10
    -0
      models/cloudbrain.go
  2. +1
    -0
      modules/auth/cloudbrain.go
  3. +2
    -0
      modules/setting/setting.go
  4. +8
    -4
      routers/repo/cloudbrain.go
  5. +9
    -0
      templates/repo/cloudbrain/new.tmpl

+ 10
- 0
models/cloudbrain.go View File

@@ -165,6 +165,7 @@ type TaskInfo struct {
Username string `json:"username"`
TaskName string `json:"task_name"`
CodeName string `json:"code_name"`
BenchmarkCategory string `json:"selected_category"`
}

func ConvertToTaskPod(input map[string]interface{}) (TaskPod, error) {
@@ -265,6 +266,15 @@ type ImageInfo struct {
PlaceView string
}

type Categories struct {
Category []*Category `json:"category"`
}

type Category struct {
Id int `json:"id"`
Value string `json:"value"`
}

type CommitImageParams struct {
Ip string `json:"ip"`
TaskContainerId string `json:"taskContainerId"`


+ 1
- 0
modules/auth/cloudbrain.go View File

@@ -11,6 +11,7 @@ type CreateCloudBrainForm struct {
Command string `form:"command" binding:"Required"`
Attachment string `form:"attachment" binding:"Required"`
JobType string `form:"job_type" binding:"Required"`
BenchmarkCategory string `form:"benchmark_category"`
}

type CommitImageCloudBrainForm struct {


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

@@ -443,6 +443,7 @@ var (
IsBenchmarkEnabled bool
BenchmarkCode string
BenchmarkServerHost string
BenchmarkCategory string

//snn4imagenet config
IsSnn4imagenetEnabled bool
@@ -1150,6 +1151,7 @@ func NewContext() {
IsBenchmarkEnabled = sec.Key("ENABLED").MustBool(false)
BenchmarkCode = sec.Key("BENCHMARKCODE").MustString("https://yangzhx:justfortest123@git.openi.org.cn/yangzhx/detection_benchmark_script.git")
BenchmarkServerHost = sec.Key("HOST").MustString("http://192.168.202.90:3366/")
BenchmarkCategory = sec.Key("CATEGORY").MustString("")

sec = Cfg.Section("snn4imagenet")
IsSnn4imagenetEnabled = sec.Key("ENABLED").MustBool(false)


+ 8
- 4
routers/repo/cloudbrain.go View File

@@ -108,7 +108,6 @@ func CloudBrainNew(ctx *context.Context) {
}

for i, payload := range resultPublic.Payload.ImageInfo {
log.Info(resultPublic.Payload.ImageInfo[i].Place)
if strings.HasPrefix(resultPublic.Payload.ImageInfo[i].Place, "192.168") {
resultPublic.Payload.ImageInfo[i].PlaceView = payload.Place[strings.Index(payload.Place, "/"):len(payload.Place)]
} else {
@@ -131,6 +130,10 @@ func CloudBrainNew(ctx *context.Context) {
ctx.Data["model_path"] = cloudbrain.ModelMountPath
ctx.Data["benchmark_path"] = cloudbrain.BenchMarkMountPath
ctx.Data["is_benchmark_enabled"] = setting.IsBenchmarkEnabled

var categories *models.Categories
json.Unmarshal([]byte(setting.BenchmarkCategory), &categories)
ctx.Data["benchmark_categories"] = categories.Category
ctx.Data["snn4imagenet_path"] = cloudbrain.Snn4imagenetMountPath
ctx.Data["is_snn4imagenet_enabled"] = setting.IsSnn4imagenetEnabled
ctx.HTML(200, tplCloudBrainNew)
@@ -162,12 +165,12 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {

benchmarkPath := setting.JobPath + jobName + cloudbrain.BenchMarkMountPath
if setting.IsBenchmarkEnabled && jobType == string(models.JobTypeBenchmark) {
downloadRateCode(repo, jobName, setting.BenchmarkCode, benchmarkPath)
downloadRateCode(repo, jobName, setting.BenchmarkCode, benchmarkPath, form.BenchmarkCategory)
}

snn4imagenetPath := setting.JobPath + jobName + cloudbrain.Snn4imagenetMountPath
if setting.IsSnn4imagenetEnabled && jobType == string(models.JobTypeSnn4imagenet) {
downloadRateCode(repo, jobName, setting.Snn4imagenetCode, snn4imagenetPath)
downloadRateCode(repo, jobName, setting.Snn4imagenetCode, snn4imagenetPath, "")
}

err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType)
@@ -337,7 +340,7 @@ func downloadCode(repo *models.Repository, codePath string) error {
return nil
}

func downloadRateCode(repo *models.Repository, taskName, gitPath, codePath string) error {
func downloadRateCode(repo *models.Repository, taskName, gitPath, codePath, benchmarkCategory string) error {
err := os.MkdirAll(codePath, os.ModePerm)
if err != nil {
log.Error("mkdir codePath failed", err.Error())
@@ -366,6 +369,7 @@ func downloadRateCode(repo *models.Repository, taskName, gitPath, codePath strin
Username: repo.Owner.Name,
TaskName: taskName,
CodeName: repo.Name,
BenchmarkCategory: benchmarkCategory,
})
if err != nil {
log.Error("json.Marshal failed", err.Error())


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

@@ -125,6 +125,15 @@
</select>
</div>

<div class="inline required field cloudbrain_benchmark">
<label>数据集类别</label>
<select class="ui search dropdown" id="cloudbrain_benchmark_category" placeholder="选择数据集类别" style='width:385px' name="benchmark_category">
{{range .benchmark_categories}}
<option name="benchmark_category" value="{{.Value}}">{{.Value}}</option>
{{end}}
</select>
</div>

<div class="inline required field">
<label>镜像</label>
<select class="ui search dropdown" id="cloudbrain_image" placeholder="选择镜像" style='width:385px' name="image">


Loading…
Cancel
Save