| @@ -106,6 +106,7 @@ type GenerateNotebookJobReq struct { | |||||
| PreTrainModelUrl string | PreTrainModelUrl string | ||||
| Spec *models.Specification | Spec *models.Specification | ||||
| CodeName string | CodeName string | ||||
| ModelPath string //参考启智GPU调试, 挂载/model目录用户的模型可以输出到这个目录 | |||||
| } | } | ||||
| func getEndPoint() string { | func getEndPoint() string { | ||||
| @@ -184,16 +185,26 @@ func GenerateNotebookJob(ctx *context.Context, req *GenerateNotebookJobReq) (job | |||||
| EndPoint: setting.Attachment.Minio.Endpoint, | EndPoint: setting.Attachment.Minio.Endpoint, | ||||
| ObjectKey: req.PreTrainModelPath, | ObjectKey: req.PreTrainModelPath, | ||||
| ReadOnly: true, | ReadOnly: true, | ||||
| ContainerPath: "/model", | |||||
| ContainerPath: cloudbrain.PretrainModelMountPath, | |||||
| }) | }) | ||||
| } | } | ||||
| datasetGrampus = append(datasetGrampus, models.GrampusDataset{ | |||||
| Name: "modelOutput", | |||||
| Bucket: setting.Bucket, | |||||
| EndPoint: getEndPoint(), | |||||
| ReadOnly: false, | |||||
| ObjectKey: req.ModelPath, | |||||
| ContainerPath: cloudbrain.ModelMountPath, | |||||
| }) | |||||
| codeGrampus = models.GrampusDataset{ | codeGrampus = models.GrampusDataset{ | ||||
| Name: req.CodeName, | Name: req.CodeName, | ||||
| Bucket: setting.Attachment.Minio.Bucket, | Bucket: setting.Attachment.Minio.Bucket, | ||||
| EndPoint: setting.Attachment.Minio.Endpoint, | EndPoint: setting.Attachment.Minio.Endpoint, | ||||
| ObjectKey: req.CodeStoragePath + cloudbrain.DefaultBranchName + ".zip", | ObjectKey: req.CodeStoragePath + cloudbrain.DefaultBranchName + ".zip", | ||||
| ReadOnly: false, | ReadOnly: false, | ||||
| ContainerPath: "/code", | |||||
| ContainerPath: cloudbrain.CodeMountPath, | |||||
| } | } | ||||
| req.Command = fmt.Sprintf(CommandGpuDebug, cpCommand) | req.Command = fmt.Sprintf(CommandGpuDebug, cpCommand) | ||||
| log.Info("debug command:" + req.Command) | log.Info("debug command:" + req.Command) | ||||
| @@ -418,8 +418,13 @@ func loadCodeAndMakeModelPath(repo *models.Repository, codePath string, branchNa | |||||
| return "cloudbrain.load_code_failed" | return "cloudbrain.load_code_failed" | ||||
| } | } | ||||
| return initModelPath(jobName, resultPath) | |||||
| } | |||||
| func initModelPath(jobName string, resultPath string) string { | |||||
| modelPath := setting.JobPath + jobName + resultPath + "/" | modelPath := setting.JobPath + jobName + resultPath + "/" | ||||
| err = mkModelPath(modelPath) | |||||
| err := mkModelPath(modelPath) | |||||
| if err != nil { | if err != nil { | ||||
| return "cloudbrain.load_code_failed" | return "cloudbrain.load_code_failed" | ||||
| } | } | ||||
| @@ -104,9 +104,9 @@ func GrampusNotebookCreate(ctx *context.Context, form auth.CreateGrampusNotebook | |||||
| repo := ctx.Repo.Repository | repo := ctx.Repo.Repository | ||||
| branchName := form.BranchName | branchName := form.BranchName | ||||
| image := strings.TrimSpace(form.Image) | image := strings.TrimSpace(form.Image) | ||||
| codeLocalPath := setting.JobPath + jobName + cloudbrain.CodeMountPath + "/" | |||||
| codeStoragePath := setting.CBCodePathPrefix + jobName + cloudbrain.CodeMountPath + "/" | codeStoragePath := setting.CBCodePathPrefix + jobName + cloudbrain.CodeMountPath + "/" | ||||
| modelStoragePath := setting.CBCodePathPrefix + jobName + cloudbrain.ModelMountPath + "/" | |||||
| tpl := tplGrampusNotebookGPUNew | tpl := tplGrampusNotebookGPUNew | ||||
| processType := grampus.ProcessorTypeGPU | processType := grampus.ProcessorTypeGPU | ||||
| @@ -203,6 +203,7 @@ func GrampusNotebookCreate(ctx *context.Context, form auth.CreateGrampusNotebook | |||||
| } | } | ||||
| //prepare code and out path | //prepare code and out path | ||||
| codeLocalPath := setting.JobPath + jobName + cloudbrain.CodeMountPath + "/" | |||||
| _, err = ioutil.ReadDir(codeLocalPath) | _, err = ioutil.ReadDir(codeLocalPath) | ||||
| if err == nil { | if err == nil { | ||||
| os.RemoveAll(codeLocalPath) | os.RemoveAll(codeLocalPath) | ||||
| @@ -222,6 +223,13 @@ func GrampusNotebookCreate(ctx *context.Context, form auth.CreateGrampusNotebook | |||||
| ctx.RenderWithErr(ctx.Tr("cloudbrain.load_code_failed"), tpl, &form) | ctx.RenderWithErr(ctx.Tr("cloudbrain.load_code_failed"), tpl, &form) | ||||
| return | return | ||||
| } | } | ||||
| errStr := initModelPath(jobName, cloudbrain.ModelMountPath) | |||||
| if errStr != "" { | |||||
| grampusNotebookNewDataPrepare(ctx, processType) | |||||
| ctx.RenderWithErr(ctx.Tr(errStr), tpl, &form) | |||||
| return | |||||
| } | |||||
| } else { | } else { | ||||
| if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil { | if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil { | ||||
| @@ -250,6 +258,7 @@ func GrampusNotebookCreate(ctx *context.Context, form auth.CreateGrampusNotebook | |||||
| Spec: spec, | Spec: spec, | ||||
| CodeStoragePath: codeStoragePath, | CodeStoragePath: codeStoragePath, | ||||
| CodeName: strings.ToLower(repo.Name), | CodeName: strings.ToLower(repo.Name), | ||||
| ModelPath: modelStoragePath, | |||||
| } | } | ||||
| if form.ModelName != "" { //使用预训练模型训练 | if form.ModelName != "" { //使用预训练模型训练 | ||||