|
@@ -979,12 +979,26 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) |
|
|
codeObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.CodePath |
|
|
codeObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.CodePath |
|
|
outputObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.OutputPath + VersionOutputPath + "/" |
|
|
outputObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.OutputPath + VersionOutputPath + "/" |
|
|
logObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.LogPath + VersionOutputPath + "/" |
|
|
logObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.LogPath + VersionOutputPath + "/" |
|
|
dataPath := "/" + setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + uuid + "/" |
|
|
|
|
|
|
|
|
// dataPath := "/" + setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + uuid + "/" |
|
|
branch_name := form.BranchName |
|
|
branch_name := form.BranchName |
|
|
isLatestVersion := modelarts.IsLatestVersion |
|
|
isLatestVersion := modelarts.IsLatestVersion |
|
|
FlavorName := form.FlavorName |
|
|
FlavorName := form.FlavorName |
|
|
VersionCount := modelarts.VersionCount |
|
|
VersionCount := modelarts.VersionCount |
|
|
EngineName := form.EngineName |
|
|
EngineName := form.EngineName |
|
|
|
|
|
if IsDatasetUseCountExceed(uuid) { |
|
|
|
|
|
log.Error("DatasetUseCount is Exceed:%v") |
|
|
|
|
|
trainJobErrorNewDataPrepare(ctx, form) |
|
|
|
|
|
ctx.RenderWithErr("DatasetUseCount is Exceed", tplModelArtsTrainJobNew, &form) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
datasetName, err := GetDatasetNameByUUID(uuid) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Error("GetDatasetNameByUUID failed:%v", err, ctx.Data["MsgID"]) |
|
|
|
|
|
trainJobErrorNewDataPrepare(ctx, form) |
|
|
|
|
|
ctx.RenderWithErr("GetDatasetNameByUUID error", tplModelArtsTrainJobNew, &form) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
dataPath := GetObsDataPathByUUID(uuid) |
|
|
|
|
|
|
|
|
count, err := models.GetCloudbrainTrainJobCountByUserID(ctx.User.ID) |
|
|
count, err := models.GetCloudbrainTrainJobCountByUserID(ctx.User.ID) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@@ -1161,6 +1175,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) |
|
|
EngineName: EngineName, |
|
|
EngineName: EngineName, |
|
|
VersionCount: VersionCount, |
|
|
VersionCount: VersionCount, |
|
|
TotalVersionCount: modelarts.TotalVersionCount, |
|
|
TotalVersionCount: modelarts.TotalVersionCount, |
|
|
|
|
|
DatasetName: datasetName, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//将params转换Parameters.Parameter,出错时返回给前端 |
|
|
//将params转换Parameters.Parameter,出错时返回给前端 |
|
@@ -1222,13 +1237,28 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ |
|
|
codeObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.CodePath + VersionOutputPath + "/" |
|
|
codeObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.CodePath + VersionOutputPath + "/" |
|
|
outputObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.OutputPath + VersionOutputPath + "/" |
|
|
outputObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.OutputPath + VersionOutputPath + "/" |
|
|
logObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.LogPath + VersionOutputPath + "/" |
|
|
logObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.LogPath + VersionOutputPath + "/" |
|
|
dataPath := "/" + setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + uuid + "/" |
|
|
|
|
|
|
|
|
// dataPath := "/" + setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + uuid + "/" |
|
|
branch_name := form.BranchName |
|
|
branch_name := form.BranchName |
|
|
PreVersionName := form.VersionName |
|
|
PreVersionName := form.VersionName |
|
|
FlavorName := form.FlavorName |
|
|
FlavorName := form.FlavorName |
|
|
EngineName := form.EngineName |
|
|
EngineName := form.EngineName |
|
|
isLatestVersion := modelarts.IsLatestVersion |
|
|
isLatestVersion := modelarts.IsLatestVersion |
|
|
|
|
|
|
|
|
|
|
|
if IsDatasetUseCountExceed(uuid) { |
|
|
|
|
|
log.Error("DatasetUseCount is Exceed:%v") |
|
|
|
|
|
versionErrorDataPrepare(ctx, form) |
|
|
|
|
|
ctx.RenderWithErr("DatasetUseCount is Exceed", tplModelArtsTrainJobVersionNew, &form) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
datasetName, err := GetDatasetNameByUUID(uuid) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Error("GetDatasetNameByUUID failed:%v", err, ctx.Data["MsgID"]) |
|
|
|
|
|
versionErrorDataPrepare(ctx, form) |
|
|
|
|
|
ctx.RenderWithErr("GetDatasetNameByUUID error", tplModelArtsTrainJobVersionNew, &form) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
dataPath := GetObsDataPathByUUID(uuid) |
|
|
|
|
|
|
|
|
canNewJob, _ := canUserCreateTrainJobVersion(ctx, latestTask.UserID) |
|
|
canNewJob, _ := canUserCreateTrainJobVersion(ctx, latestTask.UserID) |
|
|
if !canNewJob { |
|
|
if !canNewJob { |
|
|
ctx.RenderWithErr("user cann't new trainjob", tplModelArtsTrainJobVersionNew, &form) |
|
|
ctx.RenderWithErr("user cann't new trainjob", tplModelArtsTrainJobVersionNew, &form) |
|
@@ -1386,6 +1416,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ |
|
|
EngineName: EngineName, |
|
|
EngineName: EngineName, |
|
|
PreVersionName: PreVersionName, |
|
|
PreVersionName: PreVersionName, |
|
|
TotalVersionCount: latestTask.TotalVersionCount + 1, |
|
|
TotalVersionCount: latestTask.TotalVersionCount + 1, |
|
|
|
|
|
DatasetName: datasetName, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
err = modelarts.GenerateTrainJobVersion(ctx, req, jobID) |
|
|
err = modelarts.GenerateTrainJobVersion(ctx, req, jobID) |
|
@@ -2420,3 +2451,39 @@ func TrainJobDownloadLogFile(ctx *context.Context) { |
|
|
ctx.Resp.Header().Set("Cache-Control", "max-age=0") |
|
|
ctx.Resp.Header().Set("Cache-Control", "max-age=0") |
|
|
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) |
|
|
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) |
|
|
} |
|
|
} |
|
|
|
|
|
func GetObsDataPathByUUID(uuid string) string { |
|
|
|
|
|
var obsDataPath string |
|
|
|
|
|
uuidList := strings.Split(uuid, ";") |
|
|
|
|
|
for k, _ := range uuidList { |
|
|
|
|
|
if k <= 0 { |
|
|
|
|
|
obsDataPath = "/" + setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + uuid + "/" |
|
|
|
|
|
} |
|
|
|
|
|
if k > 0 { |
|
|
|
|
|
obsDataPathNext := ";" + "s3://" + setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + uuid + "/" |
|
|
|
|
|
obsDataPath = obsDataPath + obsDataPathNext |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
return obsDataPath |
|
|
|
|
|
} |
|
|
|
|
|
func GetDatasetNameByUUID(uuid string) (string, error) { |
|
|
|
|
|
uuidList := strings.Split(uuid, ";") |
|
|
|
|
|
var datasetName string |
|
|
|
|
|
for _, uuidStr := range uuidList { |
|
|
|
|
|
attach, err := models.GetAttachmentByUUID(uuidStr) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Error("GetAttachmentByUUID failed:%v", err) |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
datasetName = datasetName + attach.Name + ";" |
|
|
|
|
|
} |
|
|
|
|
|
return datasetName, nil |
|
|
|
|
|
} |
|
|
|
|
|
func IsDatasetUseCountExceed(uuid string) bool { |
|
|
|
|
|
uuidList := strings.Split(uuid, ";") |
|
|
|
|
|
if len(uuidList) > setting.MaxDatasetNum { |
|
|
|
|
|
return true |
|
|
|
|
|
} else { |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
} |