diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 8fc84c0dd..3c5bb4ddb 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -1234,7 +1234,7 @@ model.manage.create_new_convert_task=创建模型转换任务 modelconvert.manage.create_error1=相同的名称模型转换任务已经存在。 modelconvert.manage.create_error2=只能创建一个在运行的模型转换任务。 -modelconvert.manage.model_not_exist=模型不存在。 +modelconvert.manage.model_not_exist=选择的模型不存在。 modelconvert.manage.no_operate_right=无操作权限。 grampus.train_job.ai_center=智算中心 diff --git a/routers/repo/ai_model_convert.go b/routers/repo/ai_model_convert.go index 91ffb3df7..a961af1e7 100644 --- a/routers/repo/ai_model_convert.go +++ b/routers/repo/ai_model_convert.go @@ -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 { diff --git a/templates/repo/modelmanage/convertIndex.tmpl b/templates/repo/modelmanage/convertIndex.tmpl index e87719a59..1470ccdcc 100644 --- a/templates/repo/modelmanage/convertIndex.tmpl +++ b/templates/repo/modelmanage/convertIndex.tmpl @@ -132,7 +132,7 @@