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/ai_model_manage.go b/routers/repo/ai_model_manage.go index feacb4547..2c24527ce 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") + "(MB): " + fmt.Sprint(tmp.MemMiB) + " " + ctx.Tr("cloudbrain.shared_memory") + "(MB): " + 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/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) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index d3ae1624b..3bc7cb97c 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,23 +612,28 @@ 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.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 { 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 + } + } + return false } } + isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) if isCollaborator { - log.Info("Collaborator user may visit the attach.") return true } } diff --git a/templates/repo/modelmanage/showinfo.tmpl b/templates/repo/modelmanage/showinfo.tmpl index 0a57a5f44..a11ff59e5 100644 --- a/templates/repo/modelmanage/showinfo.tmpl +++ b/templates/repo/modelmanage/showinfo.tmpl @@ -191,7 +191,6 @@ -