Browse Source

merge

tags/v1.21.12.1
Gitea 4 years ago
parent
commit
9c5cced462
9 changed files with 22 additions and 19 deletions
  1. +1
    -1
      models/attachment.go
  2. +2
    -1
      models/file_chunk.go
  3. +1
    -1
      modules/modelarts/modelarts.go
  4. +3
    -1
      routers/api/v1/api.go
  5. +1
    -1
      routers/repo/attachment.go
  6. +14
    -14
      routers/repo/modelarts.go
  7. +0
    -0
      templates/repo/modelarts/notebook/index.tmpl
  8. +0
    -0
      templates/repo/modelarts/notebook/new.tmpl
  9. +0
    -0
      templates/repo/modelarts/notebook/show.tmpl

+ 1
- 1
models/attachment.go View File

@@ -401,7 +401,7 @@ func GetAllUserAttachments(userID int64) ([]*AttachmentUsername, error) {
func getModelArtsUserAttachments(e Engine, userID int64) ([]*AttachmentUsername, error) {
attachments := make([]*AttachmentUsername, 0, 10)
if err := e.Table("attachment").Join("LEFT", "`user`", "attachment.uploader_id "+
"= `user`.id").Where("attachment.type = ? and (uploader_id= ? or is_private = ?)", TypeCloudBrainTwo, userID, false).Find(&attachments); err != nil {
"= `user`.id").Where("attachment.type = ? and (uploader_id= ? or is_private = ?)", TypeCloudBrainNotebook, userID, false).Find(&attachments); err != nil {
return nil, err
}
return attachments, nil


+ 2
- 1
models/file_chunk.go View File

@@ -12,7 +12,8 @@ const (

const (
TypeCloudBrainOne = 0
TypeCloudBrainTwo = 1
TypeCloudBrainNotebook = 1
TypeCloudBrainTrainJob = 2
)

type FileChunk struct {


+ 1
- 1
modules/modelarts/modelarts.go View File

@@ -54,7 +54,7 @@ func GenerateTask(ctx *context.Context, jobName, uuid, description string) error
JobID: jobResult.ID,
JobName: jobName,
JobType: string(models.JobTypeDebug),
Type: models.TypeCloudBrainTwo,
Type: models.TypeCloudBrainNotebook,
})

if err != nil {


+ 3
- 1
routers/api/v1/api.go View File

@@ -853,7 +853,9 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/:jobid", repo.GetCloudbrainTask)
}, reqRepoReader(models.UnitTypeCloudBrain))
m.Group("/modelarts", func() {
m.Get("/:jobid", repo.GetModelArtsTask)
m.Group("/notebook", func() {
m.Get("/:jobid", repo.GetModelArtsTask)
})
}, reqRepoReader(models.UnitTypeCloudBrain))
}, repoAssignment())
})


+ 1
- 1
routers/repo/attachment.go View File

@@ -845,7 +845,7 @@ func queryDatasets(ctx *context.Context, attachs []*models.AttachmentUsername) {
}

