Browse Source

get job log

tags/v1.22.1.3
lewis 4 years ago
parent
commit
bf51e9e9a1
3 changed files with 17 additions and 8 deletions
  1. +3
    -3
      models/cloudbrain.go
  2. +13
    -4
      modules/cloudbrain/resty.go
  3. +1
    -1
      templates/repo/cloudbrain/benchmark/show.tmpl

+ 3
- 3
models/cloudbrain.go View File

@@ -461,12 +461,12 @@ type CommitImageResult struct {
}

type GetJobLogParams struct {
Size string `json:"size"`
Sort string `json:"sort"`
QueryInfo QueryInfo `json:"query"`
}

type QueryInfo struct {
Size string `json:"size"`
Sort string `json:"sort"`
MatchInfo MatchInfo `json:"match"`
}

@@ -476,7 +476,7 @@ type MatchInfo struct {

type GetJobLogResult struct {
ScrollID string `json:"_scroll_id"`
Took string `json:"took"`
Took int `json:"took"`
TimedOut bool `json:"timed_out"`
Shards struct {
Total int `json:"total"`


+ 13
- 4
modules/cloudbrain/resty.go View File

@@ -2,7 +2,10 @@ package cloudbrain

import (
"encoding/json"
"errors"
"fmt"
"net/http"
"strconv"
"strings"

"code.gitea.io/gitea/modules/log"
@@ -276,11 +279,11 @@ func GetJobLog(jobID string) (*models.GetJobLogResult, error) {
client := getRestyClient()
var result models.GetJobLogResult
req := models.GetJobLogParams{
Size: "5000",
Sort: "log.offset",
QueryInfo: models.QueryInfo{
Size: "5000",
Sort: "log.offset",
MatchInfo: models.MatchInfo{
PodName: jobID + "task1-0",
PodName: jobID + "-task1-0",
},
},
}
@@ -290,11 +293,17 @@ func GetJobLog(jobID string) (*models.GetJobLogResult, error) {
SetAuthToken(TOKEN).
SetBody(req).
SetResult(&result).
Post(HOST + "/es/_search?_source=message&scroll=5m")
Post(HOST + "es/_search?_source=message&scroll=5m")

if err != nil {
log.Info("GetJobLog failed: %v", err)
return &result, fmt.Errorf("resty GetJobLog: %v, %s", err, res.String())
}

if !strings.Contains(res.Status(), strconv.Itoa(http.StatusOK)) {
log.Info("res.Status(): %s, response: %s", res.Status(), res.String())
return &result, errors.New(res.String())
}

return &result, nil
}

+ 1
- 1
templates/repo/cloudbrain/benchmark/show.tmpl View File

@@ -550,7 +550,7 @@ td, th {
});
}
function loadLog(version_name){
$.get(`/api/v1/repos/${userName}/${repoPath}/modelarts/train-job/${jobID}/log?version_name=${version_name}&lines=50&order=asc`, (data) => {
$.get(`/api/v1/repos/${userName}/${repoPath}/cloudbrain/${jobID}/log?version_name=${version_name}&lines=50&order=asc`, (data) => {
$('input[name=end_line]').val(data.EndLine)
$('input[name=start_line]').val(data.StartLine)
$(`#log_file${version_name}`).text(data.Content)


Loading…
Cancel
Save