|
|
|
@@ -6,12 +6,13 @@ |
|
|
|
package repo |
|
|
|
|
|
|
|
import ( |
|
|
|
"net/http" |
|
|
|
"strconv" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/modules/modelarts" |
|
|
|
"net/http" |
|
|
|
"strconv" |
|
|
|
) |
|
|
|
|
|
|
|
func GetModelArtsNotebook(ctx *context.APIContext) { |
|
|
|
@@ -72,9 +73,44 @@ func GetModelArtsTrainJob(ctx *context.APIContext) { |
|
|
|
} |
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{ |
|
|
|
"JobID": jobID, |
|
|
|
"JobStatus": job.Status, |
|
|
|
"JobDuration": job.Duration, |
|
|
|
"JobID": jobID, |
|
|
|
"JobStatus": job.Status, |
|
|
|
"JobDuration": job.Duration, |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func GetModelArtsTrainJobVersion(ctx *context.APIContext) { |
|
|
|
var ( |
|
|
|
err error |
|
|
|
) |
|
|
|
|
|
|
|
jobID := ctx.Params(":jobid") |
|
|
|
versionName := ctx.Params(":version-name") |
|
|
|
repoID := ctx.Repo.Repository.ID |
|
|
|
job, err := models.GetRepoCloudBrainByJobIDAndVersionName(repoID, jobID, versionName) |
|
|
|
if err != nil { |
|
|
|
ctx.NotFound(err) |
|
|
|
return |
|
|
|
} |
|
|
|
result, err := modelarts.GetTrainJob(jobID, strconv.FormatInt(job.VersionID, 10)) |
|
|
|
if err != nil { |
|
|
|
ctx.NotFound(err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
job.Status = modelarts.TransTrainJobStatus(result.IntStatus) |
|
|
|
job.Duration = result.Duration |
|
|
|
job.TrainJobDuration = result.TrainJobDuration |
|
|
|
err = models.UpdateJob(job) |
|
|
|
if err != nil { |
|
|
|
log.Error("UpdateJob failed:", err) |
|
|
|
} |
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{ |
|
|
|
"JobID": jobID, |
|
|
|
"JobStatus": job.Status, |
|
|
|
"JobDuration": job.Duration, |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
@@ -94,7 +130,7 @@ func TrainJobGetLog(ctx *context.APIContext) { |
|
|
|
if order != modelarts.OrderDesc && order != modelarts.OrderAsc { |
|
|
|
log.Error("order(%s) check failed", order) |
|
|
|
ctx.JSON(http.StatusBadRequest, map[string]interface{}{ |
|
|
|
"err_msg": "order check failed", |
|
|
|
"err_msg": "order check failed", |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
@@ -103,7 +139,7 @@ func TrainJobGetLog(ctx *context.APIContext) { |
|
|
|
if err != nil { |
|
|
|
log.Error("GetCloudbrainByJobID(%s) failed:%v", jobID, err.Error()) |
|
|
|
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ |
|
|
|
"err_msg": "GetCloudbrainByJobID failed", |
|
|
|
"err_msg": "GetCloudbrainByJobID failed", |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
@@ -112,16 +148,16 @@ func TrainJobGetLog(ctx *context.APIContext) { |
|
|
|
if err != nil { |
|
|
|
log.Error("GetTrainJobLog(%s) failed:%v", jobID, err.Error()) |
|
|
|
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ |
|
|
|
"err_msg": "GetTrainJobLog failed", |
|
|
|
"err_msg": "GetTrainJobLog failed", |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{ |
|
|
|
"JobID": jobID, |
|
|
|
"StartLine": result.StartLine, |
|
|
|
"EndLine": result.EndLine, |
|
|
|
"Content": result.Content, |
|
|
|
"Lines": result.Lines, |
|
|
|
"JobID": jobID, |
|
|
|
"StartLine": result.StartLine, |
|
|
|
"EndLine": result.EndLine, |
|
|
|
"Content": result.Content, |
|
|
|
"Lines": result.Lines, |
|
|
|
}) |
|
|
|
} |