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.6 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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright 2016 The Gogs Authors. All rights reserved.
  2. // Copyright 2018 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package repo
  6. import (
  7. "code.gitea.io/gitea/models"
  8. "code.gitea.io/gitea/modules/context"
  9. "code.gitea.io/gitea/modules/log"
  10. "code.gitea.io/gitea/modules/modelarts"
  11. "net/http"
  12. "strconv"
  13. )
  14. func GetModelArtsNotebook(ctx *context.APIContext) {
  15. var (
  16. err error
  17. )
  18. jobID := ctx.Params(":jobid")
  19. repoID := ctx.Repo.Repository.ID
  20. job, err := models.GetRepoCloudBrainByJobID(repoID, jobID)
  21. if err != nil {
  22. ctx.NotFound(err)
  23. return
  24. }
  25. result, err := modelarts.GetJob(jobID)
  26. if err != nil {
  27. ctx.NotFound(err)
  28. return
  29. }
  30. job.Status = result.Status
  31. err = models.UpdateJob(job)
  32. if err != nil {
  33. log.Error("UpdateJob failed:", err)
  34. }
  35. ctx.JSON(http.StatusOK, map[string]interface{}{
  36. "JobID": jobID,
  37. "JobStatus": result.Status,
  38. })
  39. }
  40. func GetModelArtsTrainJob(ctx *context.APIContext) {
  41. var (
  42. err error
  43. )
  44. jobID := ctx.Params(":jobid")
  45. repoID := ctx.Repo.Repository.ID
  46. job, err := models.GetRepoCloudBrainByJobID(repoID, jobID)
  47. if err != nil {
  48. ctx.NotFound(err)
  49. return
  50. }
  51. result, err := modelarts.GetTrainJob(jobID, strconv.FormatInt(job.VersionID, 10))
  52. if err != nil {
  53. ctx.NotFound(err)
  54. return
  55. }
  56. job.Status = modelarts.TransTrainJobStatus(result.IntStatus)
  57. err = models.UpdateJob(job)
  58. if err != nil {
  59. log.Error("UpdateJob failed:", err)
  60. }
  61. ctx.JSON(http.StatusOK, map[string]interface{}{
  62. "JobID": jobID,
  63. "JobStatus": job.Status,
  64. })
  65. }