Skip to content

Commit

Permalink
better handle initial state and derived metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
gtarpenning committed Oct 10, 2024
1 parent 5aa0d02 commit 9632778
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ const CompareEvaluationsBinding = () => {
const evaluationCallIds = useMemo(() => {
return JSON.parse(query.evaluationCallIds);
}, [query.evaluationCallIds]);

const onEvaluationCallIdsUpdate = useCallback(
(newEvaluationCallIds: string[]) => {
const newQuery = new URLSearchParams(location.search);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,13 @@ export const ExampleCompareSection: React.FC<{
.length;
});
const numEvals = numTrials.length;
// Get derived scores, then filter out any not in the selected metrics
const derivedScores = Object.values(
getMetricIds(props.state.data, 'score', 'derived')
).filter(
score => props.state.selectedMetrics?.[flattenedDimensionPath(score)]
);

const numMetricScorers = metricGroupNames.length;
const numDerivedScores = derivedScores.length;
const numMetricsPerScorer = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {TextField} from '@wandb/weave/components/Form/TextField';
import {Tailwind} from '@wandb/weave/components/Tailwind';
import {maybePluralize} from '@wandb/weave/core/util/string';
import classNames from 'classnames';
import React, {useMemo, useRef, useState} from 'react';
import React, {useEffect, useMemo, useRef, useState} from 'react';

import {buildCompositeMetricsMap} from '../../compositeMetricsUtil';
import {
Expand Down Expand Up @@ -43,6 +43,15 @@ export const SummaryPlots: React.FC<{
const {selectedMetrics} = props.state;
const setSelectedMetrics = props.setSelectedMetrics;

useEffect(() => {
// If selectedMetrics is null, we should show all metrics
if (selectedMetrics == null) {
setSelectedMetrics(
Object.fromEntries(Array.from(allMetricNames).map(m => [m, true]))
);
}
}, [selectedMetrics, setSelectedMetrics, allMetricNames]);

// filter down the plotlyRadarData to only include the selected metrics, after
// computation, to allow quick addition/removal of metrics
const filteredPlotlyRadarData = useMemo(() => {
Expand Down

0 comments on commit 9632778

Please sign in to comment.