|
|
@@ -245,6 +245,32 @@ func GetTrainJobLog(jobID string) (string, error) { |
|
|
|
return logContent, nil |
|
|
|
} |
|
|
|
|
|
|
|
func GetGrampusMetrics(jobID string) (models.GetTrainJobMetricStatisticResult, error) { |
|
|
|
checkSetting() |
|
|
|
client := getRestyClient() |
|
|
|
var result models.GetTrainJobMetricStatisticResult |
|
|
|
res, err := client.R(). |
|
|
|
SetAuthToken(TOKEN). |
|
|
|
Get(HOST + urlTrainJob + "/" + jobID + "/task/0/replica/0/metrics") |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
return result, fmt.Errorf("resty GetTrainJobLog: %v", err) |
|
|
|
} |
|
|
|
if err = json.Unmarshal([]byte(res.String()), &result); err != nil { |
|
|
|
log.Error("GetGrampusMetrics json.Unmarshal failed(%s): %v", res.String(), err.Error()) |
|
|
|
return result, fmt.Errorf("json.Unmarshal failed(%s): %v", res.String(), err.Error()) |
|
|
|
} |
|
|
|
if res.StatusCode() != http.StatusOK { |
|
|
|
log.Error("Call GrampusMetrics failed(%d):%s(%s)", res.StatusCode(), result.ErrorCode, result.ErrorMsg) |
|
|
|
return result, fmt.Errorf("Call GrampusMetrics failed(%d):%d(%s)", res.StatusCode(), result.ErrorCode, result.ErrorMsg) |
|
|
|
} |
|
|
|
if !result.IsSuccess { |
|
|
|
log.Error("GetGrampusMetrics(%s) failed", jobID) |
|
|
|
return result, fmt.Errorf("GetGrampusMetrics failed:%s", result.ErrorMsg) |
|
|
|
} |
|
|
|
return result, nil |
|
|
|
} |
|
|
|
|
|
|
|
func StopJob(jobID string) (*models.GrampusStopJobResponse, error) { |
|
|
|
checkSetting() |
|
|
|
client := getRestyClient() |
|
|
|