|
|
@@ -11,11 +11,10 @@ import ( |
|
|
"strings" |
|
|
"strings" |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/cloudbrain" |
|
|
|
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
"code.gitea.io/gitea/models" |
|
|
"code.gitea.io/gitea/modules/auth" |
|
|
"code.gitea.io/gitea/modules/auth" |
|
|
"code.gitea.io/gitea/modules/base" |
|
|
"code.gitea.io/gitea/modules/base" |
|
|
|
|
|
"code.gitea.io/gitea/modules/cloudbrain" |
|
|
"code.gitea.io/gitea/modules/context" |
|
|
"code.gitea.io/gitea/modules/context" |
|
|
"code.gitea.io/gitea/modules/git" |
|
|
"code.gitea.io/gitea/modules/git" |
|
|
"code.gitea.io/gitea/modules/log" |
|
|
"code.gitea.io/gitea/modules/log" |
|
|
@@ -249,7 +248,7 @@ func NotebookManage(ctx *context.Context) { |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if !ctx.IsSigned || (ctx.User.ID != task.UserID && !ctx.IsUserSiteAdmin() && !ctx.IsUserRepoOwner()){ |
|
|
|
|
|
|
|
|
if !ctx.IsSigned || (ctx.User.ID != task.UserID && !ctx.IsUserSiteAdmin() && !ctx.IsUserRepoOwner()) { |
|
|
log.Error("the user has no right ro stop the job", task.JobName, ctx.Data["MsgID"]) |
|
|
log.Error("the user has no right ro stop the job", task.JobName, ctx.Data["MsgID"]) |
|
|
resultCode = "-1" |
|
|
resultCode = "-1" |
|
|
errorMsg = "you have no right to stop the job" |
|
|
errorMsg = "you have no right to stop the job" |
|
|
@@ -263,7 +262,7 @@ func NotebookManage(ctx *context.Context) { |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if !ctx.IsSigned || (ctx.User.ID != task.UserID && !ctx.IsUserSiteAdmin()){ |
|
|
|
|
|
|
|
|
if !ctx.IsSigned || (ctx.User.ID != task.UserID && !ctx.IsUserSiteAdmin()) { |
|
|
log.Error("the user has no right ro restart the job", task.JobName, ctx.Data["MsgID"]) |
|
|
log.Error("the user has no right ro restart the job", task.JobName, ctx.Data["MsgID"]) |
|
|
resultCode = "-1" |
|
|
resultCode = "-1" |
|
|
errorMsg = "you have no right to restart the job" |
|
|
errorMsg = "you have no right to restart the job" |
|
|
@@ -1413,6 +1412,11 @@ func TrainJobDel(ctx *context.Context) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//删除存储 |
|
|
|
|
|
if len(VersionListTasks) > 0 { |
|
|
|
|
|
DeleteJobStorage(VersionListTasks[0].JobName) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts/train-job") |
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelarts/train-job") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -1538,3 +1542,21 @@ func ModelDownload(ctx *context.Context) { |
|
|
} |
|
|
} |
|
|
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) |
|
|
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
} |