|
|
|
@@ -528,23 +528,33 @@ func QueryTrainJobList(ctx *context.Context) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func QueryTrainModelList(ctx *context.Context) { |
|
|
|
log.Info("query train job list. start.") |
|
|
|
jobName := ctx.Query("jobName") |
|
|
|
taskType := ctx.QueryInt("type") |
|
|
|
VersionName := ctx.Query("versionName") |
|
|
|
if VersionName == "" { |
|
|
|
VersionName = ctx.Query("VersionName") |
|
|
|
func QueryTrainModelFileById(ctx *context.Context) ([]storage.FileInfo, error) { |
|
|
|
JobID := ctx.Query("jobId") |
|
|
|
VersionListTasks, count, err := models.QueryModelTrainJobVersionList(JobID) |
|
|
|
if err == nil { |
|
|
|
if count == 1 { |
|
|
|
task := VersionListTasks[0] |
|
|
|
jobName := task.JobName |
|
|
|
taskType := task.Type |
|
|
|
VersionName := task.VersionName |
|
|
|
modelDbResult, err := getModelFromObjectSave(jobName, taskType, VersionName) |
|
|
|
return modelDbResult, err |
|
|
|
} |
|
|
|
} |
|
|
|
log.Info("get TypeCloudBrainTwo TrainJobListModel failed:", err) |
|
|
|
return nil, errors.New("Not found task.") |
|
|
|
} |
|
|
|
|
|
|
|
func getModelFromObjectSave(jobName string, taskType int, VersionName string) ([]storage.FileInfo, error) { |
|
|
|
if taskType == models.TypeCloudBrainTwo { |
|
|
|
objectkey := path.Join(setting.TrainJobModelPath, jobName, setting.OutPutPath, VersionName) + "/" |
|
|
|
modelDbResult, err := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, objectkey) |
|
|
|
log.Info("bucket=" + setting.Bucket + " objectkey=" + objectkey) |
|
|
|
if err != nil { |
|
|
|
log.Info("get TypeCloudBrainTwo TrainJobListModel failed:", err) |
|
|
|
return nil, err |
|
|
|
} else { |
|
|
|
ctx.JSON(200, modelDbResult) |
|
|
|
return |
|
|
|
return modelDbResult, nil |
|
|
|
} |
|
|
|
} else if taskType == models.TypeCloudBrainOne { |
|
|
|
modelSrcPrefix := setting.CBCodePathPrefix + jobName + "/model/" |
|
|
|
@@ -552,12 +562,30 @@ func QueryTrainModelList(ctx *context.Context) { |
|
|
|
modelDbResult, err := storage.GetAllObjectByBucketAndPrefixMinio(bucketName, modelSrcPrefix) |
|
|
|
if err != nil { |
|
|
|
log.Info("get TypeCloudBrainOne TrainJobListModel failed:", err) |
|
|
|
return nil, err |
|
|
|
} else { |
|
|
|
ctx.JSON(200, modelDbResult) |
|
|
|
return |
|
|
|
return modelDbResult, nil |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.JSON(200, "") |
|
|
|
return nil, errors.New("Not support.") |
|
|
|
} |
|
|
|
|
|
|
|
func QueryTrainModelList(ctx *context.Context) { |
|
|
|
log.Info("query train job list. start.") |
|
|
|
jobName := ctx.Query("jobName") |
|
|
|
taskType := ctx.QueryInt("type") |
|
|
|
VersionName := ctx.Query("versionName") |
|
|
|
if VersionName == "" { |
|
|
|
VersionName = ctx.Query("VersionName") |
|
|
|
} |
|
|
|
modelDbResult, err := getModelFromObjectSave(jobName, taskType, VersionName) |
|
|
|
if err != nil { |
|
|
|
log.Info("get TypeCloudBrainTwo TrainJobListModel failed:", err) |
|
|
|
ctx.JSON(200, "") |
|
|
|
} else { |
|
|
|
ctx.JSON(200, modelDbResult) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func DownloadSingleModelFile(ctx *context.Context) { |
|
|
|
|