From 124e1ab94e2105206bf2b51b78806357033b1f75 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 9 Jan 2023 15:25:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/cloudbrain.go | 6 +++--- services/cloudbrain/cloudbrainTask/notebook.go | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 85e3c36f8..52eea2b15 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -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 //引擎名称 diff --git a/services/cloudbrain/cloudbrainTask/notebook.go b/services/cloudbrain/cloudbrainTask/notebook.go index 8f91056e5..ff1a2100a 100644 --- a/services/cloudbrain/cloudbrainTask/notebook.go +++ b/services/cloudbrain/cloudbrainTask/notebook.go @@ -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) {