Skip to content

Commit

Permalink
handle NaN value
Browse files Browse the repository at this point in the history
  • Loading branch information
DaoDaoNoCode committed Jul 7, 2023
1 parent c7b76a2 commit 6e64b15
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 9 additions & 2 deletions frontend/src/pages/modelServing/screens/metrics/ServerGraphs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import {
ModelServingMetricsContext,
ServerMetricType,
} from '~/pages/modelServing/screens/metrics/ModelServingMetricsContext';
import { per100, toPercentage } from '~/pages/modelServing/screens/metrics/utils';
import {
convertPrometheusNaNToZero,
per100,
toPercentage,
} from '~/pages/modelServing/screens/metrics/utils';
import { NamedMetricChartLine } from './types';

const ServerGraphs: React.FC = () => {
Expand All @@ -25,7 +29,10 @@ const ServerGraphs: React.FC = () => {
metrics={data[ServerMetricType.AVG_RESPONSE_TIME].data.map(
(line): NamedMetricChartLine => ({
name: line.metric.pod,
metric: { ...data[ServerMetricType.AVG_RESPONSE_TIME], data: line.values },
metric: {
...data[ServerMetricType.AVG_RESPONSE_TIME],
data: convertPrometheusNaNToZero(line.values),
},
}),
)}
color="green"
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/pages/modelServing/screens/metrics/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BreadcrumbItem, SelectOptionObject } from '@patternfly/react-core';
import { Link } from 'react-router-dom';
import { RefreshIntervalTitle, TimeframeTitle } from '~/pages/modelServing/screens/types';
import { InferenceServiceKind, ServingRuntimeKind } from '~/k8sTypes';
import { BreadcrumbItemType, DashboardConfig } from '~/types';
import { BreadcrumbItemType, DashboardConfig, PrometheusQueryRangeResultValue } from '~/types';
import { BaseMetricRequest, BaseMetricRequestInput, BiasMetricType } from '~/api';
import { BiasMetricConfig } from '~/concepts/explainability/types';
import {
Expand Down Expand Up @@ -331,3 +331,6 @@ export const convertConfigurationRequestType = (

export const getThresholdDefaultDelta = (metricType?: BiasMetricType) =>
metricType && BIAS_CHART_CONFIGS[metricType].defaultDelta;

export const convertPrometheusNaNToZero = (data: PrometheusQueryRangeResultValue[]) =>
data.map((value) => [value[0], isNaN(Number(value[1])) ? '0' : value[1]]);

0 comments on commit 6e64b15

Please sign in to comment.