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 CloudbrainStatus string
type JobType string


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

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


type Cloudbrain struct { type Cloudbrain struct {
ID int64 `xorm:"pk autoincr"` ID int64 `xorm:"pk autoincr"`
JobID string `xorm:"INDEX NOT NULL"` JobID string `xorm:"INDEX NOT NULL"`
JobType string `xorm:"INDEX NOT NULL"`
JobName string `xorm:"INDEX"` JobName string `xorm:"INDEX"`
Status string `xorm:"INDEX"` Status string `xorm:"INDEX"`
UserID int64 `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"` Image string `form:"image" binding:"Required"`
Command string `form:"command" binding:"Required"` Command string `form:"command" binding:"Required"`
Attachment string `form:"attachment" binding:"Required"` Attachment string `form:"attachment" binding:"Required"`
JobType string `form:"job_type" binding:"Required"`
} }


type CommitImageCloudBrainForm struct { type CommitImageCloudBrainForm struct {


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

@@ -22,7 +22,7 @@ const (
Success = "S000" 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 + dataActualPath := setting.Attachment.Minio.RealPath +
setting.Attachment.Minio.Bucket + "/" + setting.Attachment.Minio.Bucket + "/" +
setting.Attachment.Minio.BasePath + setting.Attachment.Minio.BasePath +
@@ -97,6 +97,7 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath,
JobID: jobID, JobID: jobID,
JobName: jobName, JobName: jobName,
SubTaskName: SubTaskName, SubTaskName: SubTaskName,
JobType: jobType,
}) })


if err != nil { 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 image := form.Image
command := form.Command command := form.Command
uuid := form.Attachment uuid := form.Attachment
jobType := form.JobType
codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath
repo := ctx.Repo.Repository repo := ctx.Repo.Repository
downloadCode(repo, codePath) downloadCode(repo, codePath)
@@ -134,11 +135,11 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {
} }


benchmarkPath := setting.JobPath + jobName + cloudbrain.BenchMarkMountPath benchmarkPath := setting.JobPath + jobName + cloudbrain.BenchMarkMountPath
if setting.IsBenchmarkEnabled {
if setting.IsBenchmarkEnabled && jobType == string(models.JobTypeBenchmark) {
downloadBenchmarkCode(repo, jobName, benchmarkPath) 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 { if err != nil {
ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form)
return return


Loading…
Cancel
Save