Browse Source

提交代码

tags/v1.22.7.1
ychao_1983 3 years ago
parent
commit
66ed638d35
2 changed files with 15 additions and 15 deletions
  1. +10
    -10
      modules/grampus/grampus.go
  2. +5
    -5
      routers/repo/grampus.go

+ 10
- 10
modules/grampus/grampus.go View File

@@ -73,7 +73,7 @@ type GenerateTrainJobReq struct {
func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error) {
createTime := timeutil.TimeStampNow()

CenterID, CenterName := getCentersParamter(ctx, req)
centerID, centerName := getCentersParamter(ctx, req)

jobResult, err := createJob(models.CreateGrampusJobRequest{
Name: req.JobName,
@@ -84,8 +84,8 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error
ResourceSpecId: req.ResourceSpecId,
ImageId: req.ImageId,
ImageUrl: req.ImageUrl,
CenterID: CenterID,
CenterName: CenterName,
CenterID: centerID,
CenterName: centerName,
ReplicaNum: 1,
},
},
@@ -144,8 +144,8 @@ func GenerateTrainJob(ctx *context.Context, req *GenerateTrainJobReq) (err error
}

func getCentersParamter(ctx *context.Context, req *GenerateTrainJobReq) ([]string, []string) {
var CenterID []string
var CenterName []string
var centerID []string
var centerName []string

includeCenters := make(map[string]string)
excludeCenters := make(map[string]string)
@@ -174,8 +174,8 @@ func getCentersParamter(ctx *context.Context, req *GenerateTrainJobReq) ([]strin
if len(includeCenters) > 0 {
//如果有专属资源池,根据专属资源池指定智算中心
for k, v := range includeCenters {
CenterID = append(CenterID, k)
CenterName = append(CenterName, v)
centerID = append(centerID, k)
centerName = append(centerName, v)
}
} else if len(excludeCenters) > 0 {
//否则,有要排除的中心,先获取所有中心,删除其中的排除中心,得到指定的智算中心
@@ -195,12 +195,12 @@ func getCentersParamter(ctx *context.Context, req *GenerateTrainJobReq) ([]strin
}

for k, v := range allCenters {
CenterID = append(CenterID, k)
CenterName = append(CenterName, v)
centerID = append(centerID, k)
centerName = append(centerName, v)
}

}
return CenterID, CenterName
return centerID, centerName
}

func TransTrainJobStatus(status string) string {


+ 5
- 5
routers/repo/grampus.go View File

@@ -105,12 +105,12 @@ func grampusTrainJobNewDataPrepare(ctx *context.Context, processType string) err
//get valid resource specs
specs, err := grampus.GetResourceSpecs(processType)

GrampusSpecs := getFilterSpecBySpecialPool(specs, includeCenters, excludeCenters)
grampusSpecs := getFilterSpecBySpecialPool(specs, includeCenters, excludeCenters)

if err != nil {
log.Error("GetResourceSpecs failed:", err.Error())
} else {
ctx.Data["flavor_infos"] = GrampusSpecs
ctx.Data["flavor_infos"] = grampusSpecs
}

//get branches
@@ -136,14 +136,14 @@ func getFilterSpecBySpecialPool(specs *models.GetGrampusResourceSpecsResult, inc
if len(includeCenters) == 0 && len(excludeCenters) == 0 {
return specs.Infos
}
var GrampusSpecs []models.GrampusSpec
var grampusSpecs []models.GrampusSpec
for _, info := range specs.Infos {
if isInIncludeCenters(info, includeCenters) || (len(excludeCenters) != 0 && isNotAllInExcludeCenters(info, excludeCenters)) {
GrampusSpecs = append(GrampusSpecs, info)
grampusSpecs = append(grampusSpecs, info)
}

}
return GrampusSpecs
return grampusSpecs
}

func isInIncludeCenters(grampusSpec models.GrampusSpec, centers map[string]struct{}) bool {


Loading…
Cancel
Save