Browse Source

fix-bug

tags/V1.22.3.1^2
liuzx 3 years ago
parent
commit
c8b027e582
2 changed files with 27 additions and 57 deletions
  1. +10
    -29
      routers/repo/cloudbrain.go
  2. +17
    -28
      routers/repo/modelarts.go

+ 10
- 29
routers/repo/cloudbrain.go View File

@@ -189,13 +189,11 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) {

tasks, err := models.GetCloudbrainsByDisplayJobName(repo.ID, string(models.JobTypeDebug), displayJobName)
if err == nil {
for _, task := range tasks {
if strings.EqualFold(task.DisplayJobName, displayJobName) {
log.Error("the job name did already exist", ctx.Data["MsgID"])
cloudBrainNewDataPrepare(ctx)
ctx.RenderWithErr("the job name did already exist", tplCloudBrainNew, &form)
return
}
if len(tasks) != 0 {
log.Error("the job name did already exist", ctx.Data["MsgID"])
cloudBrainNewDataPrepare(ctx)
ctx.RenderWithErr("the job name did already exist", tplCloudBrainNew, &form)
return
}
} else {
if !models.IsErrJobNotExist(err) {
@@ -483,7 +481,6 @@ func CloudBrainStop(ctx *context.Context) {
}

err := cloudbrain.StopJob(task.JobID)
// err := cloudbrain.StopJob("bbb60ea009a9b011ec08bb20f3128d160513")
if err != nil {
log.Error("StopJob(%s) failed:%v", task.JobName, err, ctx.Data["msgID"])
resultCode = "-1"
@@ -1247,13 +1244,11 @@ func CloudBrainBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainF

tasks, err := models.GetCloudbrainsByDisplayJobName(repo.ID, string(models.JobTypeBenchmark), displayJobName)
if err == nil {
for _, task := range tasks {
if strings.EqualFold(task.DisplayJobName, displayJobName) {
log.Error("the job name did already exist", ctx.Data["MsgID"])
cloudBrainNewDataPrepare(ctx)
ctx.RenderWithErr("the job name did already exist", tplCloudBrainBenchmarkNew, &form)
return
}
if len(tasks) != 0 {
log.Error("the job name did already exist", ctx.Data["MsgID"])
cloudBrainNewDataPrepare(ctx)
ctx.RenderWithErr("the job name did already exist", tplCloudBrainBenchmarkNew, &form)
return
}
} else {
if !models.IsErrJobNotExist(err) {
@@ -1309,20 +1304,6 @@ func CloudBrainBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainF
}
}

// _, err = models.GetCloudbrainByName(jobName)
// if err == nil {
// log.Error("the job name did already exist", ctx.Data["MsgID"])
// cloudBrainNewDataPrepare(ctx)
// ctx.RenderWithErr("the job name did already exist", tplCloudBrainBenchmarkNew, &form)
// return
// } else {
// if !models.IsErrJobNotExist(err) {
// log.Error("GetCloudbrainByName failed, %v", err, ctx.Data["MsgID"])
// cloudBrainNewDataPrepare(ctx)
// ctx.RenderWithErr("system error", tplCloudBrainBenchmarkNew, &form)
// return
// }
// }
os.RemoveAll(codePath)
if err := downloadCode(repo, codePath); err != nil {
log.Error("downloadCode failed, %v", err, ctx.Data["MsgID"])


+ 17
- 28
routers/repo/modelarts.go View File

@@ -329,14 +329,15 @@ func NotebookManage(ctx *context.Context) {
var resultCode = "0"
var errorMsg = ""
var status = ""
task, err := models.GetCloudbrainByID(ID)
if err != nil {
log.Error("get task(%s) failed:%v", task.JobName, err.Error(), ctx.Data["MsgID"])
resultCode = "-1"
errorMsg = "system error"
}

for {
task, err := models.GetCloudbrainByID(ID)
if err != nil {
log.Error("get task(%s) failed:%v", task.JobName, err.Error(), ctx.Data["MsgID"])
resultCode = "-1"
errorMsg = "system error"
break
}

if action == models.ActionStop {
if task.Status != string(models.ModelArtsRunning) {
@@ -572,8 +573,6 @@ func trainJobNewDataPrepare(ctx *context.Context) error {
}
ctx.Data["flavor_infos"] = flavorInfos.Info

// outputObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.OutputPath
// ctx.Data["train_url"] = outputObsPath
ctx.Data["params"] = ""
ctx.Data["branchName"] = ctx.Repo.BranchName

@@ -641,9 +640,6 @@ func trainJobErrorNewDataPrepare(ctx *context.Context, form auth.CreateModelArts
}
ctx.Data["flavor_infos"] = flavorInfos.Info

// outputObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.OutputPath
// ctx.Data["train_url"] = outputObsPath

configList, err := getConfigList(modelarts.PerPage, 1, modelarts.SortByCreateTime, "desc", "", modelarts.ConfigTypeCustom)
if err != nil {
ctx.ServerError("getConfigList failed:", err)
@@ -735,9 +731,6 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error {
}
ctx.Data["params"] = Parameters.Parameter

// outputObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.OutputPath
// ctx.Data["train_url"] = outputObsPath

branches, _, err := ctx.Repo.GitRepo.GetBranches(0, 0)
if err != nil {
ctx.ServerError("GetBranches error:", err)
@@ -905,13 +898,11 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm)
//Determine whether the task name of the task in the project is duplicated
tasks, err := models.GetCloudbrainsByDisplayJobName(repo.ID, string(models.JobTypeTrain), displayJobName)
if err == nil {
for _, task := range tasks {
if strings.EqualFold(task.DisplayJobName, displayJobName) {
log.Error("the job name did already exist", ctx.Data["MsgID"])
trainJobErrorNewDataPrepare(ctx, form)
ctx.RenderWithErr("the job name did already exist", tplModelArtsTrainJobNew, &form)
return
}
if len(tasks) != 0 {
log.Error("the job name did already exist", ctx.Data["MsgID"])
trainJobErrorNewDataPrepare(ctx, form)
ctx.RenderWithErr("the job name did already exist", tplModelArtsTrainJobNew, &form)
return
}
} else {
if !models.IsErrJobNotExist(err) {
@@ -1738,13 +1729,11 @@ func InferenceJobCreate(ctx *context.Context, form auth.CreateModelArtsInference
//Determine whether the task name of the task in the project is duplicated
tasks, err := models.GetCloudbrainsByDisplayJobName(repo.ID, string(models.JobTypeInference), displayJobName)
if err == nil {
for _, task := range tasks {
if strings.EqualFold(task.DisplayJobName, displayJobName) {
log.Error("the job name did already exist", ctx.Data["MsgID"])
inferenceJobErrorNewDataPrepare(ctx, form)
ctx.RenderWithErr("the job name did already exist", tplModelArtsInferenceJobNew, &form)
return
}
if len(tasks) != 0 {
log.Error("the job name did already exist", ctx.Data["MsgID"])
inferenceJobErrorNewDataPrepare(ctx, form)
ctx.RenderWithErr("the job name did already exist", tplModelArtsInferenceJobNew, &form)
return
}
} else {
if !models.IsErrJobNotExist(err) {


Loading…
Cancel
Save