Skip to content

Commit

Permalink
Fixes: Bias metric chart selector shows a selected, non-existent char…
Browse files Browse the repository at this point in the history
…t when metrics are deleted by direct call to the TrustyAI API (#1533)
  • Loading branch information
alexcreasy committed Oct 30, 2023
1 parent a9794a1 commit 7c145d3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions frontend/src/pages/modelServing/screens/metrics/BiasTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import DashboardExpandableSection from '~/concepts/dashboard/DashboardExpandable
import useBiasChartsBrowserStorage from '~/pages/modelServing/screens/metrics/useBiasChartsBrowserStorage';
import { ModelMetricType } from '~/pages/modelServing/screens/metrics/ModelServingMetricsContext';
import EnsureMetricsAvailable from '~/pages/modelServing/screens/metrics/EnsureMetricsAvailable';
import { byId } from '~/pages/modelServing/screens/metrics/utils';

const OPEN_WRAPPER_STORAGE_KEY_PREFIX = `odh.dashboard.xai.bias_metric_chart_wrapper_open`;
const BiasTab: React.FC = () => {
Expand All @@ -36,6 +37,10 @@ const BiasTab: React.FC = () => {

React.useEffect(() => {
if (loaded && !loadError) {
// It's possible a biasMetricConfig was deleted by the user directly accessing a backend API. We need to verify
// that any saved state in the session storage is not stale and if it is, remove it.
setSelectedBiasConfigs(selectedBiasConfigs.filter((x) => biasMetricConfigs.find(byId(x))));

if (firstRender.current) {
// If the user has just navigated here AND they haven't previously selected any charts to display,
// don't show them the "No selected" empty state, instead show them the first available chart.
Expand Down

0 comments on commit 7c145d3

Please sign in to comment.