Skip to content

Commit d29f6de

Browse files
committed
perf(weve): address data loading perf issue and eval compare
1 parent 57fdbc8 commit d29f6de

File tree

3 files changed

+255
-95
lines changed

3 files changed

+255
-95
lines changed

weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CompareEvaluationsPage/sections/ExampleCompareSection/ExampleCompareSection.tsx

+38-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Box, Tooltip} from '@material-ui/core';
22
import {WarningAmberOutlined} from '@mui/icons-material';
3+
import {LoadingDots} from '@wandb/weave/components/LoadingDots';
34
import _ from 'lodash';
45
import React, {useCallback, useEffect, useMemo, useRef} from 'react';
56
import styled from 'styled-components';
@@ -50,6 +51,7 @@ import {
5051
} from '../ScorecardSection/ScorecardSection';
5152
import {
5253
PivotedRow,
54+
useExampleCompareData,
5355
useFilteredAggregateRows,
5456
} from './exampleCompareSectionUtil';
5557

@@ -225,6 +227,16 @@ export const ExampleCompareSection: React.FC<{
225227
return filteredRows[targetIndex];
226228
}, [filteredRows, targetIndex]);
227229

230+
const {targetRowValue, loading: loadingInputValue} = useExampleCompareData(
231+
props.state,
232+
filteredRows,
233+
targetIndex
234+
);
235+
236+
const inputColumnKeys = useMemo(() => {
237+
return Object.keys(targetRowValue ?? {});
238+
}, [targetRowValue]);
239+
228240
const [selectedTrials, setSelectedTrials] = React.useState<{
229241
[evalCallId: string]: number;
230242
}>({});
@@ -251,9 +263,8 @@ export const ExampleCompareSection: React.FC<{
251263
);
252264

253265
const inputRef = parseRef(target.inputRef) as WeaveObjectRef;
254-
const inputColumnKeys = Object.keys(target.input);
255-
const numInputProps = inputColumnKeys.length;
256-
const numOutputKeys = outputColumnKeys.length;
266+
const numInputProps = inputColumnKeys?.length ?? 0;
267+
const numOutputKeys = outputColumnKeys?.length ?? 0;
257268

258269
const numTrials = orderedCallIds.map(leafId => {
259270
return target.originalRows.filter(row => row.evaluationCallId === leafId)
@@ -448,7 +459,7 @@ export const ExampleCompareSection: React.FC<{
448459

449460
const inputPropValComp = (inputPropIndex: number) => {
450461
return (
451-
<ICValueView value={target.input[inputColumnKeys[inputPropIndex]]} />
462+
<ICValueView value={targetRowValue?.[inputColumnKeys[inputPropIndex]]} />
452463
);
453464
};
454465

@@ -759,16 +770,29 @@ export const ExampleCompareSection: React.FC<{
759770
</React.Fragment>
760771
)}
761772
{/* INPUT ROWS */}
762-
{_.range(numInputProps).map(inputPropIndex => {
763-
return (
764-
<React.Fragment key={inputPropMapKey(inputPropIndex)}>
765-
<GridCell style={{...stickySidebarStyleMixin}}>
766-
{inputPropKeyComp(inputPropIndex)}
767-
</GridCell>
768-
<GridCell>{inputPropValComp(inputPropIndex)}</GridCell>
769-
</React.Fragment>
770-
);
771-
})}
773+
{loadingInputValue || targetRowValue === undefined ? (
774+
<React.Fragment key={'loading'}>
775+
<GridCell style={{...stickySidebarStyleMixin}}>
776+
<LoadingDots />
777+
</GridCell>
778+
<GridCell>
779+
<LoadingDots />
780+
</GridCell>
781+
</React.Fragment>
782+
) : (
783+
<>
784+
{_.range(numInputProps).map(inputPropIndex => {
785+
return (
786+
<React.Fragment key={inputPropMapKey(inputPropIndex)}>
787+
<GridCell style={{...stickySidebarStyleMixin}}>
788+
{inputPropKeyComp(inputPropIndex)}
789+
</GridCell>
790+
<GridCell>{inputPropValComp(inputPropIndex)}</GridCell>
791+
</React.Fragment>
792+
);
793+
})}
794+
</>
795+
)}
772796
</GridCellSubgrid>
773797
{/* OUTPUT SECTION */}
774798
<GridCellSubgrid

0 commit comments

Comments
 (0)