|
|
@@ -1175,10 +1175,10 @@ sendjob: |
|
|
return &result, nil |
|
|
return &result, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func GetTrainJobList(perPage, page int, sortBy, order, searchContent, status string) (*models.GetConfigListResult, error) { |
|
|
|
|
|
|
|
|
func GetTrainJobList(perPage, page int, sortBy, order, searchContent, status string) (*models.GetTrainJobListResult, error) { |
|
|
checkSetting() |
|
|
checkSetting() |
|
|
client := getRestyClient() |
|
|
client := getRestyClient() |
|
|
var result models.GetConfigListResult |
|
|
|
|
|
|
|
|
var result models.GetTrainJobListResult |
|
|
|
|
|
|
|
|
retry := 0 |
|
|
retry := 0 |
|
|
|
|
|
|
|
|
@@ -1190,14 +1190,13 @@ sendjob: |
|
|
"sortBy": sortBy, |
|
|
"sortBy": sortBy, |
|
|
"order": order, |
|
|
"order": order, |
|
|
"search_content": searchContent, |
|
|
"search_content": searchContent, |
|
|
"status": status, |
|
|
|
|
|
}). |
|
|
}). |
|
|
SetAuthToken(TOKEN). |
|
|
SetAuthToken(TOKEN). |
|
|
SetResult(&result). |
|
|
SetResult(&result). |
|
|
Get(HOST + "/v1/" + setting.ProjectID + urlTrainJob) |
|
|
Get(HOST + "/v1/" + setting.ProjectID + urlTrainJob) |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, fmt.Errorf("resty GetConfigList: %v", err) |
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("resty GetTrainJobList: %v", err) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if res.StatusCode() == http.StatusUnauthorized && retry < 1 { |
|
|
if res.StatusCode() == http.StatusUnauthorized && retry < 1 { |
|
|
@@ -1212,13 +1211,100 @@ sendjob: |
|
|
log.Error("json.Unmarshal failed(%s): %v", res.String(), err.Error()) |
|
|
log.Error("json.Unmarshal failed(%s): %v", res.String(), err.Error()) |
|
|
return &result, fmt.Errorf("json.Unmarshal failed(%s): %v", res.String(), err.Error()) |
|
|
return &result, fmt.Errorf("json.Unmarshal failed(%s): %v", res.String(), err.Error()) |
|
|
} |
|
|
} |
|
|
log.Error("GetConfigList failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) |
|
|
|
|
|
return &result, fmt.Errorf("获取参数配置列表失败(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) |
|
|
|
|
|
|
|
|
log.Error("GetTrainJobList failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) |
|
|
|
|
|
return &result, fmt.Errorf(temp.ErrorMsg) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if !result.IsSuccess { |
|
|
if !result.IsSuccess { |
|
|
log.Error("GetConfigList failed(%s): %s", result.ErrorCode, result.ErrorMsg) |
|
|
|
|
|
return &result, fmt.Errorf("获取参数配置列表失败(%s): %s", result.ErrorCode, result.ErrorMsg) |
|
|
|
|
|
|
|
|
log.Error("GetTrainJobList failed(%s): %s", result.ErrorCode, result.ErrorMsg) |
|
|
|
|
|
return &result, fmt.Errorf(result.ErrorMsg) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return &result, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func GetTrainJobVersionList(perPage, page int, jobID string) (*models.GetTrainJobVersionListResult, error) { |
|
|
|
|
|
checkSetting() |
|
|
|
|
|
client := getRestyClient() |
|
|
|
|
|
var result models.GetTrainJobVersionListResult |
|
|
|
|
|
|
|
|
|
|
|
retry := 0 |
|
|
|
|
|
|
|
|
|
|
|
sendjob: |
|
|
|
|
|
res, err := client.R(). |
|
|
|
|
|
SetQueryParams(map[string]string{ |
|
|
|
|
|
"per_page": strconv.Itoa(perPage), |
|
|
|
|
|
"page": strconv.Itoa(page), |
|
|
|
|
|
}). |
|
|
|
|
|
SetAuthToken(TOKEN). |
|
|
|
|
|
SetResult(&result). |
|
|
|
|
|
Get(HOST + "/v1/" + setting.ProjectID + urlTrainJob + "/" + jobID + "/versions") |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, fmt.Errorf("resty GetTrainJobVersionList: %v", err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if res.StatusCode() == http.StatusUnauthorized && retry < 1 { |
|
|
|
|
|
retry++ |
|
|
|
|
|
_ = getToken() |
|
|
|
|
|
goto sendjob |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if res.StatusCode() != http.StatusOK { |
|
|
|
|
|
var temp models.ErrorResult |
|
|
|
|
|
if err = json.Unmarshal([]byte(res.String()), &temp); err != nil { |
|
|
|
|
|
log.Error("json.Unmarshal failed(%s): %v", res.String(), err.Error()) |
|
|
|
|
|
return &result, fmt.Errorf("json.Unmarshal failed(%s): %v", res.String(), err.Error()) |
|
|
|
|
|
} |
|
|
|
|
|
log.Error("GetTrainJobVersionList failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) |
|
|
|
|
|
return &result, fmt.Errorf(temp.ErrorMsg) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !result.IsSuccess { |
|
|
|
|
|
log.Error("GetTrainJobVersionList failed(%s): %s", result.ErrorCode, result.ErrorMsg) |
|
|
|
|
|
return &result, fmt.Errorf(result.ErrorMsg) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return &result, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func GetNotebookList(limit, page int, sortBy, order, searchContent, status string) (*models.GetNotebookListResult, error) { |
|
|
|
|
|
checkSetting() |
|
|
|
|
|
client := getRestyClient() |
|
|
|
|
|
var result models.GetNotebookListResult |
|
|
|
|
|
|
|
|
|
|
|
retry := 0 |
|
|
|
|
|
|
|
|
|
|
|
sendjob: |
|
|
|
|
|
res, err := client.R(). |
|
|
|
|
|
SetQueryParams(map[string]string{ |
|
|
|
|
|
"limit": strconv.Itoa(limit), |
|
|
|
|
|
"name": searchContent, |
|
|
|
|
|
"sort_key": sortBy, |
|
|
|
|
|
"sort_dir": order, |
|
|
|
|
|
}). |
|
|
|
|
|
SetAuthToken(TOKEN). |
|
|
|
|
|
SetResult(&result). |
|
|
|
|
|
Get(HOST + "/v1/" + setting.ProjectID + urlNotebook2) |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, fmt.Errorf("resty GetNotebookList: %v", err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if res.StatusCode() == http.StatusUnauthorized && retry < 1 { |
|
|
|
|
|
retry++ |
|
|
|
|
|
_ = getToken() |
|
|
|
|
|
goto sendjob |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if res.StatusCode() != http.StatusOK { |
|
|
|
|
|
var temp models.ErrorResult |
|
|
|
|
|
if err = json.Unmarshal([]byte(res.String()), &temp); err != nil { |
|
|
|
|
|
log.Error("json.Unmarshal failed(%s): %v", res.String(), err.Error()) |
|
|
|
|
|
return &result, fmt.Errorf("json.Unmarshal failed(%s): %v", res.String(), err.Error()) |
|
|
|
|
|
} |
|
|
|
|
|
log.Error("GetNotebookList failed(%d):%s(%s)", res.StatusCode(), temp.ErrorCode, temp.ErrorMsg) |
|
|
|
|
|
return &result, fmt.Errorf(temp.ErrorMsg) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return &result, nil |
|
|
return &result, nil |
|
|
|