|
|
|
@@ -216,7 +216,6 @@ func grampusParamCheckCreateTrainJob(form auth.CreateGrampusTrainJobForm) error |
|
|
|
} |
|
|
|
|
|
|
|
func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrainJobForm) { |
|
|
|
VersionOutputPath := modelarts.GetOutputPathByCount(modelarts.TotalVersionCount) |
|
|
|
displayJobName := form.DisplayJobName |
|
|
|
jobName := util.ConvertDisplayJobNameToJobName(displayJobName) |
|
|
|
uuid := form.Attachment |
|
|
|
@@ -298,20 +297,13 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain |
|
|
|
} |
|
|
|
|
|
|
|
//todo: upload code (send to file_server todo this work?) |
|
|
|
if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.OutputPath + VersionOutputPath + "/"); err != nil { |
|
|
|
if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.OutputPath); err != nil { |
|
|
|
log.Error("Failed to obsMkdir_output: %s (%v)", repo.FullName(), err) |
|
|
|
grampusTrainJobNpuNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("Failed to obsMkdir_output", tplGrampusTrainJobNPUNew, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.LogPath + VersionOutputPath + "/"); err != nil { |
|
|
|
log.Error("Failed to obsMkdir_log: %s (%v)", repo.FullName(), err) |
|
|
|
grampusTrainJobNpuNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr("Failed to obsMkdir_log", tplGrampusTrainJobNPUNew, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil { |
|
|
|
log.Error("Failed to uploadCodeToObs: %s (%v)", repo.FullName(), err) |
|
|
|
grampusTrainJobNpuNewDataPrepare(ctx) |
|
|
|
@@ -321,7 +313,7 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain |
|
|
|
|
|
|
|
//prepare command |
|
|
|
//todo: download code, download dataset, unzip dataset, exec code, upload model |
|
|
|
command, err := generateCommand(repo.Name, grampus.ProcessorTypeNPU, codeObsPath+cloudbrain.DefaultBranchName+".zip", dataObsPath+attachment.Name, bootFile, params, "", attachment.Name) |
|
|
|
command, err := generateCommand(repo.Name, grampus.ProcessorTypeNPU, codeObsPath+cloudbrain.DefaultBranchName+".zip", dataObsPath+attachment.Name, bootFile, params, setting.CodePathPrefix+jobName+modelarts.OutputPath, attachment.Name) |
|
|
|
log.Info(command) |
|
|
|
|
|
|
|
commitID, _ := ctx.Repo.GitRepo.GetBranchCommitID(branchName) |
|
|
|
@@ -545,7 +537,7 @@ func GrampusGetLog(ctx *context.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func generateCommand(repoName, processorType, codeObsPath, dataObsPath, bootFile, paramSrc, outputPath, datasetName string) (string, error) { |
|
|
|
func generateCommand(repoName, processorType, codeObsPath, dataObsPath, bootFile, paramSrc, outputObsPath, datasetName string) (string, error) { |
|
|
|
var command string |
|
|
|
|
|
|
|
command += grampus.CommandPrepareScript |
|
|
|
@@ -558,7 +550,7 @@ func generateCommand(repoName, processorType, codeObsPath, dataObsPath, bootFile |
|
|
|
} |
|
|
|
|
|
|
|
//unzip code & dataset |
|
|
|
commandUnzip := "cd dataset;unzip " + datasetName + ";cd ../code;unzip master.zip;" |
|
|
|
commandUnzip := "cd /tmp/dataset;unzip " + datasetName + ";cd /tmp/code;unzip master.zip;" |
|
|
|
command += commandUnzip |
|
|
|
|
|
|
|
//exec code |
|
|
|
@@ -581,10 +573,12 @@ func generateCommand(repoName, processorType, codeObsPath, dataObsPath, bootFile |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
commandCode := "cd " + repoName + ";python " + bootFile + paramCode |
|
|
|
commandCode := "cd " + repoName + ";python " + bootFile + paramCode + ";" |
|
|
|
command += commandCode |
|
|
|
|
|
|
|
//upload models |
|
|
|
commandUpload := "cd /tmp/script_for_grampus/;./uploader_for_grampus " + setting.Bucket + " " + outputObsPath + " " + "/tmp/output/;" |
|
|
|
command += commandUpload |
|
|
|
|
|
|
|
return command, nil |
|
|
|
} |
|
|
|
|