diff --git a/modules/modelarts/modelarts.go b/modules/modelarts/modelarts.go index 1b4d093a1..4681c18d5 100755 --- a/modules/modelarts/modelarts.go +++ b/modules/modelarts/modelarts.go @@ -11,8 +11,6 @@ import ( "strconv" "strings" - "github.com/go-resty/resty/v2" - "code.gitea.io/gitea/modules/cloudbrain" "code.gitea.io/gitea/modules/modelarts_cd" @@ -932,8 +930,8 @@ func HandleNotebookInfo(task *models.Cloudbrain) error { func uploadNoteBookFile(task *models.Cloudbrain, result *models.GetNotebook2Result) { jupyterUrl := result.Url + "?token=" + result.Token - client := getRestyClient() - cookies, xsrf := getCookiesAndCsrf(client, jupyterUrl) + + cookies, xsrf := getCookiesAndCsrf(jupyterUrl) if xsrf == "" { log.Error("browser jupyterUrl failed:%v", task.DisplayJobName) } else { @@ -945,7 +943,7 @@ func uploadNoteBookFile(task *models.Cloudbrain, result *models.GetNotebook2Resu } base64Content := base64.StdEncoding.EncodeToString(fileContents) - + client := getRestyClient() uploadUrl := getJupyterBaseUrl(result.Url) + "api/contents/" + path.Base(task.BootFile) res, err := client.R(). SetCookies(cookies). @@ -973,11 +971,11 @@ func getJupyterBaseUrl(url string) string { return baseUrl } -func getCookiesAndCsrf(client *resty.Client, jupyterUrl string) ([]*http.Cookie, string) { - +func getCookiesAndCsrf(jupyterUrl string) ([]*http.Cookie, string) { + log.Info("jupyter url:"+jupyterUrl) var cookies []*http.Cookie - for i := 0; i < 4; i++ { - res, err := client.R().Get(jupyterUrl) + for i := 0; i < 10; i++ { + res, err := http.Get(jupyterUrl) if err != nil { log.Error("browser jupyterUrl failed.") return cookies, "" @@ -987,6 +985,7 @@ func getCookiesAndCsrf(client *resty.Client, jupyterUrl string) ([]*http.Cookie, for _, cookie := range cookies { if cookie.Name == "_xsrf" { xsrf = cookie.Value + break } }