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