|
|
|
@@ -202,7 +202,7 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
gpuQueue := setting.JobType |
|
|
|
codePath := setting.JobPath + jobName + cloudbrain.CodeMountPath |
|
|
|
resourceSpecId := form.ResourceSpecId |
|
|
|
|
|
|
|
|
|
|
|
if !jobNamePattern.MatchString(jobName) { |
|
|
|
ctx.RenderWithErr(ctx.Tr("repo.cloudbrain_jobname_err"), tplModelArtsNew, &form) |
|
|
|
return |
|
|
|
@@ -474,7 +474,7 @@ func CloudBrainDel(ctx *context.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if task.Status != string(models.JobStopped) && task.Status != string(models.JobFailed){ |
|
|
|
if task.Status != string(models.JobStopped) && task.Status != string(models.JobFailed) { |
|
|
|
log.Error("the job(%s) has not been stopped", task.JobName, ctx.Data["msgID"]) |
|
|
|
ctx.ServerError("the job has not been stopped", errors.New("the job has not been stopped")) |
|
|
|
return |
|
|
|
@@ -584,19 +584,47 @@ func CloudBrainDownloadModel(ctx *context.Context) { |
|
|
|
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) |
|
|
|
} |
|
|
|
|
|
|
|
// func TrainJobloadModel(ctx *context.Context) { |
|
|
|
// parentDir := ctx.Query("parentDir") |
|
|
|
// fileName := ctx.Query("fileName") |
|
|
|
// jobName := ctx.Query("jobName") |
|
|
|
// filePath := "jobs/" + jobName + "/model/" + parentDir |
|
|
|
// url, err := storage.Attachments.PresignedGetURL(filePath, fileName) |
|
|
|
// if err != nil { |
|
|
|
// log.Error("PresignedGetURL failed: %v", err.Error(), ctx.Data["msgID"]) |
|
|
|
// ctx.ServerError("PresignedGetURL", err) |
|
|
|
// return |
|
|
|
// } |
|
|
|
|
|
|
|
// http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) |
|
|
|
// } |
|
|
|
|
|
|
|
func TrainJobloadModel(ctx *context.Context) { |
|
|
|
parentDir := ctx.Query("parentDir") |
|
|
|
fileName := ctx.Query("fileName") |
|
|
|
jobName := ctx.Query("jobName") |
|
|
|
filePath := "jobs/" + jobName + "/model/" + parentDir |
|
|
|
url, err := storage.Attachments.PresignedGetURL(filePath, fileName) |
|
|
|
uuid := ctx.Query("uuid") |
|
|
|
fileName := ctx.Query("file_name") |
|
|
|
|
|
|
|
body, err := storage.ObsDownload(uuid, fileName) |
|
|
|
if err != nil { |
|
|
|
log.Error("PresignedGetURL failed: %v", err.Error(), ctx.Data["msgID"]) |
|
|
|
ctx.ServerError("PresignedGetURL", err) |
|
|
|
return |
|
|
|
log.Info("download error.") |
|
|
|
} else { |
|
|
|
defer body.Close() |
|
|
|
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+fileName) |
|
|
|
ctx.Resp.Header().Set("Content-Type", "application/octet-stream") |
|
|
|
p := make([]byte, 1024) |
|
|
|
var readErr error |
|
|
|
var readCount int |
|
|
|
// 读取对象内容 |
|
|
|
for { |
|
|
|
readCount, readErr = body.Read(p) |
|
|
|
if readCount > 0 { |
|
|
|
ctx.Resp.Write(p[:readCount]) |
|
|
|
//fmt.Printf("%s", p[:readCount]) |
|
|
|
} |
|
|
|
if readErr != nil { |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) |
|
|
|
} |
|
|
|
|
|
|
|
func GetRate(ctx *context.Context) { |
|
|
|
|