|
|
|
@@ -58,9 +58,10 @@ func saveModelByParameters(jobId string, versionName string, name string, versio |
|
|
|
} |
|
|
|
} |
|
|
|
cloudType := aiTask.Type |
|
|
|
modelSelectedFile := ctx.Query("modelSelectedFile") |
|
|
|
//download model zip //train type |
|
|
|
if cloudType == models.TypeCloudBrainTwo { |
|
|
|
modelPath, modelSize, err = downloadModelFromCloudBrainTwo(id, aiTask.JobName, "", aiTask.TrainUrl) |
|
|
|
modelPath, modelSize, err = downloadModelFromCloudBrainTwo(id, aiTask.JobName, "", aiTask.TrainUrl, modelSelectedFile) |
|
|
|
if err != nil { |
|
|
|
log.Info("download model from CloudBrainTwo faild." + err.Error()) |
|
|
|
return err |
|
|
|
@@ -74,7 +75,7 @@ func saveModelByParameters(jobId string, versionName string, name string, versio |
|
|
|
aiTask.FlavorName = flaverName |
|
|
|
} |
|
|
|
} |
|
|
|
modelPath, modelSize, err = downloadModelFromCloudBrainOne(id, aiTask.JobName, "", aiTask.TrainUrl) |
|
|
|
modelPath, modelSize, err = downloadModelFromCloudBrainOne(id, aiTask.JobName, "", aiTask.TrainUrl, modelSelectedFile) |
|
|
|
if err != nil { |
|
|
|
log.Info("download model from CloudBrainOne faild." + err.Error()) |
|
|
|
return err |
|
|
|
@@ -163,7 +164,8 @@ func SaveModel(ctx *context.Context) { |
|
|
|
description := ctx.Query("Description") |
|
|
|
engine := ctx.QueryInt("Engine") |
|
|
|
trainTaskCreate := ctx.QueryBool("trainTaskCreate") |
|
|
|
log.Info("engine=" + fmt.Sprint(engine)) |
|
|
|
modelSelectedFile := ctx.Query("modelSelectedFile") |
|
|
|
log.Info("engine=" + fmt.Sprint(engine) + " modelSelectedFile=" + modelSelectedFile) |
|
|
|
if !trainTaskCreate { |
|
|
|
if !ctx.Repo.CanWrite(models.UnitTypeModelManage) { |
|
|
|
//ctx.NotFound(ctx.Req.URL.RequestURI(), nil) |
|
|
|
@@ -176,6 +178,10 @@ func SaveModel(ctx *context.Context) { |
|
|
|
ctx.Error(500, fmt.Sprintf("JobId or VersionName is null.")) |
|
|
|
return |
|
|
|
} |
|
|
|
if modelSelectedFile == "" { |
|
|
|
ctx.Error(500, fmt.Sprintf("Not selected model file.")) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if name == "" || version == "" { |
|
|
|
ctx.Error(500, fmt.Sprintf("name or version is null.")) |
|
|
|
@@ -193,7 +199,7 @@ func SaveModel(ctx *context.Context) { |
|
|
|
log.Info("save model end.") |
|
|
|
} |
|
|
|
|
|
|
|
func downloadModelFromCloudBrainTwo(modelUUID string, jobName string, parentDir string, trainUrl string) (string, int64, error) { |
|
|
|
func downloadModelFromCloudBrainTwo(modelUUID string, jobName string, parentDir string, trainUrl string, modelSelectedFile string) (string, int64, error) { |
|
|
|
objectkey := strings.TrimPrefix(path.Join(setting.TrainJobModelPath, jobName, setting.OutPutPath, parentDir), "/") |
|
|
|
if trainUrl != "" { |
|
|
|
objectkey = strings.Trim(trainUrl[len(setting.Bucket)+1:], "/") |
|
|
|
@@ -211,21 +217,22 @@ func downloadModelFromCloudBrainTwo(modelUUID string, jobName string, parentDir |
|
|
|
|
|
|
|
prefix := objectkey + "/" |
|
|
|
destKeyNamePrefix := Model_prefix + models.AttachmentRelativePath(modelUUID) + "/" |
|
|
|
|
|
|
|
size, err := storage.ObsCopyManyFile(setting.Bucket, prefix, setting.Bucket, destKeyNamePrefix) |
|
|
|
filterFiles := strings.Split(modelSelectedFile, ";") |
|
|
|
size, err := storage.ObsCopyManyFile(setting.Bucket, prefix, setting.Bucket, destKeyNamePrefix, filterFiles) |
|
|
|
|
|
|
|
dataActualPath := setting.Bucket + "/" + destKeyNamePrefix |
|
|
|
return dataActualPath, size, nil |
|
|
|
} |
|
|
|
|
|
|
|
func downloadModelFromCloudBrainOne(modelUUID string, jobName string, parentDir string, trainUrl string) (string, int64, error) { |
|
|
|
func downloadModelFromCloudBrainOne(modelUUID string, jobName string, parentDir string, trainUrl string, modelSelectedFile string) (string, int64, error) { |
|
|
|
modelActualPath := storage.GetMinioPath(jobName, "/model/") |
|
|
|
log.Info("modelActualPath=" + modelActualPath) |
|
|
|
modelSrcPrefix := setting.CBCodePathPrefix + jobName + "/model/" |
|
|
|
destKeyNamePrefix := Model_prefix + models.AttachmentRelativePath(modelUUID) + "/" |
|
|
|
bucketName := setting.Attachment.Minio.Bucket |
|
|
|
log.Info("destKeyNamePrefix=" + destKeyNamePrefix + " modelSrcPrefix=" + modelSrcPrefix + " bucket=" + bucketName) |
|
|
|
size, err := storage.MinioPathCopy(bucketName, modelSrcPrefix, destKeyNamePrefix) |
|
|
|
filterFiles := strings.Split(modelSelectedFile, ";") |
|
|
|
size, err := storage.MinioCopyFiles(bucketName, modelSrcPrefix, destKeyNamePrefix, filterFiles) |
|
|
|
if err == nil { |
|
|
|
dataActualPath := bucketName + "/" + destKeyNamePrefix |
|
|
|
return dataActualPath, size, nil |
|
|
|
|