diff --git a/models/cloudbrain.go b/models/cloudbrain.go index ac69a8e37..e64fc8383 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -19,6 +19,9 @@ type JobType string type ModelArtsJobStatus string const ( + NPUResource = "NPU" + GPUResource = "CPU/GPU" + JobWaiting CloudbrainStatus = "WAITING" JobStopped CloudbrainStatus = "STOPPED" JobSucceeded CloudbrainStatus = "SUCCEEDED" @@ -105,7 +108,7 @@ type Cloudbrain struct { IsLatestVersion string //是否是最新版本,1是,0否 CommitID string //提交的仓库代码id PreVersionName string //父版本名称 - ComputeResource string `xorm:"-"` //计算资源,例如npu + ComputeResource string //计算资源,例如npu EngineID int64 //引擎id TrainUrl string //输出的obs路径 diff --git a/modules/cloudbrain/cloudbrain.go b/modules/cloudbrain/cloudbrain.go index aa5d8467c..b8aa2e143 100755 --- a/modules/cloudbrain/cloudbrain.go +++ b/modules/cloudbrain/cloudbrain.go @@ -212,6 +212,7 @@ func GenerateTask(ctx *context.Context, jobName, image, command, uuid, codePath, Image: image, GpuQueue: gpuQueue, ResourceSpecId: resourceSpecId, + ComputeResource: models.GPUResource, }) if err != nil { diff --git a/modules/modelarts/modelarts.go b/modules/modelarts/modelarts.go index 3dddbc10c..6a792d42d 100755 --- a/modules/modelarts/modelarts.go +++ b/modules/modelarts/modelarts.go @@ -48,10 +48,6 @@ const ( PerPage = 10 IsLatestVersion = "1" NotLatestVersion = "0" - // ComputeResource = "NPU" - NPUResource = "NPU" - GPUResource = "CPU/GPU" - AllResource = "all" DebugType = -1 VersionCount = 1 @@ -277,7 +273,7 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error DatasetName: attach.Name, CommitID: req.CommitID, IsLatestVersion: req.IsLatestVersion, - //ComputeResource: NPUResource, + ComputeResource: models.NPUResource, EngineID: req.EngineID, TrainUrl: req.TrainUrl, BranchName: req.BranchName, @@ -360,7 +356,7 @@ func GenerateTrainJobVersion(ctx *context.Context, req *GenerateTrainJobReq, job CommitID: req.CommitID, IsLatestVersion: req.IsLatestVersion, PreVersionName: req.PreVersionName, - ComputeResource: NPUResource, + ComputeResource: models.GPUResource, EngineID: req.EngineID, TrainUrl: req.TrainUrl, BranchName: req.BranchName, diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 5503c7b35..3c60396b6 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -245,7 +245,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { ctx.RenderWithErr(err.Error(), tplCloudBrainNew, &form) return } - ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob") + ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=all") } func CloudBrainRestart(ctx *context.Context) { @@ -568,7 +568,7 @@ func CloudBrainDel(ctx *context.Context) { } deleteJobStorage(task.JobName, models.TypeCloudBrainOne) - ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob") + ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=all") } func CloudBrainShowModels(ctx *context.Context) { diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index cb51c2b36..f916fc157 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -51,11 +51,11 @@ func DebugJobIndex(ctx *context.Context) { } debugType := modelarts.DebugType jobType := string(models.JobTypeDebug) - if debugListType == modelarts.GPUResource { + if debugListType == models.GPUResource { debugType = models.TypeCloudBrainOne jobType = "" } - if debugListType == modelarts.NPUResource { + if debugListType == models.NPUResource { debugType = models.TypeCloudBrainTwo } @@ -76,16 +76,10 @@ func DebugJobIndex(ctx *context.Context) { for i, task := range ciTasks { ciTasks[i].CanDebug = cloudbrain.CanCreateOrDebugJob(ctx) ciTasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain) - - if task.Cloudbrain.Type == models.TypeCloudBrainOne { - ciTasks[i].Cloudbrain.ComputeResource = modelarts.GPUResource - } else if task.Cloudbrain.Type == models.TypeCloudBrainTwo { - ciTasks[i].Cloudbrain.ComputeResource = modelarts.NPUResource - } + ciTasks[i].Cloudbrain.ComputeResource = task.ComputeResource } pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5) - //pager.SetDefaultParams(ctx) pager.AddParam(ctx, "debugListType", "ListType") ctx.Data["Page"] = pager ctx.Data["PageIsCloudBrain"] = true @@ -345,7 +339,7 @@ func NotebookDel(ctx *context.Context) { return } - ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob") + ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=all") } func TrainJobIndex(ctx *context.Context) { @@ -375,7 +369,7 @@ func TrainJobIndex(ctx *context.Context) { for i, task := range tasks { tasks[i].CanDel = cloudbrain.CanDeleteJob(ctx, &task.Cloudbrain) tasks[i].CanModify = cloudbrain.CanModifyJob(ctx, &task.Cloudbrain) - tasks[i].ComputeResource = modelarts.NPUResource + tasks[i].ComputeResource = models.NPUResource } pager := context.NewPagination(int(count), setting.UI.IssuePagingNum, page, 5) diff --git a/templates/repo/debugjob/index.tmpl b/templates/repo/debugjob/index.tmpl index 19c2e6a94..7aa4bfa25 100755 --- a/templates/repo/debugjob/index.tmpl +++ b/templates/repo/debugjob/index.tmpl @@ -568,9 +568,10 @@ $('#' + JobID+'-icon').removeClass().addClass(res.status) $('#' + JobID+ '-text').text(res.status) if(res.status==="STOPPED"){ - $('#model-debug-'+JobID).removeClass('blue').addClass('disabled').text("再次调试").css("margin","0") + $('#model-debug-'+JobID).removeClass('disabled').addClass('blue').text("再次调试").css("margin","0") $('#model-image-'+JobID).removeClass('blue').addClass('disabled') $('#stop-model-debug-'+JobID).removeClass('blue').addClass('disabled') + $('#model-delete-'+JobID).removeClass('disabled').addClass('blue') } else{ $('#model-debug-'+JobID).removeClass('blue').addClass('disabled')