Browse Source

add notebook route

tags/v1.21.12.1
lewis 4 years ago
parent
commit
6728e51cae
4 changed files with 35 additions and 20 deletions
  1. +10
    -9
      routers/repo/modelarts.go
  2. +22
    -8
      routers/routes/routes.go
  3. +1
    -1
      templates/repo/header.tmpl
  4. +2
    -2
      templates/repo/modelarts/index.tmpl

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

@@ -29,7 +29,8 @@ func MustEnableModelArts(ctx *context.Context) {
return
}
}
func ModelArtsIndex(ctx *context.Context) {

func NotebookIndex(ctx *context.Context) {
MustEnableModelArts(ctx)
repo := ctx.Repo.Repository
page := ctx.QueryInt("page")
@@ -67,7 +68,7 @@ func ModelArtsIndex(ctx *context.Context) {
ctx.HTML(200, tplModelArtsIndex)
}

func ModelArtsNew(ctx *context.Context) {
func NotebookNew(ctx *context.Context) {
ctx.Data["PageIsCloudBrain"] = true

t := time.Now()
@@ -88,7 +89,7 @@ func ModelArtsNew(ctx *context.Context) {
ctx.HTML(200, tplModelArtsNew)
}

func ModelArtsCreate(ctx *context.Context, form auth.CreateModelArtsForm) {
func NotebookCreate(ctx *context.Context, form auth.CreateModelArtsForm) {
ctx.Data["PageIsCloudBrain"] = true
jobName := form.JobName
uuid := form.Attachment
@@ -104,7 +105,7 @@ func ModelArtsCreate(ctx *context.Context, form auth.CreateModelArtsForm) {
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts")
}

func ModelArtsShow(ctx *context.Context) {
func NotebookShow(ctx *context.Context) {
ctx.Data["PageIsCloudBrain"] = true

var jobID = ctx.Params(":jobid")
@@ -145,7 +146,7 @@ func ModelArtsShow(ctx *context.Context) {
ctx.HTML(200, tplModelArtsShow)
}

func ModelArtsDebug(ctx *context.Context) {
func NotebookDebug(ctx *context.Context) {
var jobID = ctx.Params(":jobid")
_, err := models.GetCloudbrainByJobID(jobID)
if err != nil {
@@ -180,7 +181,7 @@ func ModelArtsDebug(ctx *context.Context) {
ctx.Redirect(debugUrl)
}

func ModelArtsStop(ctx *context.Context) {
func NotebookStop(ctx *context.Context) {
var jobID = ctx.Params(":jobid")
log.Info(jobID)
task, err := models.GetCloudbrainByJobID(jobID)
@@ -212,10 +213,10 @@ func ModelArtsStop(ctx *context.Context) {
return
}

ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts")
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts/notebook")
}

func ModelArtsDel(ctx *context.Context) {
func NotebookDel(ctx *context.Context) {
var jobID = ctx.Params(":jobid")
task, err := models.GetCloudbrainByJobID(jobID)
if err != nil {
@@ -242,6 +243,6 @@ func ModelArtsDel(ctx *context.Context) {
return
}

ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts")
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts/notebook")
}


+ 22
- 8
routers/routes/routes.go View File

@@ -917,15 +917,29 @@ func RegisterRoutes(m *macaron.Macaron) {
}, context.RepoRef())

m.Group("/modelarts", func() {
m.Get("", reqRepoCloudBrainReader, repo.ModelArtsIndex)
m.Group("/:jobid", func() {
m.Get("", reqRepoCloudBrainReader, repo.ModelArtsShow)
m.Get("/debug", reqRepoCloudBrainReader, repo.ModelArtsDebug)
m.Post("/stop", reqRepoCloudBrainWriter, repo.ModelArtsStop)
m.Post("/del", reqRepoCloudBrainWriter, repo.ModelArtsDel)
m.Group("/notebook", func() {
m.Get("", reqRepoCloudBrainReader, repo.NotebookIndex)
m.Group("/:jobid", func() {
m.Get("", reqRepoCloudBrainReader, repo.NotebookShow)
m.Get("/debug", reqRepoCloudBrainReader, repo.NotebookDebug)
m.Post("/stop", reqRepoCloudBrainWriter, repo.NotebookStop)
m.Post("/del", reqRepoCloudBrainWriter, repo.NotebookDel)
})
m.Get("/create", reqRepoCloudBrainWriter, repo.NotebookNew)
m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateModelArtsForm{}), repo.NotebookCreate)
})

m.Group("/train-job", func() {
m.Get("", reqRepoCloudBrainReader, repo.NotebookIndex)
m.Group("/:jobid", func() {
m.Get("", reqRepoCloudBrainReader, repo.NotebookShow)
m.Get("/debug", reqRepoCloudBrainReader, repo.NotebookDebug)
m.Post("/stop", reqRepoCloudBrainWriter, repo.NotebookStop)
m.Post("/del", reqRepoCloudBrainWriter, repo.NotebookDel)
})
m.Get("/create", reqRepoCloudBrainWriter, repo.NotebookNew)
m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateModelArtsForm{}), repo.NotebookCreate)
})
m.Get("/create", reqRepoCloudBrainWriter, repo.ModelArtsNew)
m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateModelArtsForm{}), repo.ModelArtsCreate)
}, context.RepoRef())

m.Group("/blockchain", func() {


+ 1
- 1
templates/repo/header.tmpl View File

@@ -217,7 +217,7 @@
if(checked_radio=='0'){
window.location.href = repolink+'/cloudbrain'
}else if(checked_radio=='1'){
window.location.href = repolink+'/modelarts'
window.location.href = repolink+'/modelarts/notebook'
}else{
return;
}


+ 2
- 2
templates/repo/modelarts/index.tmpl View File

@@ -206,7 +206,7 @@

<div class="column right aligned">
{{if .Permission.CanWrite $.UnitTypeCloudBrain}}
<a class="ui green button" href="{{.RepoLink}}/modelarts/create">{{.i18n.Tr "repo.cloudbrain.new"}}</a> {{end}}
<a class="ui green button" href="{{.RepoLink}}/modelarts/notebook/create">{{.i18n.Tr "repo.cloudbrain.new"}}</a> {{end}}
</div>
</div>

@@ -417,7 +417,7 @@
return
}

$.get(`/api/v1/repos/${repoPath}/modelarts/${jobID}`, (data) => {
$.get(`/api/v1/repos/${repoPath}/modelarts/notebook/${jobID}`, (data) => {
const jobID = data.JobID
const status = data.JobStatus
$('#' + jobID).text(status)


Loading…
Cancel
Save