Browse Source

del train job storage

tags/v1.21.12.2^2
lewis 4 years ago
parent
commit
027d476a66
2 changed files with 25 additions and 3 deletions
  1. +23
    -1
      routers/api/v1/repo/modelarts.go
  2. +2
    -2
      routers/repo/cloudbrain.go

+ 23
- 1
routers/api/v1/repo/modelarts.go View File

@@ -6,7 +6,9 @@
package repo

import (
"code.gitea.io/gitea/modules/setting"
"net/http"
"os"
"strconv"
"strings"

@@ -237,7 +239,7 @@ func DelTrainJobVersion(ctx *context.APIContext) {
JobID: jobID,
})
if err != nil {
ctx.ServerError("get VersionListCount faild", err)
ctx.ServerError("get VersionListCount failed", err)
return
}
if VersionListCount > 0 {
@@ -255,6 +257,8 @@ func DelTrainJobVersion(ctx *context.APIContext) {
return
}
}
} else { //已删除该任务下的所有版本
deleteJobStorage(task.JobName)
}

ctx.JSON(http.StatusOK, map[string]interface{}{
@@ -321,3 +325,21 @@ func ModelList(ctx *context.APIContext) {
"PageIsCloudBrain": true,
})
}

func deleteJobStorage(jobName string) error {
//delete local
localJobPath := setting.JobPath + jobName
err := os.RemoveAll(localJobPath)
if err != nil {
log.Error("RemoveAll(%s) failed:%v", localJobPath, err)
}

//delete oss
dirPath := setting.CodePathPrefix + jobName + "/"
err = storage.ObsRemoveObject(setting.Bucket, dirPath)
if err != nil {
log.Error("ObsRemoveObject(%s) failed:%v", localJobPath, err)
}
return nil
}

+ 2
- 2
routers/repo/cloudbrain.go View File

@@ -567,7 +567,7 @@ func CloudBrainDel(ctx *context.Context) {
return
}

deleteJobName(task.JobName, models.TypeCloudBrainOne)
deleteJobStorage(task.JobName, models.TypeCloudBrainOne)
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob")
}

@@ -842,7 +842,7 @@ func mkModelPath(modelPath string) error {
return nil
}

func deleteJobName(jobName string, cloudbrainType int) error {
func deleteJobStorage(jobName string, cloudbrainType int) error {
//delete local
localJobPath := setting.JobPath + jobName
err := os.RemoveAll(localJobPath)


Loading…
Cancel
Save