Browse Source

notebook restart

tags/v1.21.12.2^2
lewis 3 years ago
parent
commit
749e9443e3
3 changed files with 15 additions and 11 deletions
  1. +4
    -4
      routers/repo/cloudbrain.go
  2. +10
    -7
      routers/repo/modelarts.go
  3. +1
    -0
      templates/repo/debugjob/index.tmpl

+ 4
- 4
routers/repo/cloudbrain.go View File

@@ -268,19 +268,19 @@ func CloudBrainRestart(ctx *context.Context) {

if task.Status != string(models.JobStopped) && task.Status != string(models.JobSucceeded) && task.Status != string(models.JobFailed) {
log.Error("the job(%s) is not stopped", task.JobName, ctx.Data["MsgID"])
ctx.RenderWithErr("the job is not stopped", tplCloudBrainIndex, nil)
ctx.RenderWithErr("the job is not stopped", tplDebugJobIndex, nil)
return
}

count, err := models.GetCloudbrainCountByUserID(ctx.User.ID)
if err != nil {
log.Error("GetCloudbrainCountByUserID failed:%v", err, ctx.Data["MsgID"])
ctx.RenderWithErr("system error", tplCloudBrainIndex, nil)
ctx.RenderWithErr("system error", tplDebugJobIndex, nil)
return
} else {
if count >= 1 {
log.Error("the user already has running or waiting task", ctx.Data["MsgID"])
ctx.RenderWithErr("you have already a running or waiting task, can not create more", tplCloudBrainIndex, nil)
ctx.RenderWithErr("you have already a running or waiting task, can not create more", tplDebugJobIndex, nil)
return
}
}
@@ -288,7 +288,7 @@ func CloudBrainRestart(ctx *context.Context) {
err = cloudbrain.RestartTask(ctx, task)
if err != nil {
log.Error("RestartTask failed:%v", err.Error(), ctx.Data["MsgID"])
ctx.RenderWithErr(err.Error(), tplCloudBrainIndex, nil)
ctx.RenderWithErr(err.Error(), tplDebugJobIndex, nil)
return
}
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob")


+ 10
- 7
routers/repo/modelarts.go View File

@@ -238,19 +238,20 @@ func NotebookManage(ctx *context.Context) {

task, err := models.GetCloudbrainByJobID(jobID)
if err != nil {
ctx.ServerError("GetCloudbrainByJobID failed", err)
log.Error("GetCloudbrainByJobID failed:%v", err, ctx.Data["MsgID"])
ctx.RenderWithErr("system error", tplDebugJobIndex, nil)
return
}

if action == models.ActionStop {
if task.Status != string(models.ModelArtsRunning) {
log.Error("the job(%s) is not running", task.JobName)
log.Error("the job(%s) is not running", task.JobName, ctx.Data["MsgID"])
ctx.RenderWithErr("the job is not running", tplDebugJobIndex, nil)
return
}
} else if action == models.ActionRestart {
if task.Status != string(models.ModelArtsStopped) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsCreateFailed) {
log.Error("the job(%s) is not stopped", task.JobName)
log.Error("the job(%s) is not stopped", task.JobName, ctx.Data["MsgID"])
ctx.RenderWithErr("the job is not stopped", tplDebugJobIndex, nil)
return
}
@@ -267,8 +268,10 @@ func NotebookManage(ctx *context.Context) {
return
}
}

action = models.ActionStart
} else {
log.Error("the action(%s) is illegal", action)
log.Error("the action(%s) is illegal", action, ctx.Data["MsgID"])
ctx.RenderWithErr("非法操作", tplDebugJobIndex, nil)
return
}
@@ -278,7 +281,7 @@ func NotebookManage(ctx *context.Context) {
}
res, err := modelarts.ManageNotebook(jobID, param)
if err != nil {
log.Error("ManageNotebook(%s) failed:%v", task.JobName, err.Error())
log.Error("ManageNotebook(%s) failed:%v", task.JobName, err.Error(), ctx.Data["MsgID"])
ctx.RenderWithErr("启动失败", tplDebugJobIndex, nil)
return
}
@@ -286,11 +289,11 @@ func NotebookManage(ctx *context.Context) {
task.Status = res.CurrentStatus
err = models.UpdateJob(task)
if err != nil {
log.Error("UpdateJob(%s) failed:%v", task.JobName, err.Error())
log.Error("UpdateJob(%s) failed:%v", task.JobName, err.Error(), ctx.Data["MsgID"])
ctx.RenderWithErr("system error", tplDebugJobIndex, nil)
return
}
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob")
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=all")
}

func NotebookDel(ctx *context.Context) {


+ 1
- 0
templates/repo/debugjob/index.tmpl View File

@@ -207,6 +207,7 @@

<div class="repository release dataset-list view">
{{template "repo/header" .}}
{{template "base/alert" .}}
<!-- 列表容器 -->
<div class="ui container">
<div class="ui two column stackable grid ">


Loading…
Cancel
Save