Skip to content

Commit

Permalink
Fix stack chart issue when there is no data for one area (opendatahub…
Browse files Browse the repository at this point in the history
  • Loading branch information
DaoDaoNoCode authored Sep 20, 2024
1 parent 089ff71 commit 83730aa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,21 @@ const initIntercepts = ({
ServingRuntimeModel,
mockServingRuntimeK8sResource({ name: 'test-model', namespace: 'test-project' }),
);
cy.interceptOdh(
'POST /api/prometheus/serving',
mockPrometheusServing({ result: hasServingData ? undefined : [] }), // will mock for both ok and not ok
);
cy.interceptOdh('POST /api/prometheus/serving', (req) => {
// failed http request count has no data
// all the other serving endpoints get data
const { query } = req.body;
if (
!(
query.includes(`modelmesh_api_request_milliseconds_count`) &&
query.includes(`code%21%3D%27OK`)
)
) {
req.reply(mockPrometheusServing({ result: hasServingData ? undefined : [] }));
} else {
req.reply(mockPrometheusServing({ result: [] }));
}
});
cy.interceptOdh('POST /api/prometheus/bias', (req) => {
if ((req.body as { query: string }).query.includes(`query=trustyai_dir`)) {
req.reply(mockPrometheusBias({ result: hasBiasData ? undefined : [], metric: 'DIR' }));
Expand Down Expand Up @@ -253,7 +264,7 @@ describe('Model Metrics', () => {
.shouldHaveData();
});

it('Server metrics show no data available ', () => {
it('Server metrics show no data available', () => {
initIntercepts({
disableBiasMetrics: false,
disablePerformanceMetrics: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,13 @@ const MetricsChart: React.FC<MetricsChartProps> = ({
{graphLines.map((line, i) => {
switch (type) {
case MetricsChartTypes.AREA:
return <ChartArea key={i} data={line.points} name={line.name} />;
return (
<ChartArea
key={i}
data={line.points.length === 0 ? [null] : line.points}
name={line.name}
/>
);
case MetricsChartTypes.LINE:
return <ChartLine key={i} data={line.points} name={line.name} />;
default:
Expand Down

0 comments on commit 83730aa

Please sign in to comment.