Skip to content

Commit d8ca010

Browse files
authored
parse new MLC release output (#404)
Signed-off-by: Harper, Jason M <[email protected]>
1 parent 4ac2768 commit d8ca010

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

internal/report/table_defs.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,13 @@ func GetValuesForTable(name string, outputs map[string]script.ScriptOutput) Tabl
824824
Fields: fields,
825825
}
826826
// sanity check
827-
validateTableValues(tableValues)
827+
if err := validateTableValues(tableValues); err != nil {
828+
slog.Error("table validation failed", "table", name, "error", err)
829+
return TableValues{
830+
TableDefinition: tableDefinitions[name],
831+
Fields: []Field{},
832+
}
833+
}
828834
// call the table's InsightsFunc to get insights about the data in the table
829835
if table.InsightsFunc != nil {
830836
tableValues.Insights = table.InsightsFunc(outputs, tableValues)
@@ -844,27 +850,28 @@ func getFieldIndex(fieldName string, tableValues TableValues) (int, error) {
844850
return -1, fmt.Errorf("field [%s] not found in table [%s]", fieldName, tableValues.Name)
845851
}
846852

847-
func validateTableValues(tableValues TableValues) {
853+
func validateTableValues(tableValues TableValues) error {
848854
if tableValues.Name == "" {
849-
panic("table name cannot be empty")
855+
return fmt.Errorf("table name cannot be empty")
850856
}
851857
// no field values is a valid state
852858
if len(tableValues.Fields) == 0 {
853-
return
859+
return nil
854860
}
855861
// field names cannot be empty
856862
for i, field := range tableValues.Fields {
857863
if field.Name == "" {
858-
panic(fmt.Sprintf("table %s, field %d, name cannot be empty", tableValues.Name, i))
864+
return fmt.Errorf("table %s, field %d, name cannot be empty", tableValues.Name, i)
859865
}
860866
}
861867
// the number of entries in each field must be the same
862868
numEntries := len(tableValues.Fields[0].Values)
863869
for i, field := range tableValues.Fields {
864870
if len(field.Values) != numEntries {
865-
panic(fmt.Sprintf("table %s, field %d, %s, number of entries must be the same for all fields, expected %d, got %d", tableValues.Name, i, field.Name, numEntries, len(field.Values)))
871+
return fmt.Errorf("table %s, field %d, %s, number of entries must be the same for all fields, expected %d, got %d", tableValues.Name, i, field.Name, numEntries, len(field.Values))
866872
}
867873
}
874+
return nil
868875
}
869876

870877
//
@@ -2151,8 +2158,8 @@ func numaBenchmarkTableValues(outputs map[string]script.ScriptOutput) []Field {
21512158
/* MLC Output:
21522159
Numa node
21532160
Numa node 0 1
2154-
0 175610.3 55579.7
2155-
1 55575.2 175656.7
2161+
0 175610.3 55579.7
2162+
1 55575.2 175656.7
21562163
*/
21572164
nodeBandwidthsPairs := valsArrayFromRegexSubmatch(outputs[script.NumaBenchmarkScriptName].Stdout, `^\s+(\d)\s+(\d.*)$`)
21582165
// add 1 field per numa node
@@ -2168,6 +2175,7 @@ func numaBenchmarkTableValues(outputs map[string]script.ScriptOutput) []Field {
21682175
return []Field{}
21692176
}
21702177
for i, bw := range bandwidths {
2178+
bw = strings.TrimSpace(bw)
21712179
val, err := strconv.ParseFloat(bw, 64)
21722180
if err != nil {
21732181
slog.Error(fmt.Sprintf("Unable to convert bandwidth to float: %s", bw))

0 commit comments

Comments
 (0)