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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. subTaskName = "task1"
  15. DataSetMountPath = "/home/ma-user/work"
  16. NotebookEnv = "Python3"
  17. NotebookType = "Ascend"
  18. FlavorInfo = "Ascend: 1*Ascend 910 CPU: 24 核 96GiB (modelarts.kat1.xlarge)"
  19. )
  20. func GenerateTask(ctx *context.Context, jobName, uuid string) error {
  21. dataActualPath := setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/"
  22. jobResult, err := CreateJob(models.CreateNotebookParams{
  23. JobName: jobName,
  24. Description:"",
  25. ProfileID: profileID,
  26. Flavor: flavor,
  27. Spec: models.Spec{
  28. Storage: models.Storage{
  29. Type: storageTypeOBS,
  30. Location:models.Location{
  31. Path: dataActualPath,
  32. },
  33. },
  34. AutoStop: models.AutoStop{
  35. Enable: true,
  36. Duration: autoStopDuration,
  37. },
  38. },
  39. })
  40. if err != nil {
  41. log.Error("CreateJob failed:", err.Error())
  42. return err
  43. }
  44. err = models.CreateCloudbrain(&models.Cloudbrain{
  45. Status: string(models.JobWaiting),
  46. UserID: ctx.User.ID,
  47. RepoID: ctx.Repo.Repository.ID,
  48. JobID: jobResult.ID,
  49. JobName: jobName,
  50. JobType: string(models.JobTypeDebug),
  51. Type: models.TypeCloudBrainTwo,
  52. })
  53. if err != nil {
  54. return err
  55. }
  56. return nil
  57. }