|
|
|
@@ -17,6 +17,8 @@ import ( |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/grampus" |
|
|
|
|
|
|
|
cloudbrainService "code.gitea.io/gitea/services/cloudbrain" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/convert" |
|
|
|
@@ -80,6 +82,30 @@ func CloudBrainShow(ctx *context.APIContext) { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseMessageWithDataApi{Code: 0, Message: "", Data: convert.ToCloudBrain(task)}) |
|
|
|
|
|
|
|
} |
|
|
|
func GeneralCloudBrainJobStop(ctx *context.APIContext) { |
|
|
|
task := ctx.Cloudbrain |
|
|
|
if task.IsTerminal() { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi("cloudbrain.Already_stopped")) |
|
|
|
return |
|
|
|
} |
|
|
|
var err error |
|
|
|
|
|
|
|
if ctx.Cloudbrain.Type == models.TypeCloudBrainOne { |
|
|
|
err = cloudbrain.StopJob(task.JobID) |
|
|
|
} else if ctx.Cloudbrain.Type == models.TypeCloudBrainTwo { |
|
|
|
_, err = modelarts.StopTrainJob(task.JobID, strconv.FormatInt(task.VersionID, 10)) |
|
|
|
} else { |
|
|
|
_, err = grampus.StopJob(task.JobID) |
|
|
|
} |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
log.Warn("cloud brain stopped failed.", err) |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessageApi("cloudbrain.Stopped_failed")) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, models.BaseOKMessageApi) |
|
|
|
} |
|
|
|
func CreateFileNoteBook(ctx *context.APIContext, option api.CreateFileNotebookJobOption) { |
|
|
|
cloudbrainTask.FileNotebookCreate(ctx.Context, option) |
|
|
|
} |
|
|
|
|