From 6eb4949154ff5f91c3d22c5428104bc84985bf6c Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 16 Jun 2022 10:25:01 +0800 Subject: [PATCH 1/7] fix-2208 --- routers/repo/dataset.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index d3ae1624b..e4272c053 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -623,10 +623,16 @@ func DatasetIsCollaborator(ctx *context.Context, DatasetID int64) bool { if ctx.User != nil { if repo.Owner.IsOrganization() { if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { - log.Info("org user may visit the attach.") - return true + for _, t := range repo.Owner.Teams { + if t.IsMember(ctx.User.ID) && t.HasRepository(repo.ID) { + return true + } + } + log.Info("org user can visit the attach.") + return false } } + isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) if isCollaborator { log.Info("Collaborator user may visit the attach.") From 93022126974679e0dee6613fa5ba8c4b3360363a Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Thu, 16 Jun 2022 10:50:15 +0800 Subject: [PATCH 2/7] add commit id for gpu --- modules/cloudbrain/cloudbrain.go | 3 ++- routers/repo/cloudbrain.go | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/cloudbrain/cloudbrain.go b/modules/cloudbrain/cloudbrain.go index a71389741..8fb13ca4c 100755 --- a/modules/cloudbrain/cloudbrain.go +++ b/modules/cloudbrain/cloudbrain.go @@ -187,7 +187,7 @@ func AdminOrImageCreaterRight(ctx *context.Context) { } -func GenerateTask(ctx *context.Context, displayJobName, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, brainScorePath, jobType, gpuQueue, description, branchName, bootFile, params string, benchmarkTypeID, benchmarkChildTypeID, resourceSpecId int) error { +func GenerateTask(ctx *context.Context, displayJobName, jobName, image, command, uuid, codePath, modelPath, benchmarkPath, snn4imagenetPath, brainScorePath, jobType, gpuQueue, description, branchName, bootFile, params, commitID string, benchmarkTypeID, benchmarkChildTypeID, resourceSpecId int) error { dataActualPath := setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + @@ -336,6 +336,7 @@ func GenerateTask(ctx *context.Context, displayJobName, jobName, image, command, Parameters: params, CreatedUnix: createTime, UpdatedUnix: createTime, + CommitID: commitID, }) if err != nil { diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index a93ff018c..eb2ddc93b 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -283,11 +283,13 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { mkModelPath(modelPath) uploadCodeToMinio(modelPath, jobName, cloudbrain.ModelMountPath+"/") + commitID, _ := ctx.Repo.GitRepo.GetBranchCommitID(branchName) + err = cloudbrain.GenerateTask(ctx, displayJobName, jobName, image, command, uuid, storage.GetMinioPath(jobName, cloudbrain.CodeMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.ModelMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.BenchMarkMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.Snn4imagenetMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.BrainScoreMountPath+"/"), jobType, gpuQueue, form.Description, branchName, form.BootFile, form.Params, - 0, 0, resourceSpecId) + commitID, 0, 0, resourceSpecId) if err != nil { cloudBrainNewDataPrepare(ctx) ctx.RenderWithErr(err.Error(), tpl, &form) @@ -1984,7 +1986,7 @@ func BenchMarkAlgorithmCreate(ctx *context.Context, form auth.CreateCloudBrainFo storage.GetMinioPath(jobName, cloudbrain.ModelMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.BenchMarkMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.Snn4imagenetMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.BrainScoreMountPath+"/"), string(models.JobTypeBenchmark), gpuQueue, form.Description, cloudbrain.DefaultBranchName, "", "", - benchmarkTypeID, benchmarkChildTypeID, resourceSpecId) + "", benchmarkTypeID, benchmarkChildTypeID, resourceSpecId) if err != nil { cloudBrainNewDataPrepare(ctx) ctx.RenderWithErr(err.Error(), tplCloudBrainBenchmarkNew, &form) @@ -2082,7 +2084,7 @@ func ModelBenchmarkCreate(ctx *context.Context, form auth.CreateCloudBrainForm) storage.GetMinioPath(jobName, cloudbrain.ModelMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.BenchMarkMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.Snn4imagenetMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.BrainScoreMountPath+"/"), jobType, gpuQueue, form.Description, branchName, form.BootFile, form.Params, - 0, benchmarkChildTypeID, resourceSpecId) + "", 0, benchmarkChildTypeID, resourceSpecId) if err != nil { cloudBrainNewDataPrepare(ctx) ctx.RenderWithErr(err.Error(), tpl, &form) From 0f1a2e79d4d81688440239983f6e6daf61d597de Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 16 Jun 2022 11:04:27 +0800 Subject: [PATCH 3/7] fix-2208 --- routers/repo/dataset.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index e4272c053..6a0253bb2 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -522,7 +522,6 @@ func MyFavoriteDataset(ctx *context.Context) { } datasets := IsColDatasets count := NotColcount + IsColcount - //排序 sort.Slice(datasets, func(i, j int) bool { return datasets[i].Attachment.CreatedUnix > datasets[j].Attachment.CreatedUnix }) @@ -613,7 +612,8 @@ func GetDatasetStatus(ctx *context.Context) { func DatasetIsCollaborator(ctx *context.Context, DatasetID int64) bool { dataset, err := models.GetDatasetByID(DatasetID) if err != nil { - log.Info("query dataset error") + log.Info("query dataset error:", DatasetID) + return false } else { repo, err := models.GetRepositoryByID(dataset.RepoID) if err != nil { From 87fea27067b6eb1756f82aa5a651f098647a45db Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 16 Jun 2022 11:04:32 +0800 Subject: [PATCH 4/7] =?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 --- routers/repo/ai_model_manage.go | 8 ++++++++ templates/repo/modelmanage/showinfo.tmpl | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index feacb4547..ebe2c3202 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -66,6 +66,14 @@ func saveModelByParameters(jobId string, versionName string, name string, versio return err } } else if 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") + ":" + fmt.Sprint(tmp.MemMiB) + ctx.Tr("cloudbrain.shared_memory") + ":" + fmt.Sprint(tmp.ShareMemMiB) + aiTask.FlavorName = flaverName + } + } modelPath, modelSize, err = downloadModelFromCloudBrainOne(id, aiTask.JobName, "", aiTask.TrainUrl) if err != nil { log.Info("download model from CloudBrainOne faild." + err.Error()) diff --git a/templates/repo/modelmanage/showinfo.tmpl b/templates/repo/modelmanage/showinfo.tmpl index 0a57a5f44..ee3f30b8c 100644 --- a/templates/repo/modelmanage/showinfo.tmpl +++ b/templates/repo/modelmanage/showinfo.tmpl @@ -191,7 +191,7 @@ - + From 3d0c887883a07e8d866b5ca2e53480e4c6530f6f Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 16 Jun 2022 11:05:02 +0800 Subject: [PATCH 5/7] =?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 --- templates/repo/modelmanage/showinfo.tmpl | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/repo/modelmanage/showinfo.tmpl b/templates/repo/modelmanage/showinfo.tmpl index ee3f30b8c..a11ff59e5 100644 --- a/templates/repo/modelmanage/showinfo.tmpl +++ b/templates/repo/modelmanage/showinfo.tmpl @@ -191,7 +191,6 @@ - From d1899170787b1c670a1e090561ad115a1183e348 Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 16 Jun 2022 11:11:43 +0800 Subject: [PATCH 6/7] fix-2208 --- routers/repo/dataset.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 6a0253bb2..3bc7cb97c 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -612,12 +612,12 @@ func GetDatasetStatus(ctx *context.Context) { func DatasetIsCollaborator(ctx *context.Context, DatasetID int64) bool { dataset, err := models.GetDatasetByID(DatasetID) if err != nil { - log.Info("query dataset error:", DatasetID) + log.Error("query dataset error:", err.Error()) return false } else { repo, err := models.GetRepositoryByID(dataset.RepoID) if err != nil { - log.Info("query repo error.") + log.Error("query repo error:", err.Error()) } else { repo.GetOwner() if ctx.User != nil { @@ -628,14 +628,12 @@ func DatasetIsCollaborator(ctx *context.Context, DatasetID int64) bool { return true } } - log.Info("org user can visit the attach.") return false } } isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) if isCollaborator { - log.Info("Collaborator user may visit the attach.") return true } } From 3e66c119c9acb3ede39de858ab2bf0f1c9a8a396 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 16 Jun 2022 11:11:57 +0800 Subject: [PATCH 7/7] =?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 --- routers/repo/ai_model_manage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index ebe2c3202..2c24527ce 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -70,7 +70,7 @@ func saveModelByParameters(jobId string, versionName string, name string, versio 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") + ":" + fmt.Sprint(tmp.MemMiB) + ctx.Tr("cloudbrain.shared_memory") + ":" + fmt.Sprint(tmp.ShareMemMiB) + 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 } }