Track top k nodes by norm score rather than top k nodes per scorer

This commit is contained in:
Preetha Appan
2018-08-17 18:44:00 -05:00
parent aa2b632a44
commit f6cbfbfef6
8 changed files with 116 additions and 85 deletions

View File

@@ -374,11 +374,24 @@ func formatAllocMetrics(metrics *api.AllocationMetric, scores bool, prefix strin
// Print scores
if scores {
if len(metrics.ScoreMetaData) > 0 {
for scorer, scoreMeta := range metrics.ScoreMetaData {
for _, nodeScore := range scoreMeta {
out += fmt.Sprintf("%s* Scorer %q, Node %q = %f\n", prefix, scorer, nodeScore.NodeID, nodeScore.Score)
scoreOutput := make([]string, len(metrics.ScoreMetaData)+1)
for i, scoreMeta := range metrics.ScoreMetaData {
// Add header as first row
if i == 0 {
scoreOutput[0] = "Node|"
for scorerName, _ := range scoreMeta.Scores {
scoreOutput[0] += fmt.Sprintf("%v|", scorerName)
}
scoreOutput[0] += "Final Score"
}
scoreOutput[i+1] = fmt.Sprintf("%v|", scoreMeta.NodeID)
for _, scoreVal := range scoreMeta.Scores {
scoreOutput[i+1] += fmt.Sprintf("%v|", scoreVal)
}
scoreOutput[i+1] += fmt.Sprintf("%v", scoreMeta.NormScore)
}
out += formatList(scoreOutput)
} else {
// Backwards compatibility for old allocs
for name, score := range metrics.Scores {