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 971 B

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. )
  13. func GetModelArtsTask(ctx *context.APIContext) {
  14. var (
  15. err error
  16. )
  17. jobID := ctx.Params(":jobid")
  18. repoID := ctx.Repo.Repository.ID
  19. job, err := models.GetRepoCloudBrainByJobID(repoID, jobID)
  20. if err != nil {
  21. ctx.NotFound(err)
  22. return
  23. }
  24. result, err := modelarts.GetJob(jobID)
  25. if err != nil {
  26. ctx.NotFound(err)
  27. return
  28. }
  29. job.Status = result.Status
  30. err = models.UpdateJob(job)
  31. if err != nil {
  32. log.Error("UpdateJob failed:", err)
  33. }
  34. ctx.JSON(http.StatusOK, map[string]interface{}{
  35. "JobID": jobID,
  36. "JobStatus": result.Status,
  37. })
  38. }