Skip to content

Commit

Permalink
Aggregate metrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Dec 6, 2024
1 parent d0767d9 commit 387ae8b
Showing 1 changed file with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function metricToSpecData(
yTitle: string,
transform?: (param: number) => number
) {
const wallclock = jobMetrics?.filter((jobMetric) => jobMetric.name == metricName);
const values = wallclock?.map((item) => {
const thisMetric = jobMetrics?.filter((jobMetric) => jobMetric.name == metricName);
const values = thisMetric?.map((item) => {
let y = parseFloat(item.raw_value);
if (transform !== undefined) {
y = transform(y);
Expand All @@ -84,6 +84,38 @@ function metricToSpecData(
};
}
function metricToAggregateData(
jobMetrics: components["schemas"]["WorkflowJobMetric"][] | undefined,
metricName: string,
yTitle: string,
transform?: (param: number) => number
) {
const thisMetric = jobMetrics?.filter((jobMetric) => jobMetric.name == metricName);
const aggregateByX: Record<string, number> = {};
thisMetric?.forEach((item) => {
let y = parseFloat(item.raw_value);
if (transform !== undefined) {
y = transform(y);
}
const x = itemToX(item);
if (!(x in aggregateByX)) {
aggregateByX[x] = 0;
}
aggregateByX[x] += y;
});
const values = aggregateByX.map((key, value) => {
return {
y: value,
x: key,
};
})
return {
x_title: attributeToLabel[groupBy.value],
y_title: yTitle,
values,
};
}
const wallclock: ComputedRef<boxplotData> = computed(() => {
return metricToSpecData(jobMetrics.value, "runtime_seconds", "Runtime (in Seconds)");
});
Expand Down

0 comments on commit 387ae8b

Please sign in to comment.