-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Enhancements to model bias screen * Display of multiple bias charts simultaneously * Multi-select component, allowing free text, or select-from-list selection of chartst to display * Ability to collapse / expand individual charts * User selectable refresh rates of chart data * Chart selection and open / closed status is persisted to session cache for life of user's browser session Display user defined threshold values on charts (#1163) * Clean up of bias chart logic * Displays thresholds chosen by user, or defaults if none. * Improves domain and threshold calculation based on user values or defaults
- Loading branch information
1 parent
4aa8675
commit 694ada2
Showing
21 changed files
with
547 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
frontend/src/concepts/dashboard/DashboardExpandableSection.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.dashboard-expandable-section-heading > .pf-c-expandable-section__toggle > * { | ||
font-family: var(--pf-global--FontFamily--sans-serif) !important; | ||
font-size: var(--pf-global--FontSize--2xl) !important; | ||
color: var(--pf-global--icon--Color--light) !important; | ||
} | ||
|
||
.dashboard-expandable-section-heading > .pf-c-expandable-section__toggle:hover > * { | ||
color: var(--pf-global--icon--Color--dark) !important; | ||
} |
32 changes: 32 additions & 0 deletions
32
frontend/src/concepts/dashboard/DashboardExpandableSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import { ExpandableSection } from '@patternfly/react-core'; | ||
import { useBrowserStorage } from '~/components/browserStorage'; | ||
|
||
import './DashboardExpandableSection.scss'; | ||
|
||
type DashboardExpandableSectionProps = { | ||
children: React.ReactNode; | ||
title: string; | ||
storageKey: string; | ||
}; | ||
|
||
const DashboardExpandableSection: React.FC<DashboardExpandableSectionProps> = ({ | ||
children, | ||
title, | ||
storageKey, | ||
}) => { | ||
const [isExpanded, setIsExpanded] = useBrowserStorage(storageKey, true, true, true); | ||
|
||
return ( | ||
<ExpandableSection | ||
className="dashboard-expandable-section-heading" | ||
toggleText={title} | ||
onToggle={setIsExpanded} | ||
isExpanded={isExpanded} | ||
> | ||
{children} | ||
</ExpandableSection> | ||
); | ||
}; | ||
|
||
export default DashboardExpandableSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
frontend/src/pages/modelServing/screens/metrics/BiasMetricConfigSelector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React from 'react'; | ||
import { Select, SelectGroup, SelectOption, SelectVariant } from '@patternfly/react-core'; | ||
import { useExplainabilityModelData } from '~/concepts/explainability/useExplainabilityModelData'; | ||
import { BiasMetricConfig } from '~/concepts/explainability/types'; | ||
import { MetricTypes } from '~/api'; | ||
import { | ||
byId, | ||
byNotId, | ||
createBiasSelectOption, | ||
isBiasSelectOption, | ||
} from '~/pages/modelServing/screens/metrics/utils'; | ||
import { BiasSelectOption } from '~/pages/modelServing/screens/metrics/types'; | ||
|
||
type BiasMetricConfigSelectorProps = { | ||
onChange: (x: BiasMetricConfig[]) => void; | ||
initialSelections: BiasMetricConfig[]; | ||
}; | ||
|
||
const BiasMetricConfigSelector: React.FC<BiasMetricConfigSelectorProps> = ({ | ||
onChange, | ||
initialSelections, | ||
}) => { | ||
const { biasMetricConfigs, loaded } = useExplainabilityModelData(); | ||
|
||
const [isOpen, setIsOpen] = React.useState(false); | ||
const [selected, setSelected] = React.useState<BiasSelectOption[]>( | ||
initialSelections.map(createBiasSelectOption), | ||
); | ||
|
||
const elementId = React.useId(); | ||
|
||
const changeState = React.useCallback( | ||
(options: BiasSelectOption[]) => { | ||
setSelected(options); | ||
onChange(options.map((x) => x.biasMetricConfig)); | ||
}, | ||
[onChange], | ||
); | ||
|
||
return ( | ||
<div style={{ maxWidth: '600px' }}> | ||
<span id={elementId} hidden> | ||
Select the metrics to display charts for | ||
</span> | ||
<Select | ||
variant={SelectVariant.typeaheadMulti} | ||
typeAheadAriaLabel="Select a metric" | ||
onToggle={setIsOpen} | ||
onSelect={(event, item) => { | ||
if (isBiasSelectOption(item)) { | ||
if (selected.find(byId(item))) { | ||
// User has de-selected an item. | ||
changeState(selected.filter(byNotId(item))); | ||
} else { | ||
// User has selected an item. | ||
changeState([...selected, item]); | ||
} | ||
} | ||
}} | ||
onClear={() => { | ||
changeState([]); | ||
setIsOpen(false); | ||
}} | ||
selections={selected} | ||
isOpen={isOpen} | ||
aria-labelledby={elementId} | ||
placeholderText="Select a metric" | ||
isDisabled={!(loaded && biasMetricConfigs.length > 0)} | ||
isGrouped | ||
> | ||
<SelectGroup label="SPD" key="SPD"> | ||
{biasMetricConfigs | ||
.filter((x) => x.metricType === MetricTypes.SPD) | ||
.map((x) => ( | ||
<SelectOption key={x.id} value={createBiasSelectOption(x)} /> | ||
))} | ||
</SelectGroup> | ||
<SelectGroup label="DIR" key="DIR"> | ||
{biasMetricConfigs | ||
.filter((x) => x.metricType === MetricTypes.DIR) | ||
.map((x) => ( | ||
<SelectOption key={x.id} value={createBiasSelectOption(x)} /> | ||
))} | ||
</SelectGroup> | ||
</Select> | ||
</div> | ||
); | ||
}; | ||
|
||
export default BiasMetricConfigSelector; |
Oops, something went wrong.