Browse Source

提交创建错误控制信息

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.7.1
zouap 4 years ago
parent
commit
f56764a0d8
4 changed files with 47 additions and 2 deletions
  1. +16
    -0
      models/ai_model_manage.go
  2. +5
    -0
      options/locale/locale_en-US.ini
  3. +5
    -0
      options/locale/locale_zh-CN.ini
  4. +21
    -2
      routers/repo/ai_model_convert.go

+ 16
- 0
models/ai_model_manage.go View File

@@ -381,6 +381,22 @@ func QueryModel(opts *AiModelQueryOptions) ([]*AiModelManage, int64, error) {
return aiModelManages, count, nil
}

func QueryModelConvertByRepoID(repoId int64) ([]*AiModelConvert, error) {
sess := x.NewSession()
defer sess.Close()
var cond = builder.NewCond()
cond = cond.And(
builder.Eq{"ai_model_convert.repo_id": repoId},
)
sess.OrderBy("ai_model_convert.created_unix DESC")
aiModelManageConvert := make([]*AiModelConvert, 0)
if err := sess.Table(new(AiModelConvert)).Where(cond).
Find(&aiModelManageConvert); err != nil {
return nil, fmt.Errorf("Find: %v", err)
}
return aiModelManageConvert, nil
}

func QueryModelConvert(opts *AiModelQueryOptions) ([]*AiModelConvert, int64, error) {
sess := x.NewSession()
defer sess.Close()


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

@@ -1220,6 +1220,11 @@ model.convert=Model Transformation
model.list=Model List
model.manage.create_new_convert_task=Create Model Transformation Task

modelconvert.manage.create_error1=A model transformation task with the same name already exists.
modelconvert.manage.create_error2=Only one running model transformation task can be created.
modelconvert.manage.model_not_exist=The model does not exist.
modelconvert.manage.no_operate_right=No operation permission.

grampus.train_job.ai_center = AI Center
grampus.dataset_path_rule = The code is storaged in /cache/code;the dataset is storaged in /cache/dataset;and please put your model into /cache/output, then you can download it online。
grampus.gpu_dataset_path_rule = The code is storaged in /tmp/code;the dataset is storaged in /tmp/dataset;and please put your model into /tmp/output, then you can download it online。


+ 5
- 0
options/locale/locale_zh-CN.ini View File

@@ -1232,6 +1232,11 @@ model.convert=模型转换任务
model.list=模型列表
model.manage.create_new_convert_task=创建模型转换任务

modelconvert.manage.create_error1=相同的名称模型转换任务已经存在。
modelconvert.manage.create_error2=只能创建一个在运行的模型转换任务。
modelconvert.manage.model_not_exist=模型不存在。
modelconvert.manage.no_operate_right=无操作权限。

grampus.train_job.ai_center=智算中心
grampus.dataset_path_rule = 训练脚本存储在/cache/code中,数据集存储在/cache/dataset中,训练输出请存储在/cache/output中以供后续下载。
grampus.gpu_dataset_path_rule = 训练脚本存储在/tmp/code中,数据集存储在/tmp/dataset中,训练输出请存储在/tmp/output中以供后续下载。


+ 21
- 2
routers/repo/ai_model_convert.go View File

@@ -71,7 +71,10 @@ var (
func SaveModelConvert(ctx *context.Context) {
log.Info("save model convert start.")
if !ctx.Repo.CanWrite(models.UnitTypeModelManage) {
ctx.JSON(403, ctx.Tr("repo.model_noright"))
ctx.JSON(200, map[string]string{
"result_code": "1",
"message": "No right to create task.",
})
return
}
name := ctx.Query("name")
@@ -87,10 +90,26 @@ func SaveModelConvert(ctx *context.Context) {
task, err := models.QueryModelById(modelId)
if err != nil {
log.Error("no such model!", err.Error())
ctx.ServerError("no such model:", err)
ctx.JSON(200, map[string]string{
"result_code": "1",
"message": "No such model.",
})
return
}

convertList, err := models.QueryModelConvertByRepoID(ctx.Repo.Repository.ID)
if err == nil {
for _, convert := range convertList {
if convert.Name == name {
ctx.JSON(200, map[string]string{
"result_code": "1",
"message": ctx.Tr("modelconvert.manage.create_error1"),
})
return
}
}
}

uuid := uuid.NewV4()
id := uuid.String()
modelConvert := &models.AiModelConvert{


Loading…
Cancel
Save