@@ -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 + | dataActualPath := setting.Attachment.Minio.RealPath + | ||||
setting.Attachment.Minio.Bucket + "/" + | setting.Attachment.Minio.Bucket + "/" + | ||||
@@ -336,6 +336,7 @@ func GenerateTask(ctx *context.Context, displayJobName, jobName, image, command, | |||||
Parameters: params, | Parameters: params, | ||||
CreatedUnix: createTime, | CreatedUnix: createTime, | ||||
UpdatedUnix: createTime, | UpdatedUnix: createTime, | ||||
CommitID: commitID, | |||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
@@ -66,6 +66,14 @@ func saveModelByParameters(jobId string, versionName string, name string, versio | |||||
return err | return err | ||||
} | } | ||||
} else if cloudType == models.TypeCloudBrainOne { | } 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) | modelPath, modelSize, err = downloadModelFromCloudBrainOne(id, aiTask.JobName, "", aiTask.TrainUrl) | ||||
if err != nil { | if err != nil { | ||||
log.Info("download model from CloudBrainOne faild." + err.Error()) | log.Info("download model from CloudBrainOne faild." + err.Error()) | ||||
@@ -283,11 +283,13 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { | |||||
mkModelPath(modelPath) | mkModelPath(modelPath) | ||||
uploadCodeToMinio(modelPath, jobName, cloudbrain.ModelMountPath+"/") | 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+"/"), | err = cloudbrain.GenerateTask(ctx, displayJobName, jobName, image, command, uuid, storage.GetMinioPath(jobName, cloudbrain.CodeMountPath+"/"), | ||||
storage.GetMinioPath(jobName, cloudbrain.ModelMountPath+"/"), | storage.GetMinioPath(jobName, cloudbrain.ModelMountPath+"/"), | ||||
storage.GetMinioPath(jobName, cloudbrain.BenchMarkMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.Snn4imagenetMountPath+"/"), | storage.GetMinioPath(jobName, cloudbrain.BenchMarkMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.Snn4imagenetMountPath+"/"), | ||||
storage.GetMinioPath(jobName, cloudbrain.BrainScoreMountPath+"/"), jobType, gpuQueue, form.Description, branchName, form.BootFile, form.Params, | storage.GetMinioPath(jobName, cloudbrain.BrainScoreMountPath+"/"), jobType, gpuQueue, form.Description, branchName, form.BootFile, form.Params, | ||||
0, 0, resourceSpecId) | |||||
commitID, 0, 0, resourceSpecId) | |||||
if err != nil { | if err != nil { | ||||
cloudBrainNewDataPrepare(ctx) | cloudBrainNewDataPrepare(ctx) | ||||
ctx.RenderWithErr(err.Error(), tpl, &form) | 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.ModelMountPath+"/"), | ||||
storage.GetMinioPath(jobName, cloudbrain.BenchMarkMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.Snn4imagenetMountPath+"/"), | storage.GetMinioPath(jobName, cloudbrain.BenchMarkMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.Snn4imagenetMountPath+"/"), | ||||
storage.GetMinioPath(jobName, cloudbrain.BrainScoreMountPath+"/"), string(models.JobTypeBenchmark), gpuQueue, form.Description, cloudbrain.DefaultBranchName, "", "", | storage.GetMinioPath(jobName, cloudbrain.BrainScoreMountPath+"/"), string(models.JobTypeBenchmark), gpuQueue, form.Description, cloudbrain.DefaultBranchName, "", "", | ||||
benchmarkTypeID, benchmarkChildTypeID, resourceSpecId) | |||||
"", benchmarkTypeID, benchmarkChildTypeID, resourceSpecId) | |||||
if err != nil { | if err != nil { | ||||
cloudBrainNewDataPrepare(ctx) | cloudBrainNewDataPrepare(ctx) | ||||
ctx.RenderWithErr(err.Error(), tplCloudBrainBenchmarkNew, &form) | 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.ModelMountPath+"/"), | ||||
storage.GetMinioPath(jobName, cloudbrain.BenchMarkMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.Snn4imagenetMountPath+"/"), | storage.GetMinioPath(jobName, cloudbrain.BenchMarkMountPath+"/"), storage.GetMinioPath(jobName, cloudbrain.Snn4imagenetMountPath+"/"), | ||||
storage.GetMinioPath(jobName, cloudbrain.BrainScoreMountPath+"/"), jobType, gpuQueue, form.Description, branchName, form.BootFile, form.Params, | storage.GetMinioPath(jobName, cloudbrain.BrainScoreMountPath+"/"), jobType, gpuQueue, form.Description, branchName, form.BootFile, form.Params, | ||||
0, benchmarkChildTypeID, resourceSpecId) | |||||
"", 0, benchmarkChildTypeID, resourceSpecId) | |||||
if err != nil { | if err != nil { | ||||
cloudBrainNewDataPrepare(ctx) | cloudBrainNewDataPrepare(ctx) | ||||
ctx.RenderWithErr(err.Error(), tpl, &form) | ctx.RenderWithErr(err.Error(), tpl, &form) | ||||
@@ -522,7 +522,6 @@ func MyFavoriteDataset(ctx *context.Context) { | |||||
} | } | ||||
datasets := IsColDatasets | datasets := IsColDatasets | ||||
count := NotColcount + IsColcount | count := NotColcount + IsColcount | ||||
//排序 | |||||
sort.Slice(datasets, func(i, j int) bool { | sort.Slice(datasets, func(i, j int) bool { | ||||
return datasets[i].Attachment.CreatedUnix > datasets[j].Attachment.CreatedUnix | 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 { | func DatasetIsCollaborator(ctx *context.Context, DatasetID int64) bool { | ||||
dataset, err := models.GetDatasetByID(DatasetID) | dataset, err := models.GetDatasetByID(DatasetID) | ||||
if err != nil { | if err != nil { | ||||
log.Info("query dataset error") | |||||
log.Error("query dataset error:", err.Error()) | |||||
return false | |||||
} else { | } else { | ||||
repo, err := models.GetRepositoryByID(dataset.RepoID) | repo, err := models.GetRepositoryByID(dataset.RepoID) | ||||
if err != nil { | if err != nil { | ||||
log.Info("query repo error.") | |||||
log.Error("query repo error:", err.Error()) | |||||
} else { | } else { | ||||
repo.GetOwner() | repo.GetOwner() | ||||
if ctx.User != nil { | if ctx.User != nil { | ||||
if repo.Owner.IsOrganization() { | if repo.Owner.IsOrganization() { | ||||
if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { | 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) | isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) | ||||
if isCollaborator { | if isCollaborator { | ||||
log.Info("Collaborator user may visit the attach.") | |||||
return true | return true | ||||
} | } | ||||
} | } | ||||
@@ -191,7 +191,6 @@ | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||