|
@@ -4,6 +4,7 @@ import ( |
|
|
"encoding/json" |
|
|
"encoding/json" |
|
|
"errors" |
|
|
"errors" |
|
|
"io" |
|
|
"io" |
|
|
|
|
|
"io/ioutil" |
|
|
"net/http" |
|
|
"net/http" |
|
|
"os" |
|
|
"os" |
|
|
"path" |
|
|
"path" |
|
@@ -643,18 +644,26 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
attach, err := models.GetAttachmentByUUID(uuid) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Error("GetAttachmentByUUID(%s) failed:%v", uuid, err.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//todo: del the codeLocalPath |
|
|
|
|
|
_, err = ioutil.ReadDir(codeLocalPath) |
|
|
|
|
|
if err == nil { |
|
|
|
|
|
os.RemoveAll(codeLocalPath) |
|
|
|
|
|
} |
|
|
if err := git.Clone(repo.RepoPath(), codeLocalPath, git.CloneRepoOptions{}); err != nil { |
|
|
if err := git.Clone(repo.RepoPath(), codeLocalPath, git.CloneRepoOptions{}); err != nil { |
|
|
log.Error("创建任务失败,任务名称已存在!: %s (%v)", repo.FullName(), err) |
|
|
log.Error("创建任务失败,任务名称已存在!: %s (%v)", repo.FullName(), err) |
|
|
trainJobNewDataPrepare(ctx) |
|
|
trainJobNewDataPrepare(ctx) |
|
|
attach, err := models.GetAttachmentByUUID(uuid) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Error("GetAttachmentByUUID(%s) failed:%v", uuid, err.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["bootFile"] = form.BootFile |
|
|
ctx.Data["bootFile"] = form.BootFile |
|
|
ctx.Data["uuid"] = form.Attachment |
|
|
ctx.Data["uuid"] = form.Attachment |
|
|
ctx.Data["datasetName"] = attach.Name |
|
|
ctx.Data["datasetName"] = attach.Name |
|
|
ctx.Data["params"] = form.Params |
|
|
ctx.Data["params"] = form.Params |
|
|
|
|
|
trainJobNewDataPrepare(ctx) |
|
|
// ctx.RenderWithErr("Failed to clone repository", tplModelArtsTrainJobNew, &form) |
|
|
// ctx.RenderWithErr("Failed to clone repository", tplModelArtsTrainJobNew, &form) |
|
|
ctx.RenderWithErr("创建任务失败,任务名称已存在!", tplModelArtsTrainJobNew, &form) |
|
|
ctx.RenderWithErr("创建任务失败,任务名称已存在!", tplModelArtsTrainJobNew, &form) |
|
|
// ctx.RenderWithErr(err, tplModelArtsTrainJobNew, &form) |
|
|
// ctx.RenderWithErr(err, tplModelArtsTrainJobNew, &form) |
|
@@ -763,15 +772,10 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) |
|
|
Parameters: param, |
|
|
Parameters: param, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
err := modelarts.GenerateTrainJob(ctx, req) |
|
|
|
|
|
|
|
|
err = modelarts.GenerateTrainJob(ctx, req) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Error("GenerateTrainJob failed:%v", err.Error()) |
|
|
log.Error("GenerateTrainJob failed:%v", err.Error()) |
|
|
trainJobNewDataPrepare(ctx) |
|
|
trainJobNewDataPrepare(ctx) |
|
|
attach, err := models.GetAttachmentByUUID(uuid) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Error("GetAttachmentByUUID(%s) failed:%v", uuid, err.Error()) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
ctx.Data["bootFile"] = form.BootFile |
|
|
ctx.Data["bootFile"] = form.BootFile |
|
|
ctx.Data["uuid"] = form.Attachment |
|
|
ctx.Data["uuid"] = form.Attachment |
|
|
ctx.Data["datasetName"] = attach.Name |
|
|
ctx.Data["datasetName"] = attach.Name |
|
|