From 77ac02cfe9b1aa12bdc4b9d4db87d65dbed6fe35 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 21 Nov 2022 08:50:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/modelarts/modelarts.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/modelarts/modelarts.go b/modules/modelarts/modelarts.go index acbe8947f..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,7 +971,7 @@ 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 < 10; i++ {