From b3b4276596b05c3178bb21e2f62535af4676e667 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 13 Dec 2022 10:59:10 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E4=B8=BAmlops=E5=A2=9E=E5=8A=A0=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E4=BB=BB=E5=8A=A1=E5=90=8D=E8=8E=B7=E5=8F=96jobId?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/api/v1/api.go | 1 + routers/api/v1/repo/mlops.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 66a73862b..d8ad9fdbc 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -763,6 +763,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/:username/:reponame", func() { m.Get("/right", reqToken(), repo.GetRight) m.Get("/tagger", reqToken(), repo.ListTagger) + m.Get("/cloudBrainJobId", repo.GetCloudBrainJobId) m.Combo("").Get(reqAnyRepoReader(), repo.Get). Delete(reqToken(), reqOwner(), repo.Delete). Patch(reqToken(), reqAdmin(), bind(api.EditRepoOption{}), context.RepoRef(), repo.Edit) diff --git a/routers/api/v1/repo/mlops.go b/routers/api/v1/repo/mlops.go index 43969330d..322edc3e5 100644 --- a/routers/api/v1/repo/mlops.go +++ b/routers/api/v1/repo/mlops.go @@ -69,3 +69,17 @@ func GetRight(ctx *context.APIContext) { }) } + +func GetCloudBrainJobId(ctx *context.APIContext) { + cloudbrains, err := models.GetCloudbrainsByDisplayJobName(ctx.Repo.Repository.ID, ctx.Query("jobType"), ctx.Query("name")) + if err != nil { + log.Warn("get cloudbrain by display name failed", err) + ctx.JSON(http.StatusOK, map[string]string{"jobId": ""}) + return + } + if len(cloudbrains) > 0 { + ctx.JSON(http.StatusOK, map[string]string{"jobId": cloudbrains[0].JobID}) + return + } + ctx.JSON(http.StatusOK, map[string]string{"jobId": ""}) +} From 13ad54470d3420575006637bef35ae05b01d15e9 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 13 Dec 2022 16:25:46 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=8F=8A=E6=A8=A1=E5=9E=8B=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=90=8D=E7=A7=B0=E6=9F=A5=E8=AF=A2=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/ai_model_manage.go | 12 ++++++++++++ routers/api/v1/api.go | 2 ++ routers/api/v1/repo/modelmanage.go | 14 ++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/models/ai_model_manage.go b/models/ai_model_manage.go index 4fe74e555..02f6b12c9 100644 --- a/models/ai_model_manage.go +++ b/models/ai_model_manage.go @@ -221,6 +221,18 @@ func SaveModelToDb(model *AiModelManage) error { return nil } +func QueryModelConvertByName(name string) ([]*AiModelConvert, error) { + sess := x.NewSession() + defer sess.Close() + sess.Select("*").Table(new(AiModelConvert)).Where("name='" + name + "'") + aiModelManageConvertList := make([]*AiModelConvert, 0) + err := sess.Find(&aiModelManageConvertList) + if err == nil { + return aiModelManageConvertList, nil + } + return nil, err +} + func QueryModelConvertById(id string) (*AiModelConvert, error) { sess := x.NewSession() defer sess.Close() diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index d8ad9fdbc..3e50b00fc 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -1021,6 +1021,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Delete("/delete_model", repo.DeleteModel) m.Get("/downloadall", repo.DownloadModel) m.Get("/query_model_byId", repo.QueryModelById) + m.Get("/query_model_byName", repo.QueryModelByName) m.Get("/query_model_for_predict", repo.QueryModelListForPredict) m.Get("/query_modelfile_for_predict", repo.QueryModelFileForPredict) m.Get("/query_train_model", repo.QueryTrainModelList) @@ -1028,6 +1029,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/convert_stop", repo.StopModelConvert) m.Get("/show_model_convert_page", repo.ShowModelConvertPage) m.Get("/query_model_convert_byId", repo.QueryModelConvertById) + m.Get("/query_model_convert_byName", repo.QueryModelConvertByName) m.Get("/:id", repo.GetCloudbrainModelConvertTask) m.Get("/:id/log", repo.CloudbrainForModelConvertGetLog) diff --git a/routers/api/v1/repo/modelmanage.go b/routers/api/v1/repo/modelmanage.go index a8166732d..3b0aed0d5 100644 --- a/routers/api/v1/repo/modelmanage.go +++ b/routers/api/v1/repo/modelmanage.go @@ -43,6 +43,11 @@ func QueryModelById(ctx *context.APIContext) { routerRepo.QueryModelById(ctx.Context) } +func QueryModelByName(ctx *context.APIContext) { + log.Info("QueryModelByName by api.") + routerRepo.ShowSingleModel(ctx.Context) +} + func QueryModelListForPredict(ctx *context.APIContext) { log.Info("QueryModelListForPredict by api.") ctx.Context.SetParams("isOnlyThisRepo", "true") @@ -119,3 +124,12 @@ func QueryModelConvertById(ctx *context.APIContext) { ctx.JSON(http.StatusOK, nil) } } + +func QueryModelConvertByName(ctx *context.APIContext) { + modelResult, err := routerRepo.GetModelConvertByName(ctx.Context) + if err == nil { + ctx.JSON(http.StatusOK, modelResult) + } else { + ctx.JSON(http.StatusOK, nil) + } +} From ae70992fd9da91915bb6dd3bb4c5b9cf272b9883 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 13 Dec 2022 16:43:23 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E6=9F=A5=E8=AF=A2=E6=A8=A1=E5=9E=8B=E5=8F=8A?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E8=BD=AC=E6=8D=A2=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/ai_model_manage.go | 5 +++-- routers/repo/ai_model_convert.go | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/models/ai_model_manage.go b/models/ai_model_manage.go index 02f6b12c9..702cf0937 100644 --- a/models/ai_model_manage.go +++ b/models/ai_model_manage.go @@ -221,10 +221,11 @@ func SaveModelToDb(model *AiModelManage) error { return nil } -func QueryModelConvertByName(name string) ([]*AiModelConvert, error) { +func QueryModelConvertByName(name string, repoId int64) ([]*AiModelConvert, error) { sess := x.NewSession() defer sess.Close() - sess.Select("*").Table(new(AiModelConvert)).Where("name='" + name + "'") + sess.Select("*").Table(new(AiModelConvert)). + Where("name='" + name + "' and repo_id=" + fmt.Sprint(repoId)).OrderBy("created_unix desc") aiModelManageConvertList := make([]*AiModelConvert, 0) err := sess.Find(&aiModelManageConvertList) if err == nil { diff --git a/routers/repo/ai_model_convert.go b/routers/repo/ai_model_convert.go index 4b22998f5..9839a5041 100644 --- a/routers/repo/ai_model_convert.go +++ b/routers/repo/ai_model_convert.go @@ -758,6 +758,11 @@ func GetModelConvertById(ctx *context.Context) (*models.AiModelConvert, error) { return models.QueryModelConvertById(id) } +func GetModelConvertByName(ctx *context.Context) ([]*models.AiModelConvert, error) { + name := ctx.Query("name") + return models.QueryModelConvertByName(name, ctx.Repo.Repository.ID) +} + func GetModelConvertPageData(ctx *context.Context) ([]*models.AiModelConvert, int64, error) { page := ctx.QueryInt("page") if page <= 0 { From 06765e57049b94c8e2c69b4499beeca2ca3554e5 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 14 Dec 2022 11:06:16 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 394c24825..05a4e6c82 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -2089,8 +2089,8 @@ func queryUserCreateRepo(start_unix int64, end_unix int64) (map[int64]int, map[s detailInfoMap[key] = getMapKeyStringValue(key, detailInfoMap) + int(repoRecord.CloneCnt) key = fmt.Sprint(repoRecord.OwnerID) + "_most_download" - if int(repoRecord.CloneCnt) > getMapKeyStringValue(key, detailInfoMap) { - detailInfoMap[key] = int(repoRecord.CloneCnt) + if int(repoRecord.GitCloneCnt) > getMapKeyStringValue(key, detailInfoMap) { + detailInfoMap[key] = int(repoRecord.GitCloneCnt) mostDownloadMap[repoRecord.OwnerID] = repoRecord.DisplayName() } } From aa4600c4f31ab9e18f202c80e58caea0e378dc31 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 14 Dec 2022 11:23:15 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 4ae9f6ced..99b4cb567 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -811,6 +811,7 @@ func getBonusMap() map[string]map[string]int { record, ok := bonusMap[userName] if !ok { record = make(map[string]int) + bonusMap[userName] = record } record["times"] = getMapKeyStringValue("times", record) + getIntValue(aLine[3]) record["total_bonus"] = getMapKeyStringValue("total_bonus", record) + getIntValue(aLine[4]) @@ -2106,8 +2107,8 @@ func queryUserCreateRepo(start_unix int64, end_unix int64) (map[int64]int, map[s detailInfoMap[key] = getMapKeyStringValue(key, detailInfoMap) + int(repoRecord.CloneCnt) key = fmt.Sprint(repoRecord.OwnerID) + "_most_download" - if int(repoRecord.GitCloneCnt) > getMapKeyStringValue(key, detailInfoMap) { - detailInfoMap[key] = int(repoRecord.GitCloneCnt) + if int(repoRecord.CloneCnt) > getMapKeyStringValue(key, detailInfoMap) { + detailInfoMap[key] = int(repoRecord.CloneCnt) mostDownloadMap[repoRecord.OwnerID] = repoRecord.DisplayName() } } From 0ab2224c974ad649594e713237097607c0745ea9 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 14 Dec 2022 11:24:25 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 1 + 1 file changed, 1 insertion(+) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 99b4cb567..24177371e 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -2107,6 +2107,7 @@ func queryUserCreateRepo(start_unix int64, end_unix int64) (map[int64]int, map[s detailInfoMap[key] = getMapKeyStringValue(key, detailInfoMap) + int(repoRecord.CloneCnt) key = fmt.Sprint(repoRecord.OwnerID) + "_most_download" + log.Info("git clone count =" + fmt.Sprint(repoRecord.CloneCnt) + " key=" + key) if int(repoRecord.CloneCnt) > getMapKeyStringValue(key, detailInfoMap) { detailInfoMap[key] = int(repoRecord.CloneCnt) mostDownloadMap[repoRecord.OwnerID] = repoRecord.DisplayName() From a8baf47d5b32f7f459af58fed831e839694b6ec5 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 14 Dec 2022 11:34:21 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=B9=B4=E5=BA=A6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=80=BB=E7=BB=93=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 24177371e..647e51a71 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -856,6 +856,9 @@ func getCloudBrainInfo(dateRecordAll UserBusinessAnalysisAll, CloudBrainTaskItem trainscore := 0.0 debugscore := 0.0 runtime := 0.0 + if dateRecordAll.Name == "Test_zap1234" { + log.Info("Test_zap1234 dateRecordAll.CloudBrainTaskNum=" + fmt.Sprint(dateRecordAll.CloudBrainTaskNum)) + } if dateRecordAll.CloudBrainTaskNum > 0 { cloudBrainInfo := make(map[string]string) cloudBrainInfo["create_task_num"] = fmt.Sprint(dateRecordAll.CloudBrainTaskNum) From 0b4e310366ea3abc8b1a349984fd69c0b825cb70 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 14 Dec 2022 11:42:18 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E8=A7=A3=E5=86=B3Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 647e51a71..e6cdc4889 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -785,8 +785,9 @@ func isUserYearData(tableName string) bool { if currentTimeNow.Year() >= 2023 { return false } + return true } - return true + return false } func getBonusMap() map[string]map[string]int { From 80cc401681487491c366e82c388d60dd2885a8fe Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 14 Dec 2022 11:43:10 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E8=A7=A3=E5=86=B3Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 1 - 1 file changed, 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index e6cdc4889..bb5352d7c 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -2111,7 +2111,6 @@ func queryUserCreateRepo(start_unix int64, end_unix int64) (map[int64]int, map[s detailInfoMap[key] = getMapKeyStringValue(key, detailInfoMap) + int(repoRecord.CloneCnt) key = fmt.Sprint(repoRecord.OwnerID) + "_most_download" - log.Info("git clone count =" + fmt.Sprint(repoRecord.CloneCnt) + " key=" + key) if int(repoRecord.CloneCnt) > getMapKeyStringValue(key, detailInfoMap) { detailInfoMap[key] = int(repoRecord.CloneCnt) mostDownloadMap[repoRecord.OwnerID] = repoRecord.DisplayName() From 610e3a0e31cad5679b2332eea0c343ecf99d9fb8 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 14 Dec 2022 14:42:45 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E8=A7=A3=E5=86=B3Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index bb5352d7c..6c247709e 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -857,9 +857,6 @@ func getCloudBrainInfo(dateRecordAll UserBusinessAnalysisAll, CloudBrainTaskItem trainscore := 0.0 debugscore := 0.0 runtime := 0.0 - if dateRecordAll.Name == "Test_zap1234" { - log.Info("Test_zap1234 dateRecordAll.CloudBrainTaskNum=" + fmt.Sprint(dateRecordAll.CloudBrainTaskNum)) - } if dateRecordAll.CloudBrainTaskNum > 0 { cloudBrainInfo := make(map[string]string) cloudBrainInfo["create_task_num"] = fmt.Sprint(dateRecordAll.CloudBrainTaskNum)