|
|
|
@@ -5,6 +5,7 @@ import ( |
|
|
|
"code.gitea.io/gitea/modules/modelarts" |
|
|
|
"code.gitea.io/gitea/modules/obs" |
|
|
|
"code.gitea.io/gitea/modules/storage" |
|
|
|
"encoding/json" |
|
|
|
"errors" |
|
|
|
"github.com/unknwon/com" |
|
|
|
"io" |
|
|
|
@@ -297,10 +298,23 @@ func TrainJobNew(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Data["attachments"] = attachs |
|
|
|
ctx.Data["dataset_path"] = modelarts.DataSetMountPath |
|
|
|
ctx.Data["env"] = modelarts.NotebookEnv |
|
|
|
ctx.Data["notebook_type"] = modelarts.NotebookType |
|
|
|
ctx.Data["flavor"] = modelarts.FlavorInfo |
|
|
|
ctx.Data["engine"] = modelarts.Engine |
|
|
|
|
|
|
|
var versionInfos modelarts.VersionInfo |
|
|
|
if err = json.Unmarshal([]byte(modelarts.EngineVersions), &versionInfos); err != nil { |
|
|
|
ctx.ServerError("json.Unmarshal failed:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Data["engine_versions"] = versionInfos |
|
|
|
|
|
|
|
var flavorInfos modelarts.Flavor |
|
|
|
if err = json.Unmarshal([]byte(modelarts.FlavorInfos), &flavorInfos); err != nil { |
|
|
|
ctx.ServerError("json.Unmarshal failed:", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Data["flavor_infos"] = flavorInfos |
|
|
|
ctx.HTML(200, tplModelArtsTrainJobNew) |
|
|
|
} |
|
|
|
|
|
|
|
@@ -310,12 +324,13 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) |
|
|
|
uuid := form.Attachment |
|
|
|
description := form.Description |
|
|
|
workServerNumber := form.WorkServerNumber |
|
|
|
engineID := form.EngineID |
|
|
|
bootFile := form.BootFile |
|
|
|
repo := ctx.Repo.Repository |
|
|
|
codeLocalPath := setting.JobPath + jobName + modelarts.CodePath |
|
|
|
codeObsPath := setting.Bucket + modelarts.JobPath + jobName + modelarts.CodePath |
|
|
|
outputObsPath := setting.Bucket + modelarts.JobPath + jobName + modelarts.OutputPath |
|
|
|
dataPath := setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + "/" |
|
|
|
codeObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.CodePath |
|
|
|
outputObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.OutputPath |
|
|
|
dataPath := "/" + setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + "/" |
|
|
|
|
|
|
|
if err := git.Clone(repo.RepoPath(), codeLocalPath, git.CloneRepoOptions{}); err != nil { |
|
|
|
log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err) |
|
|
|
@@ -335,9 +350,10 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) |
|
|
|
DataUrl: dataPath, |
|
|
|
Description: description, |
|
|
|
CodeObsPath: codeObsPath, |
|
|
|
BootFile: bootFile, |
|
|
|
BootFile: codeObsPath + "/" + bootFile, |
|
|
|
TrainUrl: outputObsPath, |
|
|
|
WorkServerNumber: workServerNumber, |
|
|
|
EngineID: int64(engineID), |
|
|
|
} |
|
|
|
|
|
|
|
err := modelarts.GenerateTrainJob(ctx, req) |
|
|
|
|