|
|
@@ -625,7 +625,7 @@ func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { |
|
|
|
page := 1 |
|
|
|
pagesize := 10000 |
|
|
|
count := pagesize |
|
|
|
//Each time a maximum of 1000 pieces of data are detected to the memory, batch processing |
|
|
|
//Each time a maximum of 10000 pieces of data are detected to the memory, batch processing |
|
|
|
for count == pagesize && count != 0 { |
|
|
|
cloudbrains, _, err := models.CloudbrainAllStatic(&models.CloudbrainsOptions{ |
|
|
|
ListOptions: models.ListOptions{ |
|
|
@@ -699,6 +699,9 @@ func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { |
|
|
|
if _, ok := intelligentNetJobTypeRes[v]; !ok { |
|
|
|
intelligentNetJobTypeRes[v] = 0 |
|
|
|
} |
|
|
|
if _, ok := cDCenterJobTypeRes[v]; !ok { |
|
|
|
cDCenterJobTypeRes[v] = 0 |
|
|
|
} |
|
|
|
} |
|
|
|
cloudBrainTypeList := []int{0, 1, 2, 3} |
|
|
|
for _, v := range cloudBrainTypeList { |
|
|
@@ -714,9 +717,10 @@ func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
cloudOneJobTypeRes["EVALUATION"] = cloudOneJobTypeRes[string(models.JobTypeBenchmark)] + cloudOneJobTypeRes[string(models.JobTypeSnn4imagenet)] + cloudOneJobTypeRes[string(models.JobTypeBrainScore)] |
|
|
|
cloudTwoJobTypeRes["EVALUATION"] = cloudTwoJobTypeRes[string(models.JobTypeBenchmark)] + cloudTwoJobTypeRes[string(models.JobTypeSnn4imagenet)] + cloudTwoJobTypeRes[string(models.JobTypeBrainScore)] |
|
|
|
intelligentNetJobTypeRes["EVALUATION"] = intelligentNetJobTypeRes[string(models.JobTypeBenchmark)] + intelligentNetJobTypeRes[string(models.JobTypeSnn4imagenet)] + intelligentNetJobTypeRes[string(models.JobTypeBrainScore)] |
|
|
|
cloudOneJobTypeRes["EVALUATION"] = cloudBrainPeriodNum[0] - cloudOneJobTypeRes[string(models.JobTypeTrain)] - cloudOneJobTypeRes[string(models.JobTypeInference)] - cloudOneJobTypeRes[string(models.JobTypeDebug)] |
|
|
|
cloudTwoJobTypeRes["EVALUATION"] = cloudBrainPeriodNum[1] - cloudTwoJobTypeRes[string(models.JobTypeTrain)] - cloudTwoJobTypeRes[string(models.JobTypeInference)] - cloudTwoJobTypeRes[string(models.JobTypeDebug)] |
|
|
|
intelligentNetJobTypeRes["EVALUATION"] = cloudBrainPeriodNum[2] - intelligentNetJobTypeRes[string(models.JobTypeTrain)] - intelligentNetJobTypeRes[string(models.JobTypeInference)] - intelligentNetJobTypeRes[string(models.JobTypeDebug)] |
|
|
|
cDCenterJobTypeRes["EVALUATION"] = cloudBrainPeriodNum[3] - cDCenterJobTypeRes[string(models.JobTypeTrain)] - cDCenterJobTypeRes[string(models.JobTypeInference)] - cDCenterJobTypeRes[string(models.JobTypeDebug)] |
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{ |
|
|
|
"cloudOneJobTypeRes": cloudOneJobTypeRes, |
|
|
|
"cloudTwoJobTypeRes": cloudTwoJobTypeRes, |
|
|
@@ -728,62 +732,6 @@ func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
func GetCloudbrainsStatusAnalysis(ctx *context.Context) { |
|
|
|
// recordCloudbrain, err := models.GetRecordBeginTime() |
|
|
|
// if err != nil { |
|
|
|
// log.Error("Can not get recordCloudbrain", err) |
|
|
|
// ctx.Error(http.StatusBadRequest, ctx.Tr("repo.record_begintime_get_err")) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// recordBeginTime := recordCloudbrain[0].Cloudbrain.CreatedUnix |
|
|
|
// endTime := time.Now() |
|
|
|
// cloudBrainStatusResult := make(map[string]int) |
|
|
|
// cloudBrainStatusAnalysis := make(map[string]int) |
|
|
|
// totalCount := 0 |
|
|
|
|
|
|
|
// page := 1 |
|
|
|
// pagesize := 1000 |
|
|
|
// count := pagesize |
|
|
|
// for count == pagesize && count != 0 { |
|
|
|
// cloudbrains, _, err := models.CloudbrainAllStatic(&models.CloudbrainsOptions{ |
|
|
|
// ListOptions: models.ListOptions{ |
|
|
|
// Page: page, |
|
|
|
// PageSize: pagesize, |
|
|
|
// }, |
|
|
|
// Type: models.TypeCloudBrainAll, |
|
|
|
// BeginTimeUnix: int64(recordBeginTime), |
|
|
|
// EndTimeUnix: endTime.Unix(), |
|
|
|
// }) |
|
|
|
// if err != nil { |
|
|
|
// ctx.ServerError("Get cloudbrains failed:", err) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// for _, cloudbrain := range cloudbrains { |
|
|
|
// if _, ok := cloudBrainStatusResult[cloudbrain.Status]; !ok { |
|
|
|
// cloudBrainStatusResult[cloudbrain.Status] = 1 |
|
|
|
// } else { |
|
|
|
// cloudBrainStatusResult[cloudbrain.Status] += 1 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// count = len(cloudbrains) |
|
|
|
// totalCount = totalCount + count |
|
|
|
// page += 1 |
|
|
|
// } |
|
|
|
|
|
|
|
// var jobStatuses []string |
|
|
|
// jobStatuses = append(jobStatuses, string(models.ModelArtsTrainJobWaiting), string(models.ModelArtsTrainJobFailed), string(models.ModelArtsRunning), string(models.ModelArtsTrainJobCompleted), |
|
|
|
// string(models.ModelArtsStarting), string(models.ModelArtsRestarting), string(models.ModelArtsStartFailed), |
|
|
|
// string(models.ModelArtsStopping), string(models.ModelArtsStopped), string(models.JobSucceeded)) |
|
|
|
// jobStatusesCount := 0 |
|
|
|
// for _, v := range jobStatuses { |
|
|
|
// if _, ok := cloudBrainStatusResult[v]; !ok { |
|
|
|
// cloudBrainStatusAnalysis[v] = 0 |
|
|
|
// } else { |
|
|
|
// cloudBrainStatusAnalysis[v] = cloudBrainStatusResult[v] |
|
|
|
// } |
|
|
|
// jobStatusesCount = jobStatusesCount + cloudBrainStatusResult[v] |
|
|
|
// } |
|
|
|
// cloudBrainStatusAnalysis["OTHER"] = totalCount - jobStatusesCount |
|
|
|
|
|
|
|
cloudbrainStatusCount, err := models.GetCloudbrainStatusCount() |
|
|
|
log.Info("cloudbrainStatusCount:", cloudbrainStatusCount) |
|
|
|
if err != nil { |
|
|
@@ -792,7 +740,6 @@ func GetCloudbrainsStatusAnalysis(ctx *context.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
ctx.JSON(http.StatusOK, map[string]interface{}{ |
|
|
|
// "cloudBrainStatusResult": cloudBrainStatusAnalysis, |
|
|
|
"cloudbrainStatusCount": cloudbrainStatusCount, |
|
|
|
}) |
|
|
|
} |
|
|
@@ -893,14 +840,6 @@ func GetCloudbrainsDetailData(ctx *context.Context) { |
|
|
|
} else { |
|
|
|
taskDetail.WorkServerNum = 1 |
|
|
|
} |
|
|
|
// taskDetail.CardNum, taskDetail.CardType, _ = repo.GetCloudbrainCardNumAndType(ciTasks[i].Cloudbrain) |
|
|
|
// if ciTasks[i].Cloudbrain.Spec != nil { |
|
|
|
// taskDetail.CardNum = ciTasks[i].Cloudbrain.Spec.AccCardsNum |
|
|
|
// taskDetail.CardType = ciTasks[i].Cloudbrain.Spec.AccCardType |
|
|
|
// taskDetail.AiCenter = ciTasks[i].Cloudbrain.Spec.AiCenterName |
|
|
|
// } |
|
|
|
// taskDetail.AiCenter = repo.GetCloudbrainAiCenter(ciTasks[i].Cloudbrain, ctx) |
|
|
|
// taskDetail.FlavorName, _ = repo.GetCloudbrainFlavorName(ciTasks[i].Cloudbrain) |
|
|
|
taskDetail.CardDuration = repo.GetCloudbrainCardDuration(ciTasks[i].Cloudbrain) |
|
|
|
taskDetail.WaitTime = repo.GetCloudbrainWaitTime(ciTasks[i].Cloudbrain) |
|
|
|
|
|
|
@@ -926,17 +865,6 @@ func GetCloudbrainsDetailData(ctx *context.Context) { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func getCloudbrainAiCenter(task models.Cloudbrain, ctx *context.Context) string { |
|
|
|
if task.Type == models.TypeCloudBrainOne { |
|
|
|
return ctx.Tr("repo.cloudbrain1") |
|
|
|
} else if task.Type == models.TypeCloudBrainTwo { |
|
|
|
return ctx.Tr("repo.cloudbrain2") |
|
|
|
} else if task.Type == models.TypeC2Net { |
|
|
|
return task.AiCenter |
|
|
|
} |
|
|
|
return "" |
|
|
|
} |
|
|
|
|
|
|
|
func GetCloudbrainsCreateHoursData(ctx *context.Context) { |
|
|
|
recordCloudbrain, err := models.GetRecordBeginTime() |
|
|
|
if err != nil { |
|
|
@@ -1350,6 +1278,7 @@ func DownloadCloudBrainBoard(ctx *context.Context) { |
|
|
|
log.Warn("Can not get cloud brain info", err) |
|
|
|
continue |
|
|
|
} |
|
|
|
models.LoadSpecs4CloudbrainInfo(pageRecords) |
|
|
|
for _, record := range pageRecords { |
|
|
|
|
|
|
|
for k, v := range allCloudbrainValues(row, record, ctx) { |
|
|
@@ -1380,10 +1309,9 @@ func allCloudbrainHeader(ctx *context.Context) map[string]string { |
|
|
|
"H1": ctx.Tr("cloudbrain.card_duration"), |
|
|
|
"I1": ctx.Tr("repo.modelarts.train_job.start_time"), "J1": ctx.Tr("repo.modelarts.train_job.end_time"), |
|
|
|
"K1": ctx.Tr("repo.modelarts.computing_resources"), "L1": ctx.Tr("cloudbrain.card_type"), |
|
|
|
"M1": ctx.Tr("repo.grampus.train_job.ai_center"), "N1": ctx.Tr("cloudbrain.resource_specification"), |
|
|
|
"O1": ctx.Tr("repo.cloudbrain_creator"), "P1": ctx.Tr("repo.repo_name"), "Q1": ctx.Tr("repo.cloudbrain_task_name"), |
|
|
|
"R1": ctx.Tr("repo.modelarts.deletetime")} |
|
|
|
|
|
|
|
"M1": ctx.Tr("repo.modelarts.train_job.amount_of_compute_node"), "N1": ctx.Tr("repo.grampus.train_job.ai_center"), |
|
|
|
"O1": ctx.Tr("cloudbrain.resource_specification"), "P1": ctx.Tr("repo.cloudbrain_creator"), "Q1": ctx.Tr("repo.repo_name"), |
|
|
|
"R1": ctx.Tr("repo.cloudbrain_task_name"), "S1": ctx.Tr("repo.modelarts.deletetime")} |
|
|
|
} |
|
|
|
func allCloudbrainValues(row int, rs *models.CloudbrainInfo, ctx *context.Context) map[string]string { |
|
|
|
return map[string]string{getCellName("A", row): rs.DisplayJobName, getCellName("B", row): getCloudbrainType(rs, ctx), getCellName("C", row): rs.Status, getCellName("D", row): rs.JobType, |
|
|
@@ -1391,9 +1319,16 @@ func allCloudbrainValues(row int, rs *models.CloudbrainInfo, ctx *context.Contex |
|
|
|
getCellName("G", row): rs.TrainJobDuration, getCellName("H", row): repo.GetCloudbrainCardDuration(rs.Cloudbrain), |
|
|
|
getCellName("I", row): getBrainStartTime(rs), |
|
|
|
getCellName("J", row): getBrainEndTime(rs), getCellName("K", row): rs.ComputeResource, getCellName("L", row): getCloudbrainCardType(rs), |
|
|
|
getCellName("M", row): repo.GetCloudbrainAiCenter(rs.Cloudbrain, ctx), getCellName("N", row): getCloudbrainFlavorName(rs), |
|
|
|
getCellName("O", row): rs.Name, getCellName("P", row): getBrainRepo(rs), |
|
|
|
getCellName("Q", row): rs.JobName, getCellName("R", row): getBrainDeleteTime(rs), |
|
|
|
getCellName("M", row): getWorkServerNum(rs), getCellName("N", row): repo.GetCloudbrainAiCenter(rs.Cloudbrain, ctx), |
|
|
|
getCellName("O", row): getCloudbrainFlavorName(rs), getCellName("P", row): rs.Name, |
|
|
|
getCellName("Q", row): getBrainRepo(rs), getCellName("R", row): rs.JobName, getCellName("S", row): getBrainDeleteTime(rs), |
|
|
|
} |
|
|
|
} |
|
|
|
func getWorkServerNum(rs *models.CloudbrainInfo) string { |
|
|
|
if rs.Cloudbrain.WorkServerNumber >= 1 { |
|
|
|
return fmt.Sprint(rs.Cloudbrain.WorkServerNumber) |
|
|
|
} else { |
|
|
|
return "1" |
|
|
|
} |
|
|
|
} |
|
|
|
func getBrainRepo(rs *models.CloudbrainInfo) string { |
|
|
@@ -1432,11 +1367,14 @@ func getCloudbrainType(rs *models.CloudbrainInfo, ctx *context.Context) string { |
|
|
|
} |
|
|
|
} |
|
|
|
func getCloudbrainCardType(rs *models.CloudbrainInfo) string { |
|
|
|
_, cardType, _ := repo.GetCloudbrainCardNumAndType(rs.Cloudbrain) |
|
|
|
return cardType |
|
|
|
if rs.Cloudbrain.Spec != nil { |
|
|
|
return rs.Cloudbrain.Spec.AccCardType |
|
|
|
} else { |
|
|
|
return "" |
|
|
|
} |
|
|
|
} |
|
|
|
func getCloudbrainFlavorName(rs *models.CloudbrainInfo) string { |
|
|
|
flavorName, _ := repo.GetCloudbrainFlavorName(rs.Cloudbrain) |
|
|
|
flavorName := repo.GetCloudbrainFlavorName(rs.Cloudbrain) |
|
|
|
return flavorName |
|
|
|
} |
|
|
|
|
|
|
|