Browse Source

add snn4imagenet

tags/v1.21.12.1
yuyuanshifu 4 years ago
parent
commit
07dddac0f7
7 changed files with 39 additions and 10 deletions
  1. +5
    -0
      custom/conf/app.ini.sample
  2. +1
    -0
      models/cloudbrain.go
  3. +9
    -1
      modules/cloudbrain/cloudbrain.go
  4. +10
    -0
      modules/setting/setting.go
  5. +13
    -8
      routers/repo/cloudbrain.go
  6. +0
    -1
      routers/routes/routes.go
  7. +1
    -0
      templates/repo/cloudbrain/new.tmpl

+ 5
- 0
custom/conf/app.ini.sample View File

@@ -1061,6 +1061,11 @@ ENABLED = true
BENCHMARKCODE = https://yangzhx:justfortest123@git.openi.org.cn/yangzhx/detection_benchmark_script.git
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]
HOST = http://192.168.207.34:39987
USER = cW4cMtH24eoWPE7X


+ 1
- 0
models/cloudbrain.go View File

@@ -25,6 +25,7 @@ const (

JobTypeDebug JobType = "DEBUG"
JobTypeBenchmark JobType = "BENCHMARK"
JobTypeSnn4imagenet JobType = "SNN4IMAGENET"

ModelArtsCreateQueue ModelArtsJobStatus = "CREATE_QUEUING" //免费资源创建排队中
ModelArtsCreating ModelArtsJobStatus = "CREATING" //创建中


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

@@ -15,6 +15,7 @@ const (
DataSetMountPath = "/dataset"
ModelMountPath = "/model"
BenchMarkMountPath = "/benchmark"
Snn4imagenetMountPath = "/snn4imagenet"
TaskInfoName = "/taskInfo"

SubTaskName = "task1"
@@ -22,7 +23,7 @@ const (
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 +
setting.Attachment.Minio.Bucket + "/" +
setting.Attachment.Minio.BasePath +
@@ -78,6 +79,13 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath,
ReadOnly: true,
},
},
{
HostPath: models.StHostPath{
Path: snn4imagenetPath,
MountPath: Snn4imagenetMountPath,
ReadOnly: true,
},
},
},
})
if err != nil {


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

@@ -444,6 +444,11 @@ var (
BenchmarkCode string
BenchmarkServerHost string

//snn4imagenet config
IsSnn4imagenetEnabled bool
Snn4imagenetCode string
Snn4imagenetServerHost string

//blockchain config
BlockChainHost 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")
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")
BlockChainHost = sec.Key("HOST").MustString("http://192.168.136.66:3302/")
CommitValidDate = sec.Key("COMMIT_VALID_DATE").MustString("2021-01-15")


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

@@ -143,7 +143,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {
jobType := form.JobType
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)
ctx.RenderWithErr("jobtype error", tplCloudBrainNew, &form)
return
@@ -160,10 +160,15 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {

benchmarkPath := setting.JobPath + jobName + cloudbrain.BenchMarkMountPath
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 {
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form)
return
@@ -324,14 +329,14 @@ func downloadCode(repo *models.Repository, codePath string) error {
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 {
log.Error("mkdir benchmarkPath failed", err.Error())
log.Error("mkdir codePath failed", err.Error())
return err
}

command := "git clone " + setting.BenchmarkCode + " " + benchmarkPath
command := "git clone " + gitPath + " " + codePath
cmd := exec.Command("/bin/bash", "-c", command)
output, err := cmd.Output()
log.Info(string(output))
@@ -340,7 +345,7 @@ func downloadBenchmarkCode(repo *models.Repository, taskName string, benchmarkPa
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)
if err != nil {
log.Error("OpenFile failed", err.Error())


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

@@ -529,7 +529,6 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/get_multipart_url", repo.GetMultipartUploadUrl)
m.Post("/complete_multipart", repo.CompleteMultipart)
m.Post("/update_chunk", repo.UpdateMultipart)
m.Get("/get_obs_key", repo.GetObsKey)
}, reqSignIn)

m.Group("/attachments", func() {


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

@@ -117,6 +117,7 @@
<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="BENCHMARK">BENCHMARK</option>
<option name="job_type" value="SNN4IMAGENET">SNN4IMAGENET</option>
</select>
</div>



Loading…
Cancel
Save