|
|
|
@@ -2,6 +2,7 @@ package repo |
|
|
|
|
|
|
|
import ( |
|
|
|
"archive/zip" |
|
|
|
"encoding/json" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"net/http" |
|
|
|
@@ -56,20 +57,35 @@ func SaveModelByParameters(jobId string, name string, version string, label stri |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
accuracy := make(map[string]string) |
|
|
|
accuracy["F1"] = "" |
|
|
|
accuracy["Recall"] = "" |
|
|
|
accuracy["Accuracy"] = "" |
|
|
|
accuracy["Precision"] = "" |
|
|
|
accuracyJson, _ := json.Marshal(accuracy) |
|
|
|
log.Info("accuracyJson=" + string(accuracyJson)) |
|
|
|
aiTaskJson, _ := json.Marshal(aiTask) |
|
|
|
|
|
|
|
//taskConfigInfo,err := models.GetCloudbrainByJobIDAndVersionName(jobId,aiTask.VersionName) |
|
|
|
model := &models.AiModelManage{ |
|
|
|
ID: id, |
|
|
|
Version: version, |
|
|
|
Label: label, |
|
|
|
Name: name, |
|
|
|
Description: description, |
|
|
|
New: MODEL_LATEST, |
|
|
|
Type: cloudType, |
|
|
|
Path: modelPath, |
|
|
|
Size: modelSize, |
|
|
|
AttachmentId: aiTask.Uuid, |
|
|
|
RepoId: aiTask.RepoID, |
|
|
|
UserId: userId, |
|
|
|
ID: id, |
|
|
|
Version: version, |
|
|
|
Label: label, |
|
|
|
Name: name, |
|
|
|
Description: description, |
|
|
|
New: MODEL_LATEST, |
|
|
|
Type: cloudType, |
|
|
|
Path: modelPath, |
|
|
|
Size: modelSize, |
|
|
|
AttachmentId: aiTask.Uuid, |
|
|
|
RepoId: aiTask.RepoID, |
|
|
|
UserId: userId, |
|
|
|
CodeBranch: "", |
|
|
|
CodeCommitID: aiTask.CommitID, |
|
|
|
Engine: aiTask.EngineID, |
|
|
|
ConfigJson: "", |
|
|
|
TrainTaskInfo: string(aiTaskJson), |
|
|
|
Accuracy: string(accuracyJson), |
|
|
|
} |
|
|
|
|
|
|
|
models.SaveModelToDb(model) |
|
|
|
@@ -190,6 +206,9 @@ func DownloadMultiModelFile(ctx *context.Context) { |
|
|
|
|
|
|
|
allFile, err := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, path) |
|
|
|
if err == nil { |
|
|
|
//count++ |
|
|
|
models.ModifyModelDownloadCount(id) |
|
|
|
|
|
|
|
returnFileName := task.Name + "_" + task.Version + ".zip" |
|
|
|
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+returnFileName) |
|
|
|
ctx.Resp.Header().Set("Content-Type", "application/octet-stream") |
|
|
|
@@ -247,6 +266,8 @@ func DownloadSingleModelFile(ctx *context.Context) { |
|
|
|
if err != nil { |
|
|
|
log.Info("download error.") |
|
|
|
} else { |
|
|
|
//count++ |
|
|
|
models.ModifyModelDownloadCount(id) |
|
|
|
defer body.Close() |
|
|
|
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+fileName) |
|
|
|
ctx.Resp.Header().Set("Content-Type", "application/octet-stream") |
|
|
|
@@ -272,6 +293,8 @@ func DownloadSingleModelFile(ctx *context.Context) { |
|
|
|
ctx.ServerError("GetObsCreateSignedUrl", err) |
|
|
|
return |
|
|
|
} |
|
|
|
//count++ |
|
|
|
models.ModifyModelDownloadCount(id) |
|
|
|
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) |
|
|
|
} |
|
|
|
} |
|
|
|
|