diff --git a/models/cloudbrain.go b/models/cloudbrain.go index a8a250478..f691830c3 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -1238,6 +1238,12 @@ func GetCloudbrainTrainJobCountByUserID(userID int64) (int, error) { return int(count), err } +func GetCloudbrainInferenceJobCountByUserID(userID int64) (int, error) { + count, err := x.In("status", ModelArtsTrainJobInit, ModelArtsTrainJobImageCreating, ModelArtsTrainJobSubmitTrying, ModelArtsTrainJobWaiting, ModelArtsTrainJobRunning, ModelArtsTrainJobScaling, ModelArtsTrainJobCheckInit, ModelArtsTrainJobCheckRunning, ModelArtsTrainJobCheckRunningCompleted). + And("job_type = ? and user_id = ? and type = ?", JobTypeInference, userID, TypeCloudBrainTwo).Count(new(Cloudbrain)) + return int(count), err +} + func UpdateInferenceJob(job *Cloudbrain) error { return updateJobInferenceJob(x, job) } diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index c28f18f5d..929c745f4 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -1588,17 +1588,17 @@ func InferenceJobCreate(ctx *context.Context, form auth.CreateModelArtsInference ckptUrl := form.TrainUrl + form.CkptName - count, err := models.GetCloudbrainTrainJobCountByUserID(ctx.User.ID) + count, err := models.GetCloudbrainInferenceJobCountByUserID(ctx.User.ID) if err != nil { - log.Error("GetCloudbrainTrainJobCountByUserID failed:%v", err, ctx.Data["MsgID"]) + log.Error("GetCloudbrainInferenceJobCountByUserID failed:%v", err, ctx.Data["MsgID"]) inferenceJobErrorNewDataPrepare(ctx, form) ctx.RenderWithErr("system error", tplModelArtsInferenceJobNew, &form) return } else { if count >= 1 { - log.Error("the user already has running or waiting task", ctx.Data["MsgID"]) + log.Error("the user already has running or waiting inference task", ctx.Data["MsgID"]) inferenceJobErrorNewDataPrepare(ctx, form) - ctx.RenderWithErr("you have already a running or waiting task, can not create more", tplModelArtsInferenceJobNew, &form) + ctx.RenderWithErr("you have already a running or waiting inference task, can not create more", tplModelArtsInferenceJobNew, &form) return } } @@ -1786,7 +1786,7 @@ func inferenceJobNewDataPrepare(ctx *context.Context) error { ctx.Data["PageIsCloudBrain"] = true t := time.Now() - var jobName = "inference" + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:] + var jobName = cutString(ctx.User.Name, 5) + t.Format("2006010215") + strconv.Itoa(int(t.Unix()))[5:] ctx.Data["job_name"] = jobName attachs, err := models.GetModelArtsTrainAttachments(ctx.User.ID) @@ -1946,6 +1946,7 @@ func InferenceJobShow(ctx *context.Context) { ctx.Data["jobID"] = jobID ctx.Data["jobName"] = task.JobName ctx.Data["task"] = task + ctx.Data["userName"] = ctx.User.Name ctx.HTML(http.StatusOK, tplModelArtsInferenceJobShow) } @@ -2006,14 +2007,14 @@ func DownloadMultiResultFile(ctx *context.Context) { // } // path := Model_prefix + models.AttachmentRelativePath(id) + "/" - path := strings.TrimPrefix(path.Join(setting.TrainJobModelPath, task.JobName, "result/", versionName), "/") + path := strings.TrimPrefix(path.Join(setting.TrainJobModelPath, task.JobName, "result/", versionName), "/") + "/" allFile, err := storage.GetAllObjectByBucketAndPrefix(setting.Bucket, path) if err == nil { //count++ // models.ModifyModelDownloadCount(id) - returnFileName := task.JobName + "_" + task.VersionName + ".zip" + returnFileName := task.JobName + ".zip" ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+returnFileName) ctx.Resp.Header().Set("Content-Type", "application/octet-stream") w := zip.NewWriter(ctx.Resp) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 45ebe9690..96ee3de92 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -1036,7 +1036,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("", reqRepoCloudBrainReader, repo.InferenceJobIndex) m.Group("/:jobid", func() { m.Get("", reqRepoCloudBrainReader, repo.InferenceJobShow) - m.Get("/downloadall", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.DownloadMultiResultFile) + m.Get("/downloadall", repo.DownloadMultiResultFile) }) m.Get("/create", reqRepoCloudBrainWriter, repo.InferenceJobNew) m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateModelArtsInferenceJobForm{}), repo.InferenceJobCreate) diff --git a/templates/repo/modelarts/inferencejob/index.tmpl b/templates/repo/modelarts/inferencejob/index.tmpl index 44cdbe7db..24731473b 100644 --- a/templates/repo/modelarts/inferencejob/index.tmpl +++ b/templates/repo/modelarts/inferencejob/index.tmpl @@ -157,7 +157,7 @@
{{$.CsrfTokenHtml}} {{if .CanDel}} - + {{$.i18n.Tr "repo.download"}} {{else}}