You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

modelarts.go 1.5 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package modelarts
  2. import (
  3. "code.gitea.io/gitea/modules/setting"
  4. "path"
  5. "code.gitea.io/gitea/models"
  6. "code.gitea.io/gitea/modules/context"
  7. "code.gitea.io/gitea/modules/log"
  8. )
  9. const (
  10. storageTypeOBS = "obs"
  11. autoStopDuration = 4 * 60 * 60
  12. flavor = "modelarts.kat1.xlarge"
  13. profileID = "Python3-ascend910-arm"
  14. DataSetMountPath = "/home/ma-user/work"
  15. NotebookEnv = "Python3"
  16. NotebookType = "Ascend"
  17. FlavorInfo = "Ascend: 1*Ascend 910 CPU: 24 核 96GiB (modelarts.kat1.xlarge)"
  18. )
  19. func GenerateTask(ctx *context.Context, jobName, uuid, description string) error {
  20. dataActualPath := setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + "/"
  21. jobResult, err := CreateJob(models.CreateNotebookParams{
  22. JobName: jobName,
  23. Description:description,
  24. ProfileID: profileID,
  25. Flavor: flavor,
  26. Spec: models.Spec{
  27. Storage: models.Storage{
  28. Type: storageTypeOBS,
  29. Location:models.Location{
  30. Path: dataActualPath,
  31. },
  32. },
  33. AutoStop: models.AutoStop{
  34. Enable: true,
  35. Duration: autoStopDuration,
  36. },
  37. },
  38. })
  39. if err != nil {
  40. log.Error("CreateJob failed: %v", err.Error())
  41. return err
  42. }
  43. err = models.CreateCloudbrain(&models.Cloudbrain{
  44. Status: string(models.JobWaiting),
  45. UserID: ctx.User.ID,
  46. RepoID: ctx.Repo.Repository.ID,
  47. JobID: jobResult.ID,
  48. JobName: jobName,
  49. JobType: string(models.JobTypeDebug),
  50. Type: models.TypeCloudBrainTwo,
  51. })
  52. if err != nil {
  53. return err
  54. }
  55. return nil
  56. }