|
|
@@ -37,6 +37,9 @@ const ( |
|
|
STATUS_COPY_MODEL = 1 |
|
|
STATUS_COPY_MODEL = 1 |
|
|
STATUS_FINISHED = 0 |
|
|
STATUS_FINISHED = 0 |
|
|
STATUS_ERROR = 2 |
|
|
STATUS_ERROR = 2 |
|
|
|
|
|
|
|
|
|
|
|
MODEL_LOCAL_TYPE = 1 |
|
|
|
|
|
MODEL_ONLINE_TYPE = 0 |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func saveModelByParameters(jobId string, versionName string, name string, version string, label string, description string, engine int, ctx *context.Context) (string, error) { |
|
|
func saveModelByParameters(jobId string, versionName string, name string, version string, label string, description string, engine int, ctx *context.Context) (string, error) { |
|
|
@@ -1032,28 +1035,46 @@ func ModifyModelInfo(ctx *context.Context) { |
|
|
log.Info("modify model start.") |
|
|
log.Info("modify model start.") |
|
|
id := ctx.Query("id") |
|
|
id := ctx.Query("id") |
|
|
description := ctx.Query("description") |
|
|
description := ctx.Query("description") |
|
|
|
|
|
|
|
|
|
|
|
re := map[string]string{ |
|
|
|
|
|
"code": "-1", |
|
|
|
|
|
} |
|
|
task, err := models.QueryModelById(id) |
|
|
task, err := models.QueryModelById(id) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
|
|
|
re["msg"] = err.Error() |
|
|
log.Error("no such model!", err.Error()) |
|
|
log.Error("no such model!", err.Error()) |
|
|
ctx.ServerError("no such model:", err) |
|
|
|
|
|
|
|
|
ctx.JSON(200, re) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if !isOper(ctx, task.UserId) { |
|
|
if !isOper(ctx, task.UserId) { |
|
|
ctx.NotFound(ctx.Req.URL.RequestURI(), nil) |
|
|
|
|
|
//ctx.ServerError("no right.", errors.New(ctx.Tr("repo.model_noright"))) |
|
|
|
|
|
|
|
|
re["msg"] = "No right to operation." |
|
|
|
|
|
ctx.JSON(200, re) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
if task.ModelType == MODEL_LOCAL_TYPE { |
|
|
|
|
|
name := ctx.Query("name") |
|
|
|
|
|
label := ctx.Query("label") |
|
|
|
|
|
description := ctx.Query("description") |
|
|
|
|
|
engine := ctx.QueryInt("engine") |
|
|
|
|
|
aimodels := models.QueryModelByName(name, task.RepoId) |
|
|
|
|
|
if aimodels != nil && len(aimodels) > 0 { |
|
|
|
|
|
re["msg"] = ctx.Tr("repo.model.manage.create_error") |
|
|
|
|
|
ctx.JSON(200, re) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
err = models.ModifyLocalModel(id, name, label, description, engine) |
|
|
|
|
|
|
|
|
err = ModifyModel(id, description) |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
err = ModifyModel(id, description) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Info("modify error," + err.Error()) |
|
|
|
|
|
ctx.ServerError("error.", err) |
|
|
|
|
|
|
|
|
re["msg"] = err.Error() |
|
|
|
|
|
ctx.JSON(200, re) |
|
|
|
|
|
return |
|
|
} else { |
|
|
} else { |
|
|
ctx.JSON(200, "success") |
|
|
|
|
|
|
|
|
re["code"] = "0" |
|
|
|
|
|
ctx.JSON(200, re) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func QueryModelListForPredict(ctx *context.Context) { |
|
|
func QueryModelListForPredict(ctx *context.Context) { |
|
|
|