From 2d93c784f3f8e2f583f95c954fc9586ff0c80c22 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 21 Oct 2022 16:58:50 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E7=9A=84=E5=9C=B0=E5=9D=80=E6=94=BE=E5=88=B0?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- modules/aisafety/resty.go | 5 +++-- modules/setting/setting.go | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/aisafety/resty.go b/modules/aisafety/resty.go index be6468529..ce1fa736e 100644 --- a/modules/aisafety/resty.go +++ b/modules/aisafety/resty.go @@ -10,6 +10,7 @@ import ( "strings" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/setting" "github.com/go-resty/resty/v2" ) @@ -71,8 +72,8 @@ func checkSetting() { } func loginCloudbrain() error { - HOST = "http://221.122.70.196:8081/atp-api" - KEY = "1" + HOST = setting.ModelSafetyTest.HOST + KEY = setting.ModelSafetyTest.KEY return nil } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index c6afae05a..6a2520162 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -718,6 +718,9 @@ var ( GPUBaseDataSetUUID string GPUCombatDataSetName string GPUCombatDataSetUUID string + + HOST string + KEY string }{} ModelApp = struct { @@ -1557,6 +1560,8 @@ func getModelSafetyConfig() { ModelSafetyTest.NPUBaseDataSetUUID = sec.Key("NPUBaseDataSetUUID").MustString("") ModelSafetyTest.NPUCombatDataSetName = sec.Key("NPUCombatDataSetName").MustString("") ModelSafetyTest.NPUCombatDataSetUUID = sec.Key("NPUCombatDataSetUUID").MustString("") + ModelSafetyTest.HOST = sec.Key("HOST").MustString("") + ModelSafetyTest.KEY = sec.Key("KEY").MustString("") } func getModelConvertConfig() { From 5b64d7871097a80c6354d8b936e5a09313d61b84 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 21 Oct 2022 17:00:47 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/aisafety.go | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/routers/repo/aisafety.go b/routers/repo/aisafety.go index 5102a6722..6881b4640 100644 --- a/routers/repo/aisafety.go +++ b/routers/repo/aisafety.go @@ -26,7 +26,6 @@ import ( "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/cloudbrain/resource" "code.gitea.io/gitea/services/reward/point/account" - uuid "github.com/satori/go.uuid" ) const ( @@ -37,39 +36,6 @@ const ( tplModelSafetyTestShow = "repo/modelsafety/show" ) -func CloudBrainAiSafetyCreateTest(ctx *context.Context) { - log.Info("start to create CloudBrainAiSafetyCreate") - uuid := uuid.NewV4() - id := uuid.String() - seriaNoParas := ctx.Query("serialNo") - fileName := ctx.Query("fileName") - - //if jobType == string(models.JobTypeBenchmark) { - req := aisafety.TaskReq{ - UnionId: id, - EvalName: "test1", - EvalContent: "test1", - TLPath: "test1", - Indicators: []string{"ACC", "ASS"}, - CDName: "CIFAR10_1000_FGSM", - BDName: "CIFAR10_1000基础数据集", - } - aisafety.GetAlgorithmList() - if seriaNoParas != "" { - aisafety.GetTaskStatus(seriaNoParas) - } else { - jsonStr, err := getJsonContent("http://192.168.207.34:8065/Test_zap1234/openi_aisafety/raw/branch/master/result/" + fileName) - serialNo, err := aisafety.CreateSafetyTask(req, jsonStr) - if err == nil { - log.Info("serialNo=" + serialNo) - time.Sleep(time.Duration(2) * time.Second) - aisafety.GetTaskStatus(serialNo) - } else { - log.Info("CreateSafetyTask error," + err.Error()) - } - } -} - func GetAiSafetyTaskByJob(job *models.Cloudbrain) { if job == nil { log.Error("GetCloudbrainByJobID failed") From cc99634a1a6b6c9f2b44975cd90398fc38e10491 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 26 Oct 2022 09:20:18 +0800 Subject: [PATCH 3/7] =?UTF-8?q?#3063,=E9=A6=96=E9=A1=B5=E6=96=87=E5=AD=97?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E6=9B=B4=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- options/locale/locale_en-US.ini | 2 +- options/locale/locale_zh-CN.ini | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 081db13ab..75314f6ec 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -266,7 +266,7 @@ page_dev_yunlao_desc4=Developers can freely select the corresponding computing r page_dev_yunlao_desc5=If your model requires more computing resources, you can also apply for it separately. page_dev_yunlao_apply=Apply Separately c2net_title=China Computing Network -c2net_desc=The artificial intelligence computing power network promotion alliance has access to 11 intelligent computing centers, with a total scale of 1924p. +c2net_desc=Extensive access to intelligent computing centers and supercomputing centers across the country to provide users with free computing resources. c2net_center=Center search=Search search_repo=Repository diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index ae8b6adc4..a6a841b76 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -267,8 +267,8 @@ page_dev_yunlao_desc3=中国算力网(C²NET)一期可实现不同人工智 page_dev_yunlao_desc4=开发者可以根据使用需求,自由选择相应计算资源,可以测试模型在不同硬件环境下的适配能力、性能、稳定性等。 page_dev_yunlao_desc5=如果您的模型需要更多的计算资源,也可以单独申请。 page_dev_yunlao_apply=单独申请 -c2net_title=智算网络 -c2net_desc=人工智能算力网络推进联盟已接入11家智算中心,算力总规模1924P +c2net_title=中国算力网 +c2net_desc=广泛接入全国各地智算中心、超算中心,为用户提供免费算力资源 c2net_center=中心 search=搜索 search_repo=项目 From 37b3cfebe1bee747ad3b09a653894fe63135e06c Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 26 Oct 2022 15:41:01 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E5=88=B7=E6=96=B0GPU=E8=A7=84=E6=A0=BC=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=A0=BC=E5=BC=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/ai_model_manage.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index 5b358b83b..b0bc0a62c 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -17,6 +17,7 @@ import ( "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" + "code.gitea.io/gitea/services/cloudbrain/resource" uuid "github.com/satori/go.uuid" ) @@ -69,14 +70,16 @@ func saveModelByParameters(jobId string, versionName string, name string, versio cloudType = models.TypeCloudBrainTwo } else if aiTask.ComputeResource == models.GPUResource { cloudType = models.TypeCloudBrainOne - var ResourceSpecs *models.ResourceSpecs - json.Unmarshal([]byte(setting.ResourceSpecs), &ResourceSpecs) - for _, tmp := range ResourceSpecs.ResourceSpec { - if tmp.Id == aiTask.ResourceSpecId { - flaverName := ctx.Tr("cloudbrain.gpu_num") + ": " + fmt.Sprint(tmp.GpuNum) + " " + ctx.Tr("cloudbrain.cpu_num") + ": " + fmt.Sprint(tmp.CpuNum) + " " + ctx.Tr("cloudbrain.memory") + "(MB): " + fmt.Sprint(tmp.MemMiB) + " " + ctx.Tr("cloudbrain.shared_memory") + "(MB): " + fmt.Sprint(tmp.ShareMemMiB) - aiTask.FlavorName = flaverName - } + spec, err := resource.GetAndCheckSpec(ctx.User.ID, int64(aiTask.ResourceSpecId), models.FindSpecsOptions{ + JobType: models.JobType(aiTask.JobType), + ComputeResource: models.GPU, + Cluster: models.OpenICluster, + AiCenterCode: models.AICenterOfCloudBrainOne}) + if err == nil { + flaverName := "GPU: " + fmt.Sprint(spec.AccCardsNum) + "*" + spec.AccCardType + ",CPU: " + fmt.Sprint(spec.CpuCores) + "," + ctx.Tr("cloudbrain.memory") + ": " + fmt.Sprint(spec.MemGiB) + "GB," + ctx.Tr("cloudbrain.shared_memory") + ": " + fmt.Sprint(spec.ShareMemGiB) + "GB" + aiTask.FlavorName = flaverName } + } accuracy := make(map[string]string) From e1fe38c0a3177dc2a60ab76ac37e63606518339b Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 26 Oct 2022 16:07:00 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=BF=A1=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/ai_model_manage.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index b0bc0a62c..f2b0fc6d1 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -70,16 +70,11 @@ func saveModelByParameters(jobId string, versionName string, name string, versio cloudType = models.TypeCloudBrainTwo } else if aiTask.ComputeResource == models.GPUResource { cloudType = models.TypeCloudBrainOne - spec, err := resource.GetAndCheckSpec(ctx.User.ID, int64(aiTask.ResourceSpecId), models.FindSpecsOptions{ - JobType: models.JobType(aiTask.JobType), - ComputeResource: models.GPU, - Cluster: models.OpenICluster, - AiCenterCode: models.AICenterOfCloudBrainOne}) + spec, err := resource.GetCloudbrainSpec(aiTask.ID) if err == nil { flaverName := "GPU: " + fmt.Sprint(spec.AccCardsNum) + "*" + spec.AccCardType + ",CPU: " + fmt.Sprint(spec.CpuCores) + "," + ctx.Tr("cloudbrain.memory") + ": " + fmt.Sprint(spec.MemGiB) + "GB," + ctx.Tr("cloudbrain.shared_memory") + ": " + fmt.Sprint(spec.ShareMemGiB) + "GB" aiTask.FlavorName = flaverName } - } accuracy := make(map[string]string) From 416004d08921f625edb398f4d49c224ae2c08504 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 27 Oct 2022 11:02:14 +0800 Subject: [PATCH 6/7] fix-2957 --- modules/setting/setting.go | 5 +++++ routers/repo/grampus.go | 6 ++---- services/cloudbrain/util.go | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 services/cloudbrain/util.go diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 2f468c850..2da970c75 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -597,6 +597,7 @@ var ( }{} C2NetInfos *C2NetSqInfos + C2NetMapInfo map[string]*C2NetSequenceInfo //elk config ElkUrl string @@ -1627,6 +1628,10 @@ func getGrampusConfig() { if err := json.Unmarshal([]byte(Grampus.C2NetSequence), &C2NetInfos); err != nil { log.Error("Unmarshal(C2NetSequence) failed:%v", err) } + C2NetMapInfo=make(map[string]*C2NetSequenceInfo) + for _,value :=range C2NetInfos.C2NetSqInfo{ + C2NetMapInfo[value.Name]=value + } } Grampus.SyncScriptProject = sec.Key("SYNC_SCRIPT_PROJECT").MustString("script_for_grampus") diff --git a/routers/repo/grampus.go b/routers/repo/grampus.go index d901298b7..e29bf0abc 100755 --- a/routers/repo/grampus.go +++ b/routers/repo/grampus.go @@ -37,6 +37,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + cloudbrainService "code.gitea.io/gitea/services/cloudbrain" ) const ( @@ -915,10 +916,7 @@ func GrampusTrainJobShow(ctx *context.Context) { ctx.Data["canDownload"] = cloudbrain.CanModifyJob(ctx, task) ctx.Data["displayJobName"] = task.DisplayJobName - aiCenterInfo := strings.Split(task.AiCenter, "+") - if len(aiCenterInfo) == 2 { - ctx.Data["ai_center"] = aiCenterInfo[1] - } + ctx.Data["ai_center"] = cloudbrainService.GetAiCenterShow(task.AiCenter,ctx) ctx.HTML(http.StatusOK, tplGrampusTrainJobShow) } diff --git a/services/cloudbrain/util.go b/services/cloudbrain/util.go new file mode 100644 index 000000000..ab738927e --- /dev/null +++ b/services/cloudbrain/util.go @@ -0,0 +1,33 @@ +package cloudbrain + +import ( + "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/setting" + "strings" +) + +func GetAiCenterShow(aiCenter string,ctx *context.Context) string{ + aiCenterInfo := strings.Split(aiCenter, "+") + + if len(aiCenterInfo) == 2{ + if setting.C2NetMapInfo!=nil { + if info,ok:=setting.C2NetMapInfo[aiCenterInfo[0]];ok { + if ctx.Language() == "zh-CN" { + return info.Content + } else { + return info.ContentEN + } + }else{ + return aiCenterInfo[1] + } + + }else{ + return aiCenterInfo[1] + } + + } + + return "" + + +} From 7b518359ce77f3bc05af0556a64fee0692606be6 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 27 Oct 2022 14:54:20 +0800 Subject: [PATCH 7/7] =?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 --- routers/repo/dataset.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index f0e41024b..16e21e43b 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -523,6 +523,7 @@ func ReferenceDatasetAvailable(ctx *context.Context) { PublicOnly: true, NeedAttachment: false, CloudBrainType: models.TypeCloudBrainAll, + SearchOrderBy: models.SearchOrderByDefault, } dataset, _ := models.GetDatasetByRepo(&models.Repository{ID: ctx.Repo.Repository.ID}) if dataset != nil { @@ -538,6 +539,7 @@ func PublicDatasetMultiple(ctx *context.Context) { PublicOnly: true, NeedAttachment: true, CloudBrainType: ctx.QueryInt("type"), + SearchOrderBy: models.SearchOrderByDefault, } datasetMultiple(ctx, opts)