|
|
|
@@ -73,7 +73,7 @@ func SaveModelConvert(ctx *context.Context) { |
|
|
|
if !ctx.Repo.CanWrite(models.UnitTypeModelManage) { |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"result_code": "1", |
|
|
|
"message": "No right to create task.", |
|
|
|
"message": ctx.Tr("repo.modelconvert.manage.no_operate_right"), |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
@@ -92,7 +92,7 @@ func SaveModelConvert(ctx *context.Context) { |
|
|
|
log.Error("no such model!", err.Error()) |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"result_code": "1", |
|
|
|
"message": "No such model.", |
|
|
|
"message": ctx.Tr("repo.modelconvert.manage.model_not_exist"), |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
@@ -103,7 +103,14 @@ func SaveModelConvert(ctx *context.Context) { |
|
|
|
if convert.Name == name { |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"result_code": "1", |
|
|
|
"message": ctx.Tr("modelconvert.manage.create_error1"), |
|
|
|
"message": ctx.Tr("repo.modelconvert.manage.create_error1"), |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if isRunningTask(convert.Status) { |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"result_code": "1", |
|
|
|
"message": ctx.Tr("repo.modelconvert.manage.create_error2"), |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
@@ -137,6 +144,16 @@ func SaveModelConvert(ctx *context.Context) { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func isRunningTask(status string) bool { |
|
|
|
stopStatus := []string{"COMPLETED", "STOPPED", "FAILED", "START_FAILED", "STOPPING", "SUCCEEDED"} |
|
|
|
for _, sta := range stopStatus { |
|
|
|
if sta == status { |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
return true |
|
|
|
} |
|
|
|
|
|
|
|
func goCreateTask(modelConvert *models.AiModelConvert, ctx *context.Context, task *models.AiModelManage) error { |
|
|
|
if modelConvert.IsGpuTrainTask() { |
|
|
|
log.Info("create gpu train job.") |
|
|
|
@@ -365,6 +382,7 @@ func createGpuTrainJob(modelConvert *models.AiModelConvert, ctx *context.Context |
|
|
|
log.Info("local dataset path:" + relatetiveModelPath) |
|
|
|
downloadFromObsToLocal(model, relatetiveModelPath) |
|
|
|
uploadCodeToMinio(relatetiveModelPath+"/", modelConvert.ID, "/dataset/") |
|
|
|
//TODO delete |
|
|
|
dataActualPath = setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.CBCodePathPrefix + modelConvert.ID + "/dataset" |
|
|
|
} |
|
|
|
} |
|
|
|
@@ -376,7 +394,7 @@ func createGpuTrainJob(modelConvert *models.AiModelConvert, ctx *context.Context |
|
|
|
downloadConvertCode(setting.ModelConvert.ConvertRepoPath, codePath, DefaultBranchName) |
|
|
|
|
|
|
|
uploadCodeToMinio(codePath+"/", modelConvert.ID, CodeMountPath+"/") |
|
|
|
|
|
|
|
//TODO delete |
|
|
|
minioCodePath := setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.CBCodePathPrefix + modelConvert.ID + "/code" |
|
|
|
log.Info("minio codePath=" + minioCodePath) |
|
|
|
|
|
|
|
@@ -385,6 +403,7 @@ func createGpuTrainJob(modelConvert *models.AiModelConvert, ctx *context.Context |
|
|
|
mkModelPath(modelPath) |
|
|
|
|
|
|
|
uploadCodeToMinio(modelPath, modelConvert.ID, ModelMountPath+"/") |
|
|
|
//TODO delete |
|
|
|
minioModelPath := setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.CBCodePathPrefix + modelConvert.ID + "/model" |
|
|
|
log.Info("minio model path=" + minioModelPath) |
|
|
|
|
|
|
|
@@ -485,6 +504,7 @@ func DeleteModelConvert(ctx *context.Context) { |
|
|
|
log.Info("delete model convert start.") |
|
|
|
id := ctx.Params(":id") |
|
|
|
err := models.DeleteModelConvertById(id) |
|
|
|
//TODO delete OBS文件及云脑任务 |
|
|
|
if err != nil { |
|
|
|
ctx.JSON(500, err.Error()) |
|
|
|
} else { |
|
|
|
|