|
|
|
@@ -25,8 +25,9 @@ const ( |
|
|
|
MODEL_NOT_LATEST = 0 |
|
|
|
) |
|
|
|
|
|
|
|
func SaveModelByParameters(jobId string, name string, version string, label string, description string, userId int64) error { |
|
|
|
aiTask, err := models.GetCloudbrainByJobID(jobId) |
|
|
|
func SaveModelByParameters(jobId string, versionName string, name string, version string, label string, description string, userId int64) error { |
|
|
|
aiTask, err := models.GetCloudbrainByJobIDAndVersionName(jobId, versionName) |
|
|
|
//aiTask, err := models.GetCloudbrainByJobID(jobId) |
|
|
|
if err != nil { |
|
|
|
log.Info("query task error." + err.Error()) |
|
|
|
return err |
|
|
|
@@ -70,6 +71,7 @@ func SaveModelByParameters(jobId string, name string, version string, label stri |
|
|
|
model := &models.AiModelManage{ |
|
|
|
ID: id, |
|
|
|
Version: version, |
|
|
|
VersionCount: len(aimodels) + 1, |
|
|
|
Label: label, |
|
|
|
Name: name, |
|
|
|
Description: description, |
|
|
|
@@ -91,8 +93,8 @@ func SaveModelByParameters(jobId string, name string, version string, label stri |
|
|
|
models.SaveModelToDb(model) |
|
|
|
|
|
|
|
if len(lastNewModelId) > 0 { |
|
|
|
//udpate status |
|
|
|
models.ModifyModelNewProperty(lastNewModelId, MODEL_NOT_LATEST) |
|
|
|
//udpate status and version count |
|
|
|
models.ModifyModelNewProperty(lastNewModelId, MODEL_NOT_LATEST, 0) |
|
|
|
} |
|
|
|
|
|
|
|
log.Info("save model end.") |
|
|
|
@@ -103,12 +105,13 @@ func SaveModelByParameters(jobId string, name string, version string, label stri |
|
|
|
func SaveModel(ctx *context.Context) { |
|
|
|
log.Info("save model start.") |
|
|
|
JobId := ctx.Query("JobId") |
|
|
|
VersionName := ctx.Query("VersionName") |
|
|
|
name := ctx.Query("Name") |
|
|
|
version := ctx.Query("Version") |
|
|
|
label := ctx.Query("Label") |
|
|
|
description := ctx.Query("Description") |
|
|
|
|
|
|
|
err := SaveModelByParameters(JobId, name, version, label, description, ctx.User.ID) |
|
|
|
err := SaveModelByParameters(JobId, VersionName, name, version, label, description, ctx.User.ID) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
log.Info("save model error." + err.Error()) |
|
|
|
@@ -171,7 +174,8 @@ func DeleteModelByID(id string) error { |
|
|
|
if model.New == MODEL_LATEST { |
|
|
|
aimodels := models.QueryModelByName(model.Name, model.RepoId) |
|
|
|
if len(aimodels) > 0 { |
|
|
|
models.ModifyModelNewProperty(aimodels[0].ID, MODEL_LATEST) |
|
|
|
//udpate status and version count |
|
|
|
models.ModifyModelNewProperty(aimodels[0].ID, MODEL_LATEST, len(aimodels)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|