Browse Source

合并0718分支。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.7.1
zouap 3 years ago
parent
commit
de3e171181
3 changed files with 31 additions and 9 deletions
  1. +1
    -1
      options/locale/locale_zh-CN.ini
  2. +24
    -4
      routers/repo/ai_model_convert.go
  3. +6
    -4
      templates/repo/modelmanage/convertIndex.tmpl

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

@@ -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=智算中心


+ 24
- 4
routers/repo/ai_model_convert.go View File

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


+ 6
- 4
templates/repo/modelmanage/convertIndex.tmpl View File

@@ -132,7 +132,7 @@
<!-- 删除任务 -->
<form id="delForm-{{.ID}}" action="{{$.RepoLink}}/modelmanage/delete_model_convert/{{.ID}}" method="post">
{{$.CsrfTokenHtml}}
{{if .IsCanOper}}
{{if .IsCanDelete}}
<a id="ai-delete-{{.ID}}" class='ui basic ai_delete blue button' style="border-radius: .28571429rem;">
{{$.i18n.Tr "repo.delete"}}
</a>
@@ -367,6 +367,7 @@

if(inputshapeNotValid(data['inputshape'])){
$('.ui.error.message').text("格式输入错误,请输入如:1,1,32,32,与输入数据格式对应。")
$('.ui.error.message').css('display','block')
$("#inputshape_div").addClass("error")
return false
}else{
@@ -378,13 +379,14 @@
data['NetOutputFormat']= $('#NetOutputFormat').val();
data['ModelFile'] = $('#ModelFile').val();



$.post(`${repolink}/modelmanage/create_model_convert`,data,(result) => {
console.log("result=" + result);
$('.ui.modal.second').modal('hide');
if(result.result_code ==0){
$('.ui.modal.second').modal('hide');
window.location.reload();
}else{
$('.ui.error.message').text(result.message)
$('.ui.error.message').css('display','block')
}
})
})


Loading…
Cancel
Save