#3478 file-notebook-new,修改数据库字段长度,正常至少支持10个文件同时在同一个环境打开。

Merged
zouap merged 3 commits from file-notebook-new into V20221228 1 year ago
  1. +3
    -3
      models/cloudbrain.go
  2. +13
    -8
      services/cloudbrain/cloudbrainTask/notebook.go

+ 3
- 3
models/cloudbrain.go View File

@@ -180,14 +180,14 @@ type Cloudbrain struct {
AiCenter string //grampus ai center: center_id+center_name

TrainUrl string //输出模型的obs路径
BranchName string //分支名称
BranchName string `xorm:"varchar(2550)"` //分支名称
Parameters string //传给modelarts的param参数
BootFile string //启动文件
BootFile string `xorm:"varchar(2550)"` //启动文件
DataUrl string `xorm:"varchar(3500)"` //数据集的obs路径
LogUrl string //日志输出的obs路径
PreVersionId int64 //父版本的版本id
FlavorCode string //modelarts上的规格id
Description string `xorm:"varchar(256)"` //描述
Description string `xorm:"varchar(2550)"` //描述
WorkServerNumber int //节点数
FlavorName string //规格名称
EngineName string //引擎名称


+ 13
- 8
services/cloudbrain/cloudbrainTask/notebook.go View File

@@ -35,6 +35,7 @@ const NoteBookExtension = ".ipynb"
const CPUType = 0
const GPUType = 1
const NPUType = 2
const CharacterLength = 2550

func FileNotebookCreate(ctx *context.Context, option api.CreateFileNotebookJobOption) {

@@ -46,11 +47,11 @@ func FileNotebookCreate(ctx *context.Context, option api.CreateFileNotebookJobOp
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("repo.notebook_select_wrong")))
return
}
if len(getBootFile(option.File, option.OwnerName, option.ProjectName)) > 255 {
if len(getBootFile(option.File, option.OwnerName, option.ProjectName)) > CharacterLength {
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("repo.notebook_path_too_long")))
return
}
if len(option.BranchName) > 255 {
if len(option.BranchName) > CharacterLength {
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("repo.notebook_branch_name_too_long")))
return
}
@@ -120,20 +121,20 @@ func FileNotebookCreate(ctx *context.Context, option api.CreateFileNotebookJobOp
}
}
if !isRepoFileMatch(option, noteBook) {
if len(noteBook.BootFile)+len(getBootFile(option.File, option.OwnerName, option.ProjectName))+1 <= 255 {
if len(noteBook.BootFile)+len(getBootFile(option.File, option.OwnerName, option.ProjectName))+1 <= CharacterLength {
noteBook.BootFile += ";" + getBootFile(option.File, option.OwnerName, option.ProjectName)
} else {
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("cloudbrain.notebook_path_too_long")))
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("repo.notebook_path_too_long")))
return
}
if len(noteBook.BranchName)+len(option.BranchName)+1 <= 255 {
if len(noteBook.BranchName)+len(option.BranchName)+1 <= CharacterLength {
noteBook.BranchName += ";" + option.BranchName
} else {
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("cloudbrain.notebook_branch_name_too_long")))
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("repo.notebook_branch_name_too_long")))
return
}

if len(noteBook.Description)+len(getDescription(option))+1 <= 256 {
if len(noteBook.Description)+len(getDescription(option))+1 <= CharacterLength {
noteBook.Description += ";" + getDescription(option)
}

@@ -454,7 +455,11 @@ func getCodePath(jobName string, repo *models.Repository) string {
}

func getDescription(option api.CreateFileNotebookJobOption) string {
return option.OwnerName + "/" + option.ProjectName + "/" + option.File
des := option.OwnerName + "/" + option.ProjectName + "/" + option.File
if len(des) <= CharacterLength {
return des
}
return ""
}

func modelartsFileNoteBookCreate(ctx *context.Context, option api.CreateFileNotebookJobOption, repo *models.Repository, sourceRepo *models.Repository) {


Loading…
Cancel
Save