Browse Source

add benchmark enabled

tags/v1.21.12.1
yuyuanshifu 4 years ago
parent
commit
299b02ef8b
4 changed files with 11 additions and 3 deletions
  1. +5
    -0
      models/cloudbrain.go
  2. +1
    -0
      modules/auth/cloudbrain.go
  3. +2
    -1
      modules/cloudbrain/cloudbrain.go
  4. +3
    -2
      routers/repo/cloudbrain.go

+ 5
- 0
models/cloudbrain.go View File

@@ -13,6 +13,7 @@ import (
)

type CloudbrainStatus string
type JobType string

const (
JobWaiting CloudbrainStatus = "WAITING"
@@ -20,11 +21,15 @@ const (
JobSucceeded CloudbrainStatus = "SUCCEEDED"
JobFailed CloudbrainStatus = "FAILED"
JobRunning CloudbrainStatus = "RUNNING"

JobTypeDebug JobType = "DEBUG"
JobTypeBenchmark JobType = "BENCHMARK"
)

type Cloudbrain struct {
ID int64 `xorm:"pk autoincr"`
JobID string `xorm:"INDEX NOT NULL"`
JobType string `xorm:"INDEX NOT NULL"`
JobName string `xorm:"INDEX"`
Status string `xorm:"INDEX"`
UserID int64 `xorm:"INDEX"`


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

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

type CommitImageCloudBrainForm struct {


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

@@ -22,7 +22,7 @@ const (
Success = "S000"
)

func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath string) error {
func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, jobType string) error {
dataActualPath := setting.Attachment.Minio.RealPath +
setting.Attachment.Minio.Bucket + "/" +
setting.Attachment.Minio.BasePath +
@@ -97,6 +97,7 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath,
JobID: jobID,
JobName: jobName,
SubTaskName: SubTaskName,
JobType: jobType,
})

if err != nil {


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

@@ -122,6 +122,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {
image := form.Image
command := form.Command
uuid := form.Attachment
jobType := form.JobType
codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath
repo := ctx.Repo.Repository
downloadCode(repo, codePath)
@@ -134,11 +135,11 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {
}

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

err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath)
err = cloudbrain.GenerateTask(ctx, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, jobType)
if err != nil {
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form)
return


Loading…
Cancel
Save