1
1
import { Box , Tooltip } from '@material-ui/core' ;
2
2
import { WarningAmberOutlined } from '@mui/icons-material' ;
3
+ import { LoadingDots } from '@wandb/weave/components/LoadingDots' ;
3
4
import _ from 'lodash' ;
4
5
import React , { useCallback , useEffect , useMemo , useRef } from 'react' ;
5
6
import styled from 'styled-components' ;
@@ -50,6 +51,7 @@ import {
50
51
} from '../ScorecardSection/ScorecardSection' ;
51
52
import {
52
53
PivotedRow ,
54
+ useExampleCompareData ,
53
55
useFilteredAggregateRows ,
54
56
} from './exampleCompareSectionUtil' ;
55
57
@@ -225,6 +227,16 @@ export const ExampleCompareSection: React.FC<{
225
227
return filteredRows [ targetIndex ] ;
226
228
} , [ filteredRows , targetIndex ] ) ;
227
229
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
+
228
240
const [ selectedTrials , setSelectedTrials ] = React . useState < {
229
241
[ evalCallId : string ] : number ;
230
242
} > ( { } ) ;
@@ -251,9 +263,8 @@ export const ExampleCompareSection: React.FC<{
251
263
) ;
252
264
253
265
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 ;
257
268
258
269
const numTrials = orderedCallIds . map ( leafId => {
259
270
return target . originalRows . filter ( row => row . evaluationCallId === leafId )
@@ -448,7 +459,7 @@ export const ExampleCompareSection: React.FC<{
448
459
449
460
const inputPropValComp = ( inputPropIndex : number ) => {
450
461
return (
451
- < ICValueView value = { target . input [ inputColumnKeys [ inputPropIndex ] ] } />
462
+ < ICValueView value = { targetRowValue ?. [ inputColumnKeys [ inputPropIndex ] ] } />
452
463
) ;
453
464
} ;
454
465
@@ -759,16 +770,29 @@ export const ExampleCompareSection: React.FC<{
759
770
</ React . Fragment >
760
771
) }
761
772
{ /* 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
+ ) }
772
796
</ GridCellSubgrid >
773
797
{ /* OUTPUT SECTION */ }
774
798
< GridCellSubgrid
0 commit comments