|
|
|
@@ -40,16 +40,14 @@ const ( |
|
|
|
tplGrampusTrainJobShow base.TplName = "repo/grampus/trainjob/show" |
|
|
|
|
|
|
|
//GPU |
|
|
|
tplGrampusTrainJobGPUNew base.TplName = "repo/grampus/trainjob/gpu/new" |
|
|
|
tplGrampusTrainJobGPUVersionNew base.TplName = "repo/grampus/trainjob/gpu/versionnew" |
|
|
|
tplGrampusTrainJobGPUNew base.TplName = "repo/grampus/trainjob/gpu/new" |
|
|
|
|
|
|
|
//NPU |
|
|
|
tplGrampusTrainJobNPUNew base.TplName = "repo/grampus/trainjob/npu/new" |
|
|
|
tplGrampusTrainJobNPUVersionNew base.TplName = "repo/grampus/trainjob/npu/versionnew" |
|
|
|
tplGrampusTrainJobNPUNew base.TplName = "repo/grampus/trainjob/npu/new" |
|
|
|
) |
|
|
|
|
|
|
|
func GrampusTrainJobGPUNew(ctx *context.Context) { |
|
|
|
ctx.Data["datasetType"] = models.TypeCloudBrainOne |
|
|
|
ctx.Data["IsCreate"] = true |
|
|
|
err := grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("get new train-job info failed", err) |
|
|
|
@@ -60,7 +58,7 @@ func GrampusTrainJobGPUNew(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
func GrampusTrainJobNPUNew(ctx *context.Context) { |
|
|
|
ctx.Data["datasetType"] = models.TypeCloudBrainTwo |
|
|
|
ctx.Data["IsCreate"] = true |
|
|
|
err := grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("get new train-job info failed", err) |
|
|
|
@@ -174,20 +172,21 @@ func grampusTrainJobNewDataPrepare(ctx *context.Context, processType string) err |
|
|
|
|
|
|
|
func GrampusTrainJobVersionNew(ctx *context.Context) { |
|
|
|
task := ctx.Cloudbrain |
|
|
|
ctx.Data["IsCreate"] = false |
|
|
|
if task.ComputeResource == models.GPUResource { |
|
|
|
err := grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeGPU) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("get new train-job version info failed", err) |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.HTML(http.StatusOK, tplGrampusTrainJobGPUVersionNew) |
|
|
|
ctx.HTML(http.StatusOK, tplGrampusTrainJobGPUNew) |
|
|
|
} else if task.ComputeResource == models.NPUResource { |
|
|
|
err := grampusTrainJobNewDataPrepare(ctx, grampus.ProcessorTypeNPU) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("get new train-job version info failed", err) |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.HTML(200, tplGrampusTrainJobNPUVersionNew) |
|
|
|
ctx.HTML(200, tplGrampusTrainJobNPUNew) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@@ -255,6 +254,7 @@ func grampusParamCheckCreateTrainJob(form auth.CreateGrampusTrainJobForm) error |
|
|
|
} |
|
|
|
|
|
|
|
func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrainJobForm) { |
|
|
|
ctx.Data["IsCreate"] = true |
|
|
|
displayJobName := form.DisplayJobName |
|
|
|
jobName := util.ConvertDisplayJobNameToJobName(displayJobName) |
|
|
|
uuid := form.Attachment |
|
|
|
@@ -268,11 +268,6 @@ func GrampusTrainJobGpuCreate(ctx *context.Context, form auth.CreateGrampusTrain |
|
|
|
image := strings.TrimSpace(form.Image) |
|
|
|
tpl := tplGrampusTrainJobGPUNew |
|
|
|
|
|
|
|
var jobID = ctx.Params(":jobid") |
|
|
|
if jobID != "" { |
|
|
|
tpl = tplGrampusTrainJobGPUVersionNew |
|
|
|
} |
|
|
|
|
|
|
|
lock := redis_lock.NewDistributeLock(redis_key.CloudbrainBindingJobNameKey(fmt.Sprint(repo.ID), string(models.JobTypeTrain), displayJobName)) |
|
|
|
isOk, err := lock.Lock(models.CloudbrainKeyDuration) |
|
|
|
if !isOk { |
|
|
|
@@ -485,6 +480,7 @@ func getPreTrainModelPath(pretrainModelDir string, fileName string) string { |
|
|
|
} |
|
|
|
|
|
|
|
func GrampusTrainJobVersionCreate(ctx *context.Context, form auth.CreateGrampusTrainJobForm) { |
|
|
|
ctx.Data["IsCreate"] = false |
|
|
|
computeResource := ctx.Query("compute_resource") |
|
|
|
if computeResource == models.GPUResource { |
|
|
|
GrampusTrainJobGpuCreate(ctx, form) |
|
|
|
@@ -520,6 +516,7 @@ func checkSpecialPool(ctx *context.Context, resourceType string) string { |
|
|
|
} |
|
|
|
|
|
|
|
func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrainJobForm) { |
|
|
|
ctx.Data["IsCreate"] = true |
|
|
|
displayJobName := form.DisplayJobName |
|
|
|
jobName := util.ConvertDisplayJobNameToJobName(displayJobName) |
|
|
|
uuid := form.Attachment |
|
|
|
@@ -536,12 +533,6 @@ func GrampusTrainJobNpuCreate(ctx *context.Context, form auth.CreateGrampusTrain |
|
|
|
engineName := form.EngineName |
|
|
|
tpl := tplGrampusTrainJobNPUNew |
|
|
|
|
|
|
|
//判断路由是否存在jobID,若存在,则说明是创建版本 |
|
|
|
var jobID = ctx.Params(":jobid") |
|
|
|
if jobID != "" { |
|
|
|
tpl = tplGrampusTrainJobNPUVersionNew |
|
|
|
} |
|
|
|
|
|
|
|
lock := redis_lock.NewDistributeLock(redis_key.CloudbrainBindingJobNameKey(fmt.Sprint(repo.ID), string(models.JobTypeTrain), displayJobName)) |
|
|
|
isOk, err := lock.Lock(models.CloudbrainKeyDuration) |
|
|
|
if !isOk { |
|
|
|
|