Browse Source

Merge branch 'grampus-notebook' of openi.pcl.ac.cn:OpenI/aiforge into grampus-notebook

tags/v1.22.12.1^2
zhoupzh 3 years ago
parent
commit
0c462ddde9
2 changed files with 10 additions and 1 deletions
  1. +1
    -0
      models/cloudbrain.go
  2. +9
    -1
      modules/grampus/resty.go

+ 1
- 0
models/cloudbrain.go View File

@@ -1538,6 +1538,7 @@ type GrampusNotebookResponse struct {
} }


type GrampusNotebookRestartResponse struct { type GrampusNotebookRestartResponse struct {
GrampusResult
NewId string `json:"newId"` NewId string `json:"newId"`
Status string `json:"status"` Status string `json:"status"`
} }


+ 9
- 1
modules/grampus/resty.go View File

@@ -418,15 +418,23 @@ func RestartNotebookJob(jobID string) (*models.GrampusNotebookRestartResponse, e
checkSetting() checkSetting()
client := getRestyClient() client := getRestyClient()
var restartResponse *models.GrampusNotebookRestartResponse var restartResponse *models.GrampusNotebookRestartResponse
retry := 0


sendjob:
res, err := client.R(). res, err := client.R().
SetAuthToken(TOKEN). SetAuthToken(TOKEN).
SetResult(&restartResponse). SetResult(&restartResponse).
Get(HOST + urlNotebookJob + "/" + jobID + "/start")
Post(HOST + urlNotebookJob + "/" + jobID + "/start")


if err != nil { if err != nil {
return nil, fmt.Errorf("resty grampus restart note book job: %v", err) return nil, fmt.Errorf("resty grampus restart note book job: %v", err)
} }
if restartResponse.ErrorCode == errorIllegalToken && retry < 1 {
retry++
log.Info("retry get token")
_ = getToken()
goto sendjob
}


if res.StatusCode() != http.StatusOK { if res.StatusCode() != http.StatusOK {
log.Error("resty grampus restart note book job failed(%s): %v", res.String(), err.Error()) log.Error("resty grampus restart note book job failed(%s): %v", res.String(), err.Error())


Loading…
Cancel
Save