|
|
|
@@ -213,7 +213,7 @@ func cloudBrainNewDataPrepare(ctx *context.Context) error { |
|
|
|
} |
|
|
|
|
|
|
|
if len(trainGpuTypes) > 0 { |
|
|
|
ctx.Data["train_gpu_types"] = trainGpuInfos |
|
|
|
ctx.Data["train_gpu_types"] = trainGpuTypes |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
@@ -257,6 +257,10 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
repo := ctx.Repo.Repository |
|
|
|
tpl := tplCloudBrainNew |
|
|
|
|
|
|
|
if jobType == string(models.JobTypeTrain) { |
|
|
|
tpl = tplCloudBrainTrainJobNew |
|
|
|
} |
|
|
|
|
|
|
|
tasks, err := models.GetCloudbrainsByDisplayJobName(repo.ID, jobType, displayJobName) |
|
|
|
if err == nil { |
|
|
|
if len(tasks) != 0 { |
|
|
|
@@ -322,6 +326,13 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
command = commandTrain |
|
|
|
} |
|
|
|
|
|
|
|
errStr := checkCloudBrainSpecialPool(ctx, jobType, gpuQueue, resourceSpecId) |
|
|
|
|
|
|
|
if errStr != "" { |
|
|
|
cloudBrainNewDataPrepare(ctx) |
|
|
|
ctx.RenderWithErr(errStr, tpl, &form) |
|
|
|
} |
|
|
|
|
|
|
|
if branchName == "" { |
|
|
|
branchName = cloudbrain.DefaultBranchName |
|
|
|
} |
|
|
|
@@ -374,6 +385,42 @@ func CloudBrainCreate(ctx *context.Context, form auth.CreateCloudBrainForm) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
检查用户传输的参数是否符合专属资源池 |
|
|
|
*/ |
|
|
|
func checkCloudBrainSpecialPool(ctx *context.Context, jobType string, queue string, resourceSpecId int) string { |
|
|
|
if cloudbrain.SpecialPools != nil { |
|
|
|
|
|
|
|
var isInPoolOrg = false |
|
|
|
var matchSpecialPool = false |
|
|
|
|
|
|
|
for _, specialPool := range cloudbrain.SpecialPools.Pools { |
|
|
|
|
|
|
|
if cloudbrain.IsElementExist(specialPool.JobType, jobType) && cloudbrain.IsQueueInSpecialtPool(specialPool.Pool, queue) { |
|
|
|
if cloudbrain.IsResourceSpecInSpecialPool(specialPool.ResourceSpec, resourceSpecId) { |
|
|
|
matchSpecialPool = true |
|
|
|
org, _ := models.GetOrgByName(specialPool.Org) |
|
|
|
if org != nil { |
|
|
|
isInPoolOrg, _ = models.IsOrganizationMember(org.ID, ctx.User.ID) |
|
|
|
if isInPoolOrg { |
|
|
|
break //传入参数,和专属资源池匹配上了,检查通过 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//资源池有匹配上,但是用户不在相应的组织中,返回错误信息。界面已经过滤了选择,界面操作不会到这个逻辑 |
|
|
|
if matchSpecialPool && !isInPoolOrg { |
|
|
|
return ctx.Tr("repo.grampus.no_operate_right") |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//没有匹配到资源池或者没有设置专属资源池,检查通过; 获取和资源池完全匹配检查通过 |
|
|
|
return "" |
|
|
|
} |
|
|
|
|
|
|
|
func CloudBrainRestart(ctx *context.Context) { |
|
|
|
var ID = ctx.Params(":id") |
|
|
|
var resultCode = "0" |
|
|
|
|