#4326 fix bug #4285

Merged
ychao_1983 merged 2 commits from handle-async-err into V20230531 11 months ago
  1. +1
    -0
      options/locale/locale_en-US.ini
  2. +2
    -1
      options/locale/locale_zh-CN.ini
  3. +12
    -3
      routers/response/error.go
  4. +2
    -1
      routers/response/response_list.go
  5. +1
    -0
      services/ai_task_service/task/cloudbrain_one_notebook_task.go
  6. +1
    -0
      services/ai_task_service/task/cloudbrain_two_notebook_task.go
  7. +1
    -0
      services/ai_task_service/task/grampus_notebook_task.go
  8. +1
    -0
      services/ai_task_service/task/grampus_online_infer_task.go
  9. +13
    -0
      services/ai_task_service/task/opt_handler.go

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

@@ -3433,6 +3433,7 @@ can_not_restart = The task was not scheduled successfully before, so it cannot b
dataset_size_over_limit = The size of dataset exceeds limitation (%dGB)
boot_file_must_python = The boot file must be a python file
boot_file_not_exist= The boot file is not exists.
branch_not_exists= The branch does not exist. Please refresh and select again.

[common_error]
system_error = System error.Please try again later


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

@@ -3454,7 +3454,8 @@ stop_failed = 任务停止失败,请稍后再试
can_not_restart = 这个任务之前没有调度成功,不能再次调试。
dataset_size_over_limit = 数据集大小超过限制(%dGB)
boot_file_must_python = 启动文件必须是python文件
boot_file_not_exist =启动文件不存在。
boot_file_not_exist =启动文件不存在
branch_not_exists= 代码分支不存在,请刷新后重试

[common_error]
system_error = 当前服务不可用,请稍后再试


+ 12
- 3
routers/response/error.go View File

@@ -7,12 +7,21 @@ type BizError struct {
TrParams []interface{}
}

//当调用此方法时意味着错误信息中有占位符,需要传入参数
//因此此时需要新建一个对象避免并发问题
func (e *BizError) WithParams(params ...interface{}) *BizError {
newErr := &BizError{
Code: e.Code,
DefaultMsg: e.DefaultMsg,
TrCode: e.TrCode,
}
if e.TrParams == nil {
e.TrParams = make([]interface{}, 0)
newErr.TrParams = params
} else {
newErr.TrParams = append(e.TrParams, params)
}
e.TrParams = append(e.TrParams, params)
return e
return newErr
}

