|
|
@@ -1894,6 +1894,9 @@ func inferenceJobErrorNewDataPrepare(ctx *context.Context, form auth.CreateModel |
|
|
|
ctx.Data["bootFile"] = form.BootFile |
|
|
|
ctx.Data["uuid"] = form.Attachment |
|
|
|
ctx.Data["branch_name"] = form.BranchName |
|
|
|
ctx.Data["model_name"] = form.ModelName |
|
|
|
ctx.Data["model_version"] = form.ModelVersion |
|
|
|
ctx.Data["ckpt_name"] = form.CkptName |
|
|
|
|
|
|
|
return nil |
|
|
|
} |
|
|
@@ -1945,52 +1948,6 @@ func InferenceJobShow(ctx *context.Context) { |
|
|
|
ctx.Data["task"] = task |
|
|
|
ctx.HTML(http.StatusOK, tplModelArtsInferenceJobShow) |
|
|
|
} |
|
|
|
func InferenceJobStop(ctx *context.Context) { |
|
|
|
var jobID = ctx.Params(":jobid") |
|
|
|
task, err := models.GetCloudbrainByJobID(jobID) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetCloudbrainByJobID(%s) failed:%v", task.JobName, err.Error()) |
|
|
|
ctx.RenderWithErr(err.Error(), tplModelArtsInferenceJobIndex, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
_, err = modelarts.StopTrainJob(jobID, strconv.FormatInt(task.VersionID, 10)) |
|
|
|
if err != nil { |
|
|
|
log.Error("StopInferenceJob(%s) failed:%v", task.JobName, err.Error()) |
|
|
|
ctx.RenderWithErr(err.Error(), tplModelArtsInferenceJobIndex, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts/inference-job") |
|
|
|
} |
|
|
|
|
|
|
|
func InferenceJobDel(ctx *context.Context) { |
|
|
|
var jobID = ctx.Params(":jobid") |
|
|
|
|
|
|
|
task, err := models.GetCloudbrainByJobID(jobID) |
|
|
|
if err != nil { |
|
|
|
log.Error("GetCloudbrainByJobID(%s) failed:%v", task.JobName, err.Error()) |
|
|
|
ctx.RenderWithErr(err.Error(), tplModelArtsInferenceJobIndex, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//删除modelarts上的任务记录 |
|
|
|
_, err = modelarts.DelTrainJob(jobID) |
|
|
|
if err != nil { |
|
|
|
log.Error("DelInferenceJob(%s) failed:%v", jobID, err.Error()) |
|
|
|
ctx.RenderWithErr(err.Error(), tplModelArtsInferenceJobIndex, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//删除数据库Cloudbrain表的记录 |
|
|
|
err = models.DeleteJob(task) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("DeleteJob failed", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts/inference-job") |
|
|
|
} |
|
|
|
|
|
|
|
func ResultDownload(ctx *context.Context) { |
|
|
|
var ( |
|
|
@@ -2036,28 +1993,27 @@ func DeleteJobStorage(jobName string) error { |
|
|
|
} |
|
|
|
|
|
|
|
func DownloadMultiResultFile(ctx *context.Context) { |
|
|
|
log.Info("DownloadMultiModelFile start.") |
|
|
|
id := ctx.Query("ID") |
|
|
|
log.Info("id=" + id) |
|
|
|
task, err := models.QueryModelById(id) |
|
|
|
var jobID = ctx.Params(":jobid") |
|
|
|
var versionName = ctx.Query("version_name") |
|
|
|
task, err := models.GetCloudbrainByJobIDAndVersionName(jobID, versionName) |
|
|
|
if err != nil { |
|
|
|
log.Error("no such model!", err.Error()) |
|
|
|
ctx.ServerError("no such model:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
if !isCanDeleteOrDownload(ctx, task) { |
|
|
|
ctx.ServerError("no right.", errors.New(ctx.Tr("repo.model_noright"))) |
|
|
|
log.Error("GetCloudbrainByJobID(%s) failed:%v", task.JobName, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
// if !isCanDeleteOrDownload(ctx, task) { |
|
|
|
// ctx.ServerError("no right.", errors.New(ctx.Tr("repo.model_noright"))) |
|
|
|
// return |
|
|
|
// } |
|
|
|
|
|
|
|
path := Model_prefix + models.AttachmentRelativePath(id) + "/" |
|
|
|
// path := Model_prefix + models.AttachmentRelativePath(id) + "/" |
|
|
|
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) |
|
|
|
// models.ModifyModelDownloadCount(id) |
|
|
|
|
|
|
|
returnFileName := task.Name + "_" + task.Version + ".zip" |
|
|
|
returnFileName := task.JobName + "_" + task.VersionName + ".zip" |
|
|
|
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+returnFileName) |
|
|
|
ctx.Resp.Header().Set("Content-Type", "application/octet-stream") |
|
|
|
w := zip.NewWriter(ctx.Resp) |
|
|
|