|
|
|
@@ -71,25 +71,24 @@ func saveModelByParameters(jobId string, versionName string, name string, versio |
|
|
|
aiTaskJson, _ := json.Marshal(aiTask) |
|
|
|
|
|
|
|
model := &models.AiModelManage{ |
|
|
|
ID: id, |
|
|
|
Version: version, |
|
|
|
VersionCount: len(aimodels) + 1, |
|
|
|
Label: label, |
|
|
|
Name: name, |
|
|
|
Description: description, |
|
|
|
New: MODEL_LATEST, |
|
|
|
Type: cloudType, |
|
|
|
Path: modelPath, |
|
|
|
Size: modelSize, |
|
|
|
AttachmentId: aiTask.Uuid, |
|
|
|
RepoId: aiTask.RepoID, |
|
|
|
UserId: ctx.User.ID, |
|
|
|
UserRelAvatarLink: ctx.User.RelAvatarLink(), |
|
|
|
CodeBranch: aiTask.BranchName, |
|
|
|
CodeCommitID: aiTask.CommitID, |
|
|
|
Engine: aiTask.EngineID, |
|
|
|
TrainTaskInfo: string(aiTaskJson), |
|
|
|
Accuracy: string(accuracyJson), |
|
|
|
ID: id, |
|
|
|
Version: version, |
|
|
|
VersionCount: len(aimodels) + 1, |
|
|
|
Label: label, |
|
|
|
Name: name, |
|
|
|
Description: description, |
|
|
|
New: MODEL_LATEST, |
|
|
|
Type: cloudType, |
|
|
|
Path: modelPath, |
|
|
|
Size: modelSize, |
|
|
|
AttachmentId: aiTask.Uuid, |
|
|
|
RepoId: aiTask.RepoID, |
|
|
|
UserId: ctx.User.ID, |
|
|
|
CodeBranch: aiTask.BranchName, |
|
|
|
CodeCommitID: aiTask.CommitID, |
|
|
|
Engine: aiTask.EngineID, |
|
|
|
TrainTaskInfo: string(aiTaskJson), |
|
|
|
Accuracy: string(accuracyJson), |
|
|
|
} |
|
|
|
|
|
|
|
err = models.SaveModelToDb(model) |
|
|
|
@@ -395,7 +394,7 @@ func ShowSingleModel(ctx *context.Context) { |
|
|
|
ctx.JSON(http.StatusOK, models) |
|
|
|
} |
|
|
|
|
|
|
|
func queryUserName(intSlice []int64) map[int64]string { |
|
|
|
func queryUserName(intSlice []int64) map[int64]*models.User { |
|
|
|
keys := make(map[int64]string) |
|
|
|
uniqueElements := []int64{} |
|
|
|
for _, entry := range intSlice { |
|
|
|
@@ -404,13 +403,14 @@ func queryUserName(intSlice []int64) map[int64]string { |
|
|
|
uniqueElements = append(uniqueElements, entry) |
|
|
|
} |
|
|
|
} |
|
|
|
userNames, err := models.GetUserNamesByIDs(uniqueElements) |
|
|
|
result := make(map[int64]*models.User) |
|
|
|
userLists, err := models.GetUsersByIDs(uniqueElements) |
|
|
|
if err == nil { |
|
|
|
for i, userName := range userNames { |
|
|
|
keys[uniqueElements[i]] = userName |
|
|
|
for i, user := range userLists { |
|
|
|
result[uniqueElements[i]] = user |
|
|
|
} |
|
|
|
} |
|
|
|
return keys |
|
|
|
return result |
|
|
|
} |
|
|
|
|
|
|
|
func ShowOneVersionOtherModel(ctx *context.Context) { |
|
|
|
@@ -428,7 +428,11 @@ func ShowOneVersionOtherModel(ctx *context.Context) { |
|
|
|
userNameMap := queryUserName(userIds) |
|
|
|
|
|
|
|
for _, model := range aimodels { |
|
|
|
model.UserName = userNameMap[model.UserId] |
|
|
|
value := userNameMap[model.UserId] |
|
|
|
if value != nil { |
|
|
|
model.UserName = value.Name |
|
|
|
model.UserRelAvatarLink = value.RelAvatarLink() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if len(aimodels) > 0 { |
|
|
|
@@ -504,7 +508,11 @@ func ShowModelPageInfo(ctx *context.Context) { |
|
|
|
|
|
|
|
userNameMap := queryUserName(userIds) |
|
|
|
for _, model := range modelResult { |
|
|
|
model.UserName = userNameMap[model.UserId] |
|
|
|
value := userNameMap[model.UserId] |
|
|
|
if value != nil { |
|
|
|
model.UserName = value.Name |
|
|
|
model.UserRelAvatarLink = value.RelAvatarLink() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
mapInterface := make(map[string]interface{}) |
|
|
|
|