|
- package modelarts
-
- import (
- "code.gitea.io/gitea/modules/setting"
- "path"
-
- "code.gitea.io/gitea/models"
- "code.gitea.io/gitea/modules/context"
- "code.gitea.io/gitea/modules/log"
- )
-
- const (
- storageTypeOBS = "obs"
- autoStopDuration = 4 * 60 *60
- flavor = "modelarts.kat1.xlarge"
- profileID = "Python3-ascend910-arm"
-
- subTaskName = "task1"
-
- DataSetMountPath = "/home/ma-user/work"
- NotebookEnv = "Python3"
- NotebookType = "Ascend"
- FlavorInfo = "Ascend: 1*Ascend 910 CPU: 24 核 96GiB (modelarts.kat1.xlarge)"
- )
-
- func GenerateTask(ctx *context.Context, jobName, uuid string) error {
- dataActualPath := setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/"
- jobResult, err := CreateJob(models.CreateNotebookParams{
- JobName: jobName,
- Description:"",
- ProfileID: profileID,
- Flavor: flavor,
- Spec: models.Spec{
- Storage: models.Storage{
- Type: storageTypeOBS,
- Location:models.Location{
- Path: dataActualPath,
- },
- },
- AutoStop: models.AutoStop{
- Enable: true,
- Duration: autoStopDuration,
- },
- },
-
- })
- if err != nil {
- log.Error("CreateJob failed:", err.Error())
- return err
- }
-
- err = models.CreateCloudbrain(&models.Cloudbrain{
- Status: string(models.JobWaiting),
- UserID: ctx.User.ID,
- RepoID: ctx.Repo.Repository.ID,
- JobID: jobResult.ID,
- JobName: jobName,
- SubTaskName: subTaskName,
- JobType: string(models.JobTypeDebug),
- Type: models.TypeCloudBrainTwo,
- })
-
- if err != nil {
- return err
- }
-
- return nil
- }
|