|
|
@@ -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) { |
|
|
|