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.4 kB

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