func NewBizError(err error) *BizError {


+ 2
- 1
routers/response/response_list.go View File

@@ -26,9 +26,10 @@ var RESULT_CLEARD = &BizError{Code: 2009, DefaultMsg: "The files of the task hav
var CREATE_FAILED = &BizError{Code: 2010, DefaultMsg: "Create AI task failed", TrCode: "ai_task.create_failed"}
var RESTART_FAILED = &BizError{Code: 2011, DefaultMsg: "Restart AI task failed", TrCode: "ai_task.restart_failed"}
var STOP_FAILED = &BizError{Code: 2012, DefaultMsg: "Stop AI task failed", TrCode: "ai_task.stop_failed"}
var DATASET_SIZE_OVER_LIMIT = &BizError{Code: 2013, DefaultMsg: "Stop AI task failed", TrCode: "ai_task.dataset_size_over_limit"}
var DATASET_SIZE_OVER_LIMIT = &BizError{Code: 2013, DefaultMsg: "The size of dataset exceeds limitation", TrCode: "ai_task.dataset_size_over_limit"}
var BOOT_FILE_MUST_BE_PYTHON = &BizError{Code: 2013, DefaultMsg: "The boot file must be a python file", TrCode: "ai_task.boot_file_must_python"}
var BOOT_FILE_NOT_EXIST = &BizError{Code: 2014, DefaultMsg: "The boot file not exist", TrCode: "ai_task.boot_file_not_exist"}
var DATASET_SELECT_ERROR = &BizError{Code: 2017, DefaultMsg: "Dataset select error: the count exceed the limit or has same name", TrCode: "cloudbrain.error.dataset_select"}
var PARTIAL_DATASETS_NOT_AVAILABLE = &BizError{Code: 2018, DefaultMsg: "There are non-existent or deleted files in the selected dataset file, please select again", TrCode: "cloudbrain.error.partial_datasets_not_available"}
var LOAD_CODE_FAILED = &BizError{Code: 2019, DefaultMsg: "Fail to load code, please check if the right branch is selected.", TrCode: "cloudbrain.load_code_failed"}
var BRANCH_NOT_EXISTS = &BizError{Code: 2020, DefaultMsg: "The branch does not exist", TrCode: "ai_task.branch_not_exists"}

+ 1
- 0
services/ai_task_service/task/cloudbrain_one_notebook_task.go View File

@@ -37,6 +37,7 @@ func (t CloudbrainOneNotebookTaskTemplate) Create(ctx *context.CreationContext)
Next(t.CheckPointBalance).
Next(t.CheckDatasetSize).
Next(t.CheckDatasetExists).
Next(t.CheckBranchExists).
Next(t.InsertCloudbrainRecord4Async).
AsyncNextWithErrFun(t.BuildContainerData, t.CallCreationAPI, t.AfterCallCreationAPI4Async, t.NotifyCreation, t.HandleErr4Async).
Operate(ctx)


+ 1
- 0
services/ai_task_service/task/cloudbrain_two_notebook_task.go View File

@@ -40,6 +40,7 @@ func (t CloudbrainTwoNotebookTaskTemplate) Create(ctx *context.CreationContext)
Next(t.CheckPointBalance).
Next(t.CheckDatasetSize).
Next(t.CheckDatasetExists).
Next(t.CheckBranchExists).
Next(t.InsertCloudbrainRecord4Async).
AsyncNextWithErrFun(t.BuildContainerData, t.CallCreationAPI, t.AfterCallCreationAPI4Async, t.NotifyCreation, t.HandleErr4Async).
Operate(ctx)


+ 1
- 0
services/ai_task_service/task/grampus_notebook_task.go View File

@@ -38,6 +38,7 @@ func (t GrampusNoteBookTaskTemplate) Create(ctx *context.CreationContext) (*enti
Next(t.CheckPointBalance).
Next(t.CheckDatasetSize).
Next(t.CheckDatasetExists).
Next(t.CheckBranchExists).
Next(t.CheckModel).
Next(t.InsertCloudbrainRecord4Async).
AsyncNextWithErrFun(t.BuildContainerData, t.CallCreationAPI, t.AfterCallCreationAPI4Async, t.NotifyCreation, t.HandleErr4Async).


+ 1
- 0
services/ai_task_service/task/grampus_online_infer_task.go View File

@@ -41,6 +41,7 @@ func (t GrampusOnlineInferTaskTemplate) Create(ctx *context.CreationContext) (*e
Next(t.CheckPointBalance).
Next(t.CheckDatasetSize).
Next(t.CheckDatasetExists).
Next(t.CheckBranchExists).
Next(t.CheckModel).
Next(t.InsertCloudbrainRecord4Async).
AsyncNext(t.BuildContainerData, t.CallCreationAPI, t.AfterCallCreationAPI4Async, t.NotifyCreation).


+ 13
- 0
services/ai_task_service/task/opt_handler.go View File

@@ -28,6 +28,7 @@ type CreationHandler interface {
CheckPointBalance(ctx *context.CreationContext) *response.BizError
CheckDatasetExists(ctx *context.CreationContext) *response.BizError
CheckDatasetSize(ctx *context.CreationContext) *response.BizError
CheckBranchExists(ctx *context.CreationContext) *response.BizError
CheckModel(ctx *context.CreationContext) *response.BizError
CheckBootFile(ctx *context.CreationContext) *response.BizError
CheckIsCleared(ctx *context.CreationContext) *response.BizError
@@ -121,6 +122,18 @@ func (DefaultCreationHandler) CheckDatasetExists(ctx *context.CreationContext) *
return nil
}

func (DefaultCreationHandler) CheckBranchExists(ctx *context.CreationContext) *response.BizError {
log.Info("Start to CheckBranchExists.displayJobName=%s jobType=%s cluster=%s", ctx.Request.DisplayJobName, ctx.Request.JobType, ctx.Request.Cluster)
if ctx.GitRepo == nil || ctx.Request.BranchName == "" {
return nil
}
if !ctx.GitRepo.IsBranchExist(ctx.Request.BranchName) {
return response.BRANCH_NOT_EXISTS
}
log.Info("CheckBranchExists success.displayJobName=%s jobType=%s cluster=%s", ctx.Request.DisplayJobName, ctx.Request.JobType, ctx.Request.Cluster)
return nil
}

func (DefaultCreationHandler) CheckDatasetSize(ctx *context.CreationContext) *response.BizError {
log.Info("Start to CheckDatasetSize.displayJobName=%s jobType=%s cluster=%s", ctx.Request.DisplayJobName, ctx.Request.JobType, ctx.Request.Cluster)
if ctx.Request.DatasetUUIDStr == "" {


Loading…
Cancel
Save