func checkTypeCloudBrain(typeCloudBrain int) error {
if typeCloudBrain != models.TypeCloudBrainOne && typeCloudBrain != models.TypeCloudBrainTwo {
if typeCloudBrain != models.TypeCloudBrainOne && typeCloudBrain != models.TypeCloudBrainNotebook {
log.Error("type error:", typeCloudBrain)
return errors.New("type error")
}


+ 14
- 14
routers/repo/modelarts.go View File

@@ -17,9 +17,9 @@ import (
)

const (
tplModelArtsIndex base.TplName = "repo/modelarts/index"
tplModelArtsNew base.TplName = "repo/modelarts/new"
tplModelArtsShow base.TplName = "repo/modelarts/show"
tplModelArtsNotebookIndex base.TplName = "repo/modelarts/notebook/index"
tplModelArtsNotebookNew base.TplName = "repo/modelarts/notebook/new"
tplModelArtsNotebookShow base.TplName = "repo/modelarts/notebook/show"
)

// MustEnableDataset check if repository enable internal cb
@@ -44,7 +44,7 @@ func NotebookIndex(ctx *context.Context) {
PageSize: setting.UI.IssuePagingNum,
},
RepoID: repo.ID,
Type: models.TypeCloudBrainTwo,
Type: models.TypeCloudBrainNotebook,
})
if err != nil {
ctx.ServerError("Cloudbrain", err)
@@ -65,7 +65,7 @@ func NotebookIndex(ctx *context.Context) {

ctx.Data["PageIsCloudBrain"] = true
ctx.Data["Tasks"] = ciTasks
ctx.HTML(200, tplModelArtsIndex)
ctx.HTML(200, tplModelArtsNotebookIndex)
}

func NotebookNew(ctx *context.Context) {
@@ -86,7 +86,7 @@ func NotebookNew(ctx *context.Context) {
ctx.Data["env"] = modelarts.NotebookEnv
ctx.Data["notebook_type"] = modelarts.NotebookType
ctx.Data["flavor"] = modelarts.FlavorInfo
ctx.HTML(200, tplModelArtsNew)
ctx.HTML(200, tplModelArtsNotebookNew)
}

func NotebookCreate(ctx *context.Context, form auth.CreateModelArtsForm) {
@@ -98,11 +98,11 @@ func NotebookCreate(ctx *context.Context, form auth.CreateModelArtsForm) {

err := modelarts.GenerateTask(ctx, jobName, uuid, description)
if err != nil {
ctx.RenderWithErr(err.Error(), tplModelArtsNew, &form)
ctx.RenderWithErr(err.Error(), tplModelArtsNotebookNew, &form)
return
}

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

func NotebookShow(ctx *context.Context) {
@@ -112,14 +112,14 @@ func NotebookShow(ctx *context.Context) {
task, err := models.GetCloudbrainByJobID(jobID)
if err != nil {
ctx.Data["error"] = err.Error()
ctx.RenderWithErr(err.Error(), tplModelArtsIndex, nil)
ctx.RenderWithErr(err.Error(), tplModelArtsNotebookIndex, nil)
return
}

result, err := modelarts.GetJob(jobID)
if err != nil {
ctx.Data["error"] = err.Error()
ctx.RenderWithErr(err.Error(), tplModelArtsIndex, nil)
ctx.RenderWithErr(err.Error(), tplModelArtsNotebookIndex, nil)
return
}

@@ -128,7 +128,7 @@ func NotebookShow(ctx *context.Context) {
err = models.UpdateJob(task)
if err != nil {
ctx.Data["error"] = err.Error()
ctx.RenderWithErr(err.Error(), tplModelArtsIndex, nil)
ctx.RenderWithErr(err.Error(), tplModelArtsNotebookIndex, nil)
return
}

@@ -143,7 +143,7 @@ func NotebookShow(ctx *context.Context) {
ctx.Data["task"] = task
ctx.Data["jobID"] = jobID
ctx.Data["result"] = result
ctx.HTML(200, tplModelArtsShow)
ctx.HTML(200, tplModelArtsNotebookShow)
}

func NotebookDebug(ctx *context.Context) {
@@ -156,13 +156,13 @@ func NotebookDebug(ctx *context.Context) {

result, err := modelarts.GetJob(jobID)
if err != nil {
ctx.RenderWithErr(err.Error(), tplModelArtsIndex, nil)
ctx.RenderWithErr(err.Error(), tplModelArtsNotebookIndex, nil)
return
}

res, err := modelarts.GetJobToken(jobID)
if err != nil {
ctx.RenderWithErr(err.Error(), tplModelArtsIndex, nil)
ctx.RenderWithErr(err.Error(), tplModelArtsNotebookIndex, nil)
return
}



templates/repo/modelarts/index.tmpl → templates/repo/modelarts/notebook/index.tmpl View File


templates/repo/modelarts/new.tmpl → templates/repo/modelarts/notebook/new.tmpl View File


templates/repo/modelarts/show.tmpl → templates/repo/modelarts/notebook/show.tmpl View File


Loading…
Cancel
Save