Reviewed-by: 史梦园 <1729788216@qq.com>master
@@ -1061,6 +1061,11 @@ ENABLED = true | |||||
BENCHMARKCODE = https://yangzhx:justfortest123@git.openi.org.cn/yangzhx/detection_benchmark_script.git | BENCHMARKCODE = https://yangzhx:justfortest123@git.openi.org.cn/yangzhx/detection_benchmark_script.git | ||||
HOST = http://192.168.202.90:3366/ | HOST = http://192.168.202.90:3366/ | ||||
[snn4imagenet] | |||||
ENABLED = true | |||||
SNN4IMAGENETCODE = https://yult:eh2Ten4iLYjFkbj@git.openi.org.cn/ylt/snn4imagenet.git | |||||
HOST = http://192.168.202.90:3366/ | |||||
[decompress] | [decompress] | ||||
HOST = http://192.168.207.34:39987 | HOST = http://192.168.207.34:39987 | ||||
USER = cW4cMtH24eoWPE7X | USER = cW4cMtH24eoWPE7X | ||||
@@ -25,6 +25,7 @@ const ( | |||||
JobTypeDebug JobType = "DEBUG" | JobTypeDebug JobType = "DEBUG" | ||||
JobTypeBenchmark JobType = "BENCHMARK" | JobTypeBenchmark JobType = "BENCHMARK" | ||||
JobTypeSnn4imagenet JobType = "SNN4IMAGENET" | |||||
ModelArtsCreateQueue ModelArtsJobStatus = "CREATE_QUEUING" //免费资源创建排队中 | ModelArtsCreateQueue ModelArtsJobStatus = "CREATE_QUEUING" //免费资源创建排队中 | ||||
ModelArtsCreating ModelArtsJobStatus = "CREATING" //创建中 | ModelArtsCreating ModelArtsJobStatus = "CREATING" //创建中 | ||||
@@ -15,6 +15,7 @@ const ( | |||||
DataSetMountPath = "/dataset" | DataSetMountPath = "/dataset" | ||||
ModelMountPath = "/model" | ModelMountPath = "/model" | ||||
BenchMarkMountPath = "/benchmark" | BenchMarkMountPath = "/benchmark" | ||||
Snn4imagenetMountPath = "/snn4imagenet" | |||||
TaskInfoName = "/taskInfo" | TaskInfoName = "/taskInfo" | ||||
SubTaskName = "task1" | SubTaskName = "task1" | ||||
@@ -22,7 +23,7 @@ const ( | |||||
Success = "S000" | Success = "S000" | ||||
) | ) | ||||
func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, jobType string) error { | |||||
func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, jobType string) error { | |||||
dataActualPath := setting.Attachment.Minio.RealPath + | dataActualPath := setting.Attachment.Minio.RealPath + | ||||
setting.Attachment.Minio.Bucket + "/" + | setting.Attachment.Minio.Bucket + "/" + | ||||
setting.Attachment.Minio.BasePath + | setting.Attachment.Minio.BasePath + | ||||
@@ -78,6 +79,13 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, | |||||
ReadOnly: true, | ReadOnly: true, | ||||
}, | }, | ||||
}, | }, | ||||
{ | |||||
HostPath: models.StHostPath{ | |||||
Path: snn4imagenetPath, | |||||
MountPath: Snn4imagenetMountPath, | |||||
ReadOnly: true, | |||||
}, | |||||
}, | |||||
}, | }, | ||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
@@ -444,6 +444,11 @@ var ( | |||||
BenchmarkCode string | BenchmarkCode string | ||||
BenchmarkServerHost string | BenchmarkServerHost string | ||||
//snn4imagenet config | |||||
IsSnn4imagenetEnabled bool | |||||
Snn4imagenetCode string | |||||
Snn4imagenetServerHost string | |||||
//blockchain config | //blockchain config | ||||
BlockChainHost string | BlockChainHost string | ||||
CommitValidDate string | CommitValidDate string | ||||
@@ -1146,6 +1151,11 @@ func NewContext() { | |||||
BenchmarkCode = sec.Key("BENCHMARKCODE").MustString("https://yangzhx:justfortest123@git.openi.org.cn/yangzhx/detection_benchmark_script.git") | 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/") | BenchmarkServerHost = sec.Key("HOST").MustString("http://192.168.202.90:3366/") | ||||
sec = Cfg.Section("snn4imagenet") | |||||
IsSnn4imagenetEnabled = sec.Key("ENABLED").MustBool(false) | |||||
Snn4imagenetCode = sec.Key("SNN4IMAGENETCODE").MustString("https://yangzhx:justfortest123@git.openi.org.cn/yangzhx/detection_benchmark_script.git") | |||||
Snn4imagenetServerHost = sec.Key("HOST").MustString("http://192.168.202.90:3366/") | |||||
sec = Cfg.Section("blockchain") | sec = Cfg.Section("blockchain") | ||||
BlockChainHost = sec.Key("HOST").MustString("http://192.168.136.66:3302/") | BlockChainHost = sec.Key("HOST").MustString("http://192.168.136.66:3302/") | ||||
CommitValidDate = sec.Key("COMMIT_VALID_DATE").MustString("2021-01-15") | CommitValidDate = sec.Key("COMMIT_VALID_DATE").MustString("2021-01-15") | ||||
@@ -131,6 +131,8 @@ func CloudBrainNew(ctx *context.Context) { | |||||
ctx.Data["model_path"] = cloudbrain.ModelMountPath | ctx.Data["model_path"] = cloudbrain.ModelMountPath | ||||
ctx.Data["benchmark_path"] = cloudbrain.BenchMarkMountPath | ctx.Data["benchmark_path"] = cloudbrain.BenchMarkMountPath | ||||
ctx.Data["is_benchmark_enabled"] = setting.IsBenchmarkEnabled | ctx.Data["is_benchmark_enabled"] = setting.IsBenchmarkEnabled | ||||
ctx.Data["snn4imagenet_path"] = cloudbrain.Snn4imagenetMountPath | |||||
ctx.Data["is_snn4imagenet_enabled"] = setting.IsSnn4imagenetEnabled | |||||
ctx.HTML(200, tplCloudBrainNew) | ctx.HTML(200, tplCloudBrainNew) | ||||
} | } | ||||
@@ -143,7 +145,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { | |||||
jobType := form.JobType | jobType := form.JobType | ||||
codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath | 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) | log.Error("jobtype error:", jobType) | ||||
ctx.RenderWithErr("jobtype error", tplCloudBrainNew, &form) | ctx.RenderWithErr("jobtype error", tplCloudBrainNew, &form) | ||||
return | return | ||||
@@ -160,10 +162,15 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { | |||||
benchmarkPath := setting.JobPath + jobName + cloudbrain.BenchMarkMountPath | benchmarkPath := setting.JobPath + jobName + cloudbrain.BenchMarkMountPath | ||||
if setting.IsBenchmarkEnabled && jobType == string(models.JobTypeBenchmark) { | 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 { | if err != nil { | ||||
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) | ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) | ||||
return | return | ||||
@@ -304,15 +311,21 @@ func CloudBrainDel(ctx *context.Context) { | |||||
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain") | ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain") | ||||
} | } | ||||
func CloudBrainBenchmark(ctx *context.Context) { | |||||
func GetRate(ctx *context.Context) { | |||||
var jobID = ctx.Params(":jobid") | var jobID = ctx.Params(":jobid") | ||||
_, err := models.GetCloudbrainByJobID(jobID) | |||||
job, err := models.GetCloudbrainByJobID(jobID) | |||||
if err != nil { | if err != nil { | ||||
ctx.ServerError("GetCloudbrainByJobID failed", err) | ctx.ServerError("GetCloudbrainByJobID failed", err) | ||||
return | return | ||||
} | } | ||||
ctx.Redirect(setting.BenchmarkServerHost) | |||||
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 { | func downloadCode(repo *models.Repository, codePath string) error { | ||||
@@ -324,14 +337,14 @@ func downloadCode(repo *models.Repository, codePath string) error { | |||||
return nil | 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 { | if err != nil { | ||||
log.Error("mkdir benchmarkPath failed", err.Error()) | |||||
log.Error("mkdir codePath failed", err.Error()) | |||||
return err | return err | ||||
} | } | ||||
command := "git clone " + setting.BenchmarkCode + " " + benchmarkPath | |||||
command := "git clone " + gitPath + " " + codePath | |||||
cmd := exec.Command("/bin/bash", "-c", command) | cmd := exec.Command("/bin/bash", "-c", command) | ||||
output, err := cmd.Output() | output, err := cmd.Output() | ||||
log.Info(string(output)) | log.Info(string(output)) | ||||
@@ -340,7 +353,7 @@ func downloadBenchmarkCode(repo *models.Repository, taskName string, benchmarkPa | |||||
return err | 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) | f, err := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) | ||||
if err != nil { | if err != nil { | ||||
log.Error("OpenFile failed", err.Error()) | log.Error("OpenFile failed", err.Error()) | ||||
@@ -532,7 +532,6 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
m.Get("/get_multipart_url", repo.GetMultipartUploadUrl) | m.Get("/get_multipart_url", repo.GetMultipartUploadUrl) | ||||
m.Post("/complete_multipart", repo.CompleteMultipart) | m.Post("/complete_multipart", repo.CompleteMultipart) | ||||
m.Post("/update_chunk", repo.UpdateMultipart) | m.Post("/update_chunk", repo.UpdateMultipart) | ||||
m.Get("/get_obs_key", repo.GetObsKey) | |||||
}, reqSignIn) | }, reqSignIn) | ||||
m.Group("/attachments", func() { | m.Group("/attachments", func() { | ||||
@@ -911,7 +910,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
m.Post("/commit_image", reqRepoCloudBrainWriter, bindIgnErr(auth.CommitImageCloudBrainForm{}), repo.CloudBrainCommitImage) | m.Post("/commit_image", reqRepoCloudBrainWriter, bindIgnErr(auth.CommitImageCloudBrainForm{}), repo.CloudBrainCommitImage) | ||||
m.Post("/stop", reqRepoCloudBrainWriter, repo.CloudBrainStop) | m.Post("/stop", reqRepoCloudBrainWriter, repo.CloudBrainStop) | ||||
m.Post("/del", reqRepoCloudBrainWriter, repo.CloudBrainDel) | 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.Get("/create", reqRepoCloudBrainWriter, repo.CloudBrainNew) | ||||
m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateCloudBrainForm{}), repo.CloudBrainCreate) | m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateCloudBrainForm{}), repo.CloudBrainCreate) | ||||
@@ -269,7 +269,7 @@ | |||||
<!-- 评分 --> | <!-- 评分 --> | ||||
<div class="one wide column"> | <div class="one wide column"> | ||||
<div class="ui text center clipboard"> | <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> | <span class="fitted">评分</span> | ||||
</a> | </a> | ||||
</div> | </div> | ||||
@@ -84,6 +84,10 @@ | |||||
.inline.required.field.cloudbrain_benchmark { | .inline.required.field.cloudbrain_benchmark { | ||||
display: none; | display: none; | ||||
} | } | ||||
.inline.required.field.cloudbrain_snn4imagenet { | |||||
display: none; | |||||
} | |||||
</style> | </style> | ||||
<div id="mask"> | <div id="mask"> | ||||
@@ -112,11 +116,12 @@ | |||||
<input name="job_name" id="cloudbrain_job_name" placeholder="任务名称" value="{{.job_name}}" tabindex="3" autofocus required maxlength="255"> | <input name="job_name" id="cloudbrain_job_name" placeholder="任务名称" value="{{.job_name}}" tabindex="3" autofocus required maxlength="255"> | ||||
</div> | </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> | <label>任务类型</label> | ||||
<select id="cloudbrain_job_type" class="ui search dropdown" placeholder="选择任务类型" style='width:385px' name="job_type"> | <select id="cloudbrain_job_type" class="ui search dropdown" placeholder="选择任务类型" style='width:385px' name="job_type"> | ||||
<option name="job_type" value="DEBUG">DEBUG</option> | <option name="job_type" value="DEBUG">DEBUG</option> | ||||
<option name="job_type" value="BENCHMARK">BENCHMARK</option> | <option name="job_type" value="BENCHMARK">BENCHMARK</option> | ||||
<option name="job_type" value="SNN4IMAGENET">SNN4IMAGENET</option> | |||||
</select> | </select> | ||||
</div> | </div> | ||||
@@ -157,6 +162,10 @@ | |||||
<label>benchmark脚本存放路径</label> | <label>benchmark脚本存放路径</label> | ||||
<input name="benchmark_path" id="cloudbrain_benchmark_path" value="{{.benchmark_path}}" tabindex="3" autofocus required maxlength="255" readonly="readonly"> | <input name="benchmark_path" id="cloudbrain_benchmark_path" value="{{.benchmark_path}}" tabindex="3" autofocus required maxlength="255" readonly="readonly"> | ||||
</div> | </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> | <div class="inline required field" hidden> | ||||
<label>启动命令</label> | <label>启动命令</label> | ||||
<textarea name="command" rows="10" readonly="readonly">{{.command}}</textarea> | <textarea name="command" rows="10" readonly="readonly">{{.command}}</textarea> | ||||
@@ -195,8 +204,11 @@ | |||||
$("#cloudbrain_job_type").change(function() { | $("#cloudbrain_job_type").change(function() { | ||||
if ($(this).val() == 'BENCHMARK') { | if ($(this).val() == 'BENCHMARK') { | ||||
$(".cloudbrain_benchmark").show(); | $(".cloudbrain_benchmark").show(); | ||||
} else if ($(this).val() == 'SNN4IMAGENET') { | |||||
$(".cloudbrain_snn4imagenet").show(); | |||||
} else { | } else { | ||||
$(".cloudbrain_benchmark").hide(); | $(".cloudbrain_benchmark").hide(); | ||||
$(".cloudbrain_snn4imagenet").hide(); | |||||
} | } | ||||
}) | }) | ||||
}) | }) |