|
|
@@ -105,6 +105,23 @@ func saveModelByParameters(jobId string, versionName string, name string, versio |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
func SaveNewNameModel(ctx *context.Context) { |
|
|
|
name := ctx.Query("Name") |
|
|
|
if name == "" { |
|
|
|
ctx.Error(500, fmt.Sprintf("name or version is null.")) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
aimodels := models.QueryModelByName(name, ctx.Repo.Repository.ID) |
|
|
|
if len(aimodels) > 0 { |
|
|
|
ctx.Error(500, ctx.Tr("repo.model_rename")) |
|
|
|
return |
|
|
|
} |
|
|
|
SaveModel(ctx) |
|
|
|
|
|
|
|
log.Info("save model end.") |
|
|
|
} |
|
|
|
|
|
|
|
func SaveModel(ctx *context.Context) { |
|
|
|
log.Info("save model start.") |
|
|
|
JobId := ctx.Query("JobId") |
|
|
@@ -569,3 +586,53 @@ func ModifyModelInfo(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func QueryModelListForPredict(ctx *context.Context) { |
|
|
|
repoId := ctx.Repo.Repository.ID |
|
|
|
modelResult, count, err := models.QueryModel(&models.AiModelQueryOptions{ |
|
|
|
ListOptions: models.ListOptions{ |
|
|
|
Page: -1, |
|
|
|
PageSize: -1, |
|
|
|
}, |
|
|
|
RepoID: repoId, |
|
|
|
Type: -1, |
|
|
|
New: -1, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("Cloudbrain", err) |
|
|
|
return |
|
|
|
} |
|
|
|
log.Info("query return count=" + fmt.Sprint(count)) |
|
|
|
|
|
|
|
nameList := make([]string, 0) |
|
|
|
|
|
|
|
nameMap := make(map[string][]*models.AiModelManage) |
|
|
|
for _, model := range modelResult { |
|
|
|
if _, value := nameMap[model.Name]; !value { |
|
|
|
models := make([]*models.AiModelManage, 0) |
|
|
|
models = append(models, model) |
|
|
|
nameMap[model.Name] = models |
|
|
|
nameList = append(nameList, model.Name) |
|
|
|
} else { |
|
|
|
nameMap[model.Name] = append(nameMap[model.Name], model) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
mapInterface := make(map[string]interface{}) |
|
|
|
mapInterface["nameList"] = nameList |
|
|
|
mapInterface["nameMap"] = nameMap |
|
|
|
ctx.JSON(http.StatusOK, mapInterface) |
|
|
|
} |
|
|
|
|
|
|
|
func QueryModelFileForPredict(ctx *context.Context) { |
|
|
|
id := ctx.Query("ID") |
|
|
|
model, err := models.QueryModelById(id) |
|
|
|
if err != nil { |
|
|
|
log.Error("no such model!", err.Error()) |
|
|
|
ctx.ServerError("no such model:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
prefix := model.Path[len(setting.Bucket)+2:] |
|
|
|
fileinfos, err := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, prefix) |
|
|
|
ctx.JSON(http.StatusOK, fileinfos) |
|
|
|
} |