Browse Source

JobTypeSnn4imagenet

tags/v1.21.12.1
yuyuanshifu 4 years ago
parent
commit
518ebf60d9
4 changed files with 33 additions and 2 deletions
  1. +19
    -0
      routers/repo/cloudbrain.go
  2. +1
    -0
      routers/routes/routes.go
  3. +1
    -1
      templates/repo/cloudbrain/index.tmpl
  4. +12
    -1
      templates/repo/cloudbrain/new.tmpl

+ 19
- 0
routers/repo/cloudbrain.go View File

@@ -131,6 +131,8 @@ func CloudBrainNew(ctx *context.Context) {
ctx.Data["model_path"] = cloudbrain.ModelMountPath
ctx.Data["benchmark_path"] = cloudbrain.BenchMarkMountPath
ctx.Data["is_benchmark_enabled"] = setting.IsBenchmarkEnabled
ctx.Data["snn4imagenet_path"] = cloudbrain.Snn4imagenetMountPath
ctx.Data["is_snn4imagenet_enabled"] = setting.IsSnn4imagenetEnabled
ctx.HTML(200, tplCloudBrainNew)
}

@@ -320,6 +322,23 @@ func CloudBrainBenchmark(ctx *context.Context) {
ctx.Redirect(setting.BenchmarkServerHost)
}

func GetRate(ctx *context.Context) {
var jobID = ctx.Params(":jobid")
job, err := models.GetCloudbrainByJobID(jobID)
if err != nil {
ctx.ServerError("GetCloudbrainByJobID failed", err)
return
}

if job.JobType == string(models.JobTypeBenchmark) {
ctx.Redirect(setting.BenchmarkServerHost)
} else if job.JobType == string(models.JobTypeSnn4imagenet) {
ctx.Redirect(setting.Snn4imagenetServerHost)
} else {
log.Error("JobType error:", job.JobType)
}
}

func downloadCode(repo *models.Repository, codePath string) error {
if err := git.Clone(repo.RepoPath(), codePath, git.CloneRepoOptions{}); err != nil {
log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err)


+ 1
- 0
routers/routes/routes.go View File

@@ -911,6 +911,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Post("/stop", reqRepoCloudBrainWriter, repo.CloudBrainStop)
m.Post("/del", reqRepoCloudBrainWriter, repo.CloudBrainDel)
m.Get("/benchmark", reqRepoCloudBrainWriter, repo.CloudBrainBenchmark)
m.Get("/rate", reqRepoCloudBrainWriter, repo.GetRate)
})
m.Get("/create", reqRepoCloudBrainWriter, repo.CloudBrainNew)
m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateCloudBrainForm{}), repo.CloudBrainCreate)


+ 1
- 1
templates/repo/cloudbrain/index.tmpl View File

@@ -269,7 +269,7 @@
<!-- 评分 -->
<div class="one wide column">
<div class="ui text center clipboard">
<a class="title" onclick="stop(this)" href="{{if and (ne .Status "WAITING") (eq .JobType "BENCHMARK")}}{{$.Link}}/{{.JobID}}/benchmark{{else}}javascript:void(0);{{end}}" style="{{if and (ne .Status "WAITING") (eq .JobType "BENCHMARK")}}{{else}}color:#CCCCCC{{end}}">
<a class="title" onclick="stop(this)" href="{{if and (ne .Status "WAITING") (ne .JobType "DEBUG")}}{{$.Link}}/{{.JobID}}/rate{{else}}javascript:void(0);{{end}}" style="{{if and (ne .Status "WAITING") (ne .JobType "DEBUG")}}{{else}}color:#CCCCCC{{end}}">
<span class="fitted">评分</span>
</a>
</div>


+ 12
- 1
templates/repo/cloudbrain/new.tmpl View File

@@ -84,6 +84,10 @@
.inline.required.field.cloudbrain_benchmark {
display: none;
}

.inline.required.field.cloudbrain_snn4imagenet {
display: none;
}
</style>

<div id="mask">
@@ -112,7 +116,7 @@
<input name="job_name" id="cloudbrain_job_name" placeholder="任务名称" value="{{.job_name}}" tabindex="3" autofocus required maxlength="255">
</div>

<div class="inline required field" style="{{if .is_benchmark_enabled}}display:block;{{else}}display:none;{{end}}">
<div class="inline required field" style="{{if .is_benchmark_enabled}}display:block;{{else if .is_snn4imagenet_enabled}}display:block;{{else}}display:none;{{end}}">
<label>任务类型</label>
<select id="cloudbrain_job_type" class="ui search dropdown" placeholder="选择任务类型" style='width:385px' name="job_type">
<option name="job_type" value="DEBUG">DEBUG</option>
@@ -158,6 +162,10 @@
<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 cloudbrain_snn4imagenet">
<label>snn4imagenet脚本存放路径</label>
<input name="snn4imagenet_path" id="cloudbrain_snn4imagenet_path" value="{{.snn4imagenet_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>
@@ -196,8 +204,11 @@
$("#cloudbrain_job_type").change(function() {
if ($(this).val() == 'BENCHMARK') {
$(".cloudbrain_benchmark").show();
} else if ($(this).val() == 'SNN4IMAGENET') {
$(".cloudbrain_snn4imagenet").show();
} else {
$(".cloudbrain_benchmark").hide();
$(".cloudbrain_snn4imagenet").hide();
}
})
})

Loading…
Cancel
Save