Browse Source

respone

tags/v1.21.12.1
yuyuanshifu 4 years ago
parent
commit
13f3a4ac3c
2 changed files with 36 additions and 36 deletions
  1. +1
    -1
      models/cloudbrain.go
  2. +35
    -35
      modules/modelarts/resty.go

+ 1
- 1
models/cloudbrain.go View File

@@ -315,7 +315,7 @@ type Location struct {
}

type NotebookResult struct {
ErrorCode int `json:"error_code"`
ErrorCode string `json:"error_code"`
ErrorMsg string `json:"error_msg"`
}



+ 35
- 35
modules/modelarts/resty.go View File

@@ -106,6 +106,12 @@ sendjob:
return nil, fmt.Errorf("resty create job: %s", err)
}

if res.StatusCode() == http.StatusUnauthorized && retry < 1 {
retry++
_ = getToken()
goto sendjob
}

var response models.NotebookResult
err = json.Unmarshal(res.Body(), &response)
if err != nil {
@@ -113,13 +119,7 @@ sendjob:
return &result, fmt.Errorf("son.Unmarshal failed: %s", err.Error())
}

if response.ErrorCode == http.StatusUnauthorized && retry < 1 {
retry++
_ = getToken()
goto sendjob
}

if response.ErrorCode != 0 {
if len(response.ErrorCode) != 0 {
log.Error("CreateJob failed(%s): %s", response.ErrorCode, response.ErrorMsg)
return &result, fmt.Errorf("CreateJob failed(%s): %s", response.ErrorCode, response.ErrorMsg)
}
@@ -145,6 +145,12 @@ sendjob:
return nil, fmt.Errorf("resty GetJob: %v", err)
}

if res.StatusCode() == http.StatusUnauthorized && retry < 1 {
retry++
_ = getToken()
goto sendjob
}

var response models.NotebookResult
err = json.Unmarshal(res.Body(), &response)
if err != nil {
@@ -152,13 +158,7 @@ sendjob:
return &result, fmt.Errorf("son.Unmarshal failed: %s", err.Error())
}

if response.ErrorCode == http.StatusUnauthorized && retry < 1 {
retry++
_ = getToken()
goto sendjob
}

if response.ErrorCode != 0 {
if len(response.ErrorCode) != 0 {
log.Error("GetJob failed(%s): %s", response.ErrorCode, response.ErrorMsg)
return &result, fmt.Errorf("GetJob failed(%s): %s", response.ErrorCode, response.ErrorMsg)
}
@@ -185,6 +185,12 @@ sendjob:
return &result, fmt.Errorf("resty StopJob: %v", err)
}

if res.StatusCode() == http.StatusUnauthorized && retry < 1 {
retry++
_ = getToken()
goto sendjob
}

var response models.NotebookResult
err = json.Unmarshal(res.Body(), &response)
if err != nil {
@@ -192,13 +198,7 @@ sendjob:
return &result, fmt.Errorf("son.Unmarshal failed: %s", err.Error())
}

if response.ErrorCode == http.StatusUnauthorized && retry < 1 {
retry++
_ = getToken()
goto sendjob
}

if response.ErrorCode != 0 {
if len(response.ErrorCode) != 0 {
log.Error("StopJob failed(%s): %s", response.ErrorCode, response.ErrorMsg)
return &result, fmt.Errorf("StopJob failed(%s): %s", response.ErrorCode, response.ErrorMsg)
}
@@ -224,6 +224,12 @@ sendjob:
return &result, fmt.Errorf("resty DelJob: %v", err)
}

if res.StatusCode() == http.StatusUnauthorized && retry < 1 {
retry++
_ = getToken()
goto sendjob
}

var response models.NotebookResult
err = json.Unmarshal(res.Body(), &response)
if err != nil {
@@ -231,13 +237,7 @@ sendjob:
return &result, fmt.Errorf("son.Unmarshal failed: %s", err.Error())
}

if response.ErrorCode == http.StatusUnauthorized && retry < 1 {
retry++
_ = getToken()
goto sendjob
}

if response.ErrorCode != 0 {
if len(response.ErrorCode) != 0 {
log.Error("DelJob failed(%s): %s", response.ErrorCode, response.ErrorMsg)
return &result, fmt.Errorf("DelJob failed(%s): %s", response.ErrorCode, response.ErrorMsg)
}
@@ -263,6 +263,12 @@ sendjob:
return &result, fmt.Errorf("resty GetJobToken: %v", err)
}

if res.StatusCode() == http.StatusUnauthorized && retry < 1 {
retry++
_ = getToken()
goto sendjob
}

var response models.NotebookResult
err = json.Unmarshal(res.Body(), &response)
if err != nil {
@@ -270,13 +276,7 @@ sendjob:
return &result, fmt.Errorf("son.Unmarshal failed: %s", err.Error())
}

if response.ErrorCode == http.StatusUnauthorized && retry < 1 {
retry++
_ = getToken()
goto sendjob
}

if response.ErrorCode != 0 {
if len(response.ErrorCode) != 0 {
log.Error("GetJobToken failed(%s): %s", response.ErrorCode, response.ErrorMsg)
return &result, fmt.Errorf("GetJobToken failed(%s): %s", response.ErrorCode, response.ErrorMsg)
}


Loading…
Cancel
Save