|
|
|
@@ -1573,6 +1573,7 @@ func ModelDownload(ctx *context.Context) { |
|
|
|
|
|
|
|
func InferenceJobCreate(ctx *context.Context, form auth.CreateModelArtsInferenceJobForm) { |
|
|
|
ctx.Data["PageIsTrainJob"] = true |
|
|
|
VersionOutputPath := modelarts.GetVersionOutputPathByTotalVersionCount(modelarts.TotalVersionCount) |
|
|
|
jobName := form.JobName |
|
|
|
uuid := form.Attachment |
|
|
|
description := form.Description |
|
|
|
@@ -1585,12 +1586,14 @@ func InferenceJobCreate(ctx *context.Context, form auth.CreateModelArtsInference |
|
|
|
repo := ctx.Repo.Repository |
|
|
|
codeLocalPath := setting.JobPath + jobName + modelarts.CodePath |
|
|
|
codeObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.CodePath |
|
|
|
resultObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.ResultPath |
|
|
|
logObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.LogPath |
|
|
|
resultObsPath := "/" + setting.Bucket + modelarts.JobPath + jobName + modelarts.ResultPath + 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 + "/" |
|
|
|
branch_name := form.BranchName |
|
|
|
FlavorName := form.FlavorName |
|
|
|
EngineName := form.EngineName |
|
|
|
isLatestVersion := modelarts.IsLatestVersion |
|
|
|
VersionCount := modelarts.VersionCount |
|
|
|
trainUrl := form.TrainUrl |
|
|
|
modelName := form.ModelName |
|
|
|
modelVersion := form.ModelVersion |
|
|
|
@@ -1646,14 +1649,14 @@ func InferenceJobCreate(ctx *context.Context, form auth.CreateModelArtsInference |
|
|
|
} |
|
|
|
|
|
|
|
//todo: upload code (send to file_server todo this work?) |
|
|
|
if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.ResultPath); err != nil { |
|
|
|
if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.ResultPath + VersionOutputPath + "/"); err != nil { |
|
|
|
log.Error("Failed to obsMkdir_result: %s (%v)", repo.FullName(), err) |
|
|
|
inferenceJobErrorNewDataPrepare(ctx, form) |
|
|
|
ctx.RenderWithErr("Failed to obsMkdir_result", tplModelArtsInferenceJobNew, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.LogPath); err != nil { |
|
|
|
if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.LogPath + VersionOutputPath + "/"); err != nil { |
|
|
|
log.Error("Failed to obsMkdir_log: %s (%v)", repo.FullName(), err) |
|
|
|
inferenceJobErrorNewDataPrepare(ctx, form) |
|
|
|
ctx.RenderWithErr("Failed to obsMkdir_log", tplModelArtsInferenceJobNew, &form) |
|
|
|
@@ -1700,29 +1703,32 @@ func InferenceJobCreate(ctx *context.Context, form auth.CreateModelArtsInference |
|
|
|
} |
|
|
|
|
|
|
|
req := &modelarts.GenerateInferenceJobReq{ |
|
|
|
JobName: jobName, |
|
|
|
DataUrl: dataPath, |
|
|
|
Description: description, |
|
|
|
CodeObsPath: codeObsPath, |
|
|
|
BootFileUrl: codeObsPath + bootFile, |
|
|
|
BootFile: bootFile, |
|
|
|
TrainUrl: trainUrl, |
|
|
|
FlavorCode: flavorCode, |
|
|
|
WorkServerNumber: workServerNumber, |
|
|
|
EngineID: int64(engineID), |
|
|
|
LogUrl: logObsPath, |
|
|
|
PoolID: poolID, |
|
|
|
Uuid: uuid, |
|
|
|
Parameters: param, //modelarts训练时用到 |
|
|
|
CommitID: commitID, |
|
|
|
BranchName: branch_name, |
|
|
|
Params: form.Params, |
|
|
|
FlavorName: FlavorName, |
|
|
|
EngineName: EngineName, |
|
|
|
ModelName: modelName, |
|
|
|
ModelVersion: modelVersion, |
|
|
|
CkptName: ckptName, |
|
|
|
ResultUrl: resultObsPath, |
|
|
|
JobName: jobName, |
|
|
|
DataUrl: dataPath, |
|
|
|
Description: description, |
|
|
|
CodeObsPath: codeObsPath, |
|
|
|
BootFileUrl: codeObsPath + bootFile, |
|
|
|
BootFile: bootFile, |
|
|
|
TrainUrl: trainUrl, |
|
|
|
FlavorCode: flavorCode, |
|
|
|
WorkServerNumber: workServerNumber, |
|
|
|
EngineID: int64(engineID), |
|
|
|
LogUrl: logObsPath, |
|
|
|
PoolID: poolID, |
|
|
|
Uuid: uuid, |
|
|
|
Parameters: param, //modelarts训练时用到 |
|
|
|
CommitID: commitID, |
|
|
|
BranchName: branch_name, |
|
|
|
Params: form.Params, |
|
|
|
FlavorName: FlavorName, |
|
|
|
EngineName: EngineName, |
|
|
|
IsLatestVersion: isLatestVersion, |
|
|
|
VersionCount: VersionCount, |
|
|
|
TotalVersionCount: modelarts.TotalVersionCount, |
|
|
|
ModelName: modelName, |
|
|
|
ModelVersion: modelVersion, |
|
|
|
CkptName: ckptName, |
|
|
|
ResultUrl: resultObsPath, |
|
|
|
} |
|
|
|
|
|
|
|
//将params转换Parameters.Parameter,出错时返回给前端 |
|
|
|
@@ -2004,6 +2010,7 @@ func ResultDownload(ctx *context.Context) { |
|
|
|
) |
|
|
|
|
|
|
|
var jobID = ctx.Params(":jobid") |
|
|
|
versionName := ctx.Query("version_name") |
|
|
|
parentDir := ctx.Query("parent_dir") |
|
|
|
fileName := ctx.Query("file_name") |
|
|
|
log.Info("DownloadResult start.") |
|
|
|
@@ -2011,7 +2018,7 @@ func ResultDownload(ctx *context.Context) { |
|
|
|
if err != nil { |
|
|
|
ctx.Data["error"] = err.Error() |
|
|
|
} |
|
|
|
path := strings.TrimPrefix(path.Join(setting.TrainJobModelPath, task.JobName, modelarts.ResultPath, parentDir, fileName), "/") |
|
|
|
path := strings.TrimPrefix(path.Join(setting.TrainJobModelPath, task.JobName, modelarts.ResultPath, versionName, parentDir, fileName), "/") |
|
|
|
log.Info("Download path is:%s", path) |
|
|
|
|
|
|
|
url, err := storage.GetObsCreateSignedUrlByBucketAndKey(setting.Bucket, path) |
|
|
|
|