diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 419c6d6a4..79e35812e 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -6,13 +6,14 @@ package repo import ( - "code.gitea.io/gitea/modules/notification" "encoding/json" "net/http" "path" "strconv" "strings" + "code.gitea.io/gitea/modules/notification" + "code.gitea.io/gitea/modules/grampus" "code.gitea.io/gitea/modules/setting" @@ -352,6 +353,14 @@ func DelTrainJobVersion(ctx *context.APIContext) { return } + if task.Status != string(models.ModelArtsTrainJobImageFailed) && task.Status != string(models.ModelArtsTrainJobSubmitFailed) && task.Status != string(models.ModelArtsTrainJobDeleteFailed) && + task.Status != string(models.ModelArtsTrainJobCompleted) && task.Status != string(models.ModelArtsTrainJobFailed) && + task.Status != string(models.ModelArtsTrainJobKilled) && task.Status != string(models.ModelArtsTrainJobCanceled) && task.Status != string(models.ModelArtsTrainJobLost) { + log.Error("the job(%s) version has not been stopped", task.JobName) + ctx.NotFound(err) + return + } + //删除modelarts上的记录 _, err = modelarts.DelTrainJobVersion(jobID, strconv.FormatInt(task.VersionID, 10)) if err != nil { diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 763308930..237591635 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -1839,6 +1839,16 @@ func TrainJobDel(ctx *context.Context) { return } + for _, task := range VersionListTasks { + if task.Status != string(models.ModelArtsTrainJobImageFailed) && task.Status != string(models.ModelArtsTrainJobSubmitFailed) && task.Status != string(models.ModelArtsTrainJobDeleteFailed) && + task.Status != string(models.ModelArtsTrainJobCompleted) && task.Status != string(models.ModelArtsTrainJobFailed) && + task.Status != string(models.ModelArtsTrainJobKilled) && task.Status != string(models.ModelArtsTrainJobCanceled) && task.Status != string(models.ModelArtsTrainJobLost) { + log.Error("the job(%s) version has not been stopped", task.JobName) + ctx.RenderWithErr("the job version has not been stopped", tplModelArtsTrainJobIndex, nil) + return + } + } + //删除modelarts上的任务记录 _, err = modelarts.DelTrainJob(jobID) if err != nil {