#3783 fix-3781,branch名称含notebook文件夹不支持的字符直接提示不支持

Merged
zouap merged 3 commits from fix-3693 into V20230307 1 year ago
  1. +1
    -1
      options/locale/locale_en-US.ini
  2. +1
    -1
      options/locale/locale_zh-CN.ini
  3. +17
    -0
      services/cloudbrain/cloudbrainTask/notebook.go

+ 1
- 1
options/locale/locale_en-US.ini View File

@@ -1066,7 +1066,7 @@ notebook_select_wrong=Please select a Notebook(.ipynb) file first.
notebook_path_too_long=The total length of selected file or files path exceed 255 characters, please select a shorter path file or change the file path.
notebook_branch_name_too_long=The total length of branch or branches name exceed 255 characters, please select a file in other branch.
notebook_file_no_right=You have no right to access the Notebook(.ipynb) file.
notebook_repo_conflict=The files in different branches of the same repository can not run together.
notebook_branch_name_not_support=The branch name contains < > ' " ; \ ` = # $ % ^ ( ), can not run online.
debug_again_fail=Fail to restart debug task, please try again later.
debug_again_fail_forever=The task was scheduled failed last time, can not restart.



+ 1
- 1
options/locale/locale_zh-CN.ini View File

@@ -1065,7 +1065,7 @@ notebook_select_wrong=请先选择Notebook(.ipynb)文件。
notebook_path_too_long=选择的一个或多个Notebook文件路径总长度超过255个字符,请选择路径较短的文件或调整文件路径。
notebook_branch_name_too_long=选择的一个或多个Notebook文件分支名总长度超过255个字符,请选择其他分支的文件。
notebook_file_no_right=您没有这个Notebook文件的读权限。
notebook_repo_conflict=同一个仓库的不同分支文件不能同时运行。
notebook_branch_name_not_support=分支名包含< > ' " ; \ ` = # $ % ^ ( )字符,不支持在线运行。
debug_again_fail=再次调试失败,请稍后再试。
debug_again_fail_forever=这个任务之前没有调度成功,不能再次调试。



+ 17
- 0
services/cloudbrain/cloudbrainTask/notebook.go View File

@@ -48,6 +48,8 @@ const GPUType = 1
const NPUType = 2
const CharacterLength = 2550

var notebookDirInvalidChar = []string{"<", ">", "'", "\"", ";", "\\", "`", "=", "#", "$", "%", "^", "(", ")"}

func GrampusNotebookCreate(ctx *context.Context, option api.CreateNotebookOption) {
displayJobName := option.DisplayJobName
jobName := util.ConvertDisplayJobNameToJobName(displayJobName)
@@ -286,6 +288,10 @@ func FileNotebookCreate(ctx *context.Context, option api.CreateFileNotebookJobOp
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("repo.notebook_branch_name_too_long")))
return
}
if branchNameContainsNotebookInvalidChar(option.BranchName) {
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi(ctx.Tr("repo.notebook_branch_name_not_support")))
return
}

var imageIdNpu string
var err error
@@ -400,6 +406,17 @@ func FileNotebookCreate(ctx *context.Context, option api.CreateFileNotebookJobOp

}

func branchNameContainsNotebookInvalidChar(branchName string) bool {

for _, invalidChar := range notebookDirInvalidChar {
if strings.Contains(branchName, invalidChar) {
return true
}
}
return false

}

func isImageMatch(npuImage string, book *models.Cloudbrain) bool {
return (!book.IsNPUTask()) || book.Image == npuImage



Loading…
Cancel
Save