Browse Source

Merge branch 'zouap' of https://git.openi.org.cn/OpenI/aiforge into zouap

tags/v1.21.12.1^2
zhoupzh 4 years ago
parent
commit
fb25078130
3 changed files with 16 additions and 31 deletions
  1. +2
    -0
      options/locale/locale_en-US.ini
  2. +1
    -0
      options/locale/locale_zh-CN.ini
  3. +13
    -31
      routers/repo/ai_model_manage.go

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

@@ -883,6 +883,8 @@ modelarts.train_job_para_admin=train_job_para_admin
modelarts.train_job_para.edit=train_job_para.edit
modelarts.train_job_para.connfirm=train_job_para.connfirm

model.manage.create_error=Equal Name and Version has existed.

template.items = Template Items
template.git_content = Git Content (Default Branch)
template.git_hooks = Git Hooks


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

@@ -894,6 +894,7 @@ modelarts.train_job_para_admin=任务参数管理
modelarts.train_job_para.edit=编辑
modelarts.train_job_para.connfirm=确定

model.manage.create_error=相同的名称和版本的模型已经存在。

template.items=模板选项
template.git_content=Git数据(默认分支)


+ 13
- 31
routers/repo/ai_model_manage.go View File

@@ -26,7 +26,7 @@ const (
MODEL_NOT_LATEST = 0
)

func saveModelByParameters(jobId string, versionName string, name string, version string, label string, description string, userId int64, userName string, userHeadUrl string) error {
func saveModelByParameters(jobId string, versionName string, name string, version string, label string, description string, ctx *context.Context) error {
aiTask, err := models.GetCloudbrainByJobIDAndVersionName(jobId, versionName)
//aiTask, err := models.GetCloudbrainByJobID(jobId)
if err != nil {
@@ -45,6 +45,9 @@ func saveModelByParameters(jobId string, versionName string, name string, versio
aimodels := models.QueryModelByName(name, aiTask.RepoID)
if len(aimodels) > 0 {
for _, model := range aimodels {
if model.Version == version {
return errors.New(ctx.Tr("repo.model.manage.create_error"))
}
if model.New == MODEL_LATEST {
lastNewModelId = model.ID
}
@@ -82,9 +85,9 @@ func saveModelByParameters(jobId string, versionName string, name string, versio
Size: modelSize,
AttachmentId: aiTask.Uuid,
RepoId: aiTask.RepoID,
UserId: userId,
UserName: userName,
UserRelAvatarLink: userHeadUrl,
UserId: ctx.User.ID,
UserName: ctx.User.Name,
UserRelAvatarLink: ctx.User.RelAvatarLink(),
CodeBranch: aiTask.BranchName,
CodeCommitID: aiTask.CommitID,
Engine: aiTask.EngineID,
@@ -125,7 +128,7 @@ func SaveModel(ctx *context.Context) {
return
}

err := saveModelByParameters(JobId, VersionName, name, version, label, description, ctx.User.ID, ctx.User.Name, ctx.User.RelAvatarLink())
err := saveModelByParameters(JobId, VersionName, name, version, label, description, ctx)

if err != nil {
log.Info("save model error." + err.Error())
@@ -355,33 +358,12 @@ func ShowModelInfo(ctx *context.Context) {
}

func ShowSingleModel(ctx *context.Context) {
id := ctx.Params(":ID")
parentDir := ctx.Query("parentDir")
log.Info("Show single ModelInfo start.id=" + id)
task, err := models.QueryModelById(id)
if err != nil {
log.Error("no such model!", err.Error())
ctx.ServerError("no such model:", err)
return
}
log.Info("bucket=" + setting.Bucket + " key=" + task.Path[len(setting.Bucket)+1:])
models, err := storage.GetOneLevelAllObjectUnderDir(setting.Bucket, task.Path[len(setting.Bucket)+1:], parentDir)
if err != nil {
log.Info("get model list failed:", err)
ctx.ServerError("GetObsListObject:", err)
return
} else {
log.Info("get model file,size=" + fmt.Sprint(len(models)))
}
name := ctx.Query("name")

if err != nil {
ctx.ServerError("QueryTrainJobList:", err)
} else {
mapInterface := make(map[string]interface{})
mapInterface["task"] = task
mapInterface["models"] = models
ctx.JSON(http.StatusOK, mapInterface)
}
log.Info("Show single ModelInfo start.name=" + name)
models := models.QueryModelByName(name, ctx.Repo.Repository.ID)

ctx.JSON(http.StatusOK, models)
}

func ShowOneVersionOtherModel(ctx *context.Context) {


Loading…
Cancel
Save