|
|
|
@@ -55,7 +55,7 @@ func saveModelByParameters(jobId string, versionName string, name string, versio |
|
|
|
cloudType = aiTask.Type |
|
|
|
//download model zip //train type |
|
|
|
if cloudType == models.TypeCloudBrainTwo { |
|
|
|
modelPath, modelSize, err = downloadModelFromCloudBrainTwo(id, aiTask.JobName, "") |
|
|
|
modelPath, modelSize, err = downloadModelFromCloudBrainTwo(id, aiTask.JobName, "", aiTask.TrainUrl) |
|
|
|
if err != nil { |
|
|
|
log.Info("download model from CloudBrainTwo faild." + err.Error()) |
|
|
|
return err |
|
|
|
@@ -141,9 +141,12 @@ func SaveModel(ctx *context.Context) { |
|
|
|
log.Info("save model end.") |
|
|
|
} |
|
|
|
|
|
|
|
func downloadModelFromCloudBrainTwo(modelUUID string, jobName string, parentDir string) (string, int64, error) { |
|
|
|
|
|
|
|
func downloadModelFromCloudBrainTwo(modelUUID string, jobName string, parentDir string, trainUrl string) (string, int64, error) { |
|
|
|
objectkey := strings.TrimPrefix(path.Join(setting.TrainJobModelPath, jobName, setting.OutPutPath, parentDir), "/") |
|
|
|
if trainUrl != "" { |
|
|
|
objectkey = trainUrl[len(setting.Bucket)+1:] |
|
|
|
} |
|
|
|
|
|
|
|
modelDbResult, err := storage.GetOneLevelAllObjectUnderDir(setting.Bucket, objectkey, "") |
|
|
|
log.Info("bucket=" + setting.Bucket + " objectkey=" + objectkey) |
|
|
|
if err != nil { |
|
|
|
@@ -392,6 +395,24 @@ func ShowSingleModel(ctx *context.Context) { |
|
|
|
ctx.JSON(http.StatusOK, models) |
|
|
|
} |
|
|
|
|
|
|
|
func queryUserName(intSlice []int64) map[int64]string { |
|
|
|
keys := make(map[int64]string) |
|
|
|
uniqueElements := []int64{} |
|
|
|
for _, entry := range intSlice { |
|
|
|
if _, value := keys[entry]; !value { |
|
|
|
keys[entry] = "" |
|
|
|
uniqueElements = append(uniqueElements, entry) |
|
|
|
} |
|
|
|
} |
|
|
|
userNames, err := models.GetUserNamesByIDs(uniqueElements) |
|
|
|
if err == nil { |
|
|
|
for i, userName := range userNames { |
|
|
|
keys[uniqueElements[i]] = userName |
|
|
|
} |
|
|
|
} |
|
|
|
return keys |
|
|
|
} |
|
|
|
|
|
|
|
func ShowOneVersionOtherModel(ctx *context.Context) { |
|
|
|
repoId := ctx.Repo.Repository.ID |
|
|
|
name := ctx.Query("name") |
|
|
|
@@ -404,12 +425,10 @@ func ShowOneVersionOtherModel(ctx *context.Context) { |
|
|
|
model.IsCanOper = isOper(ctx, model.UserId) |
|
|
|
userIds[i] = model.UserId |
|
|
|
} |
|
|
|
userNameMap := queryUserName(userIds) |
|
|
|
|
|
|
|
userNames, err := models.GetUserNamesByIDs(userIds) |
|
|
|
if err == nil { |
|
|
|
for i, model := range aimodels { |
|
|
|
model.UserName = userNames[i] |
|
|
|
} |
|
|
|
for _, model := range aimodels { |
|
|
|
model.UserName = userNameMap[model.UserId] |
|
|
|
} |
|
|
|
|
|
|
|
if len(aimodels) > 0 { |
|
|
|
@@ -479,11 +498,9 @@ func ShowModelPageInfo(ctx *context.Context) { |
|
|
|
userIds[i] = model.UserId |
|
|
|
} |
|
|
|
|
|
|
|
userNames, err := models.GetUserNamesByIDs(userIds) |
|
|
|
if err == nil { |
|
|
|
for i, model := range modelResult { |
|
|
|
model.UserName = userNames[i] |
|
|
|
} |
|
|
|
userNameMap := queryUserName(userIds) |
|
|
|
for _, model := range modelResult { |
|
|
|
model.UserName = userNameMap[model.UserId] |
|
|
|
} |
|
|
|
|
|
|
|
mapInterface := make(map[string]interface{}) |
|
|
|
|