Skip to content

Commit e23e9d5

Browse files
authored
Fix duplicate status in trace explorer header, and remove filtering out session level assessments (#20131)
Signed-off-by: Daniel Lok <daniel.lok@databricks.com>
1 parent f2750fe commit e23e9d5

File tree

8 files changed

+84
-17
lines changed

8 files changed

+84
-17
lines changed

mlflow/server/js/src/lang/default/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,10 @@
738738
"defaultMessage": "Chart view",
739739
"description": "Label for the table view toggle button in the logged model list page"
740740
},
741+
"451ETc": {
742+
"defaultMessage": "Session",
743+
"description": "Label for the session to which an assessment belongs"
744+
},
741745
"46xd2Z": {
742746
"defaultMessage": "Compare",
743747
"description": "Runs charts > components > config > RunsChartsConfigureDifferenceChart > Compare config section"

mlflow/server/js/src/shared/web-shared/model-trace-explorer/ModelTraceExplorer.utils.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,7 @@ export const isSessionLevelAssessment = (assessment: Assessment): boolean => {
13541354
*/
13551355
export const getTraceLevelAssessments = (assessments?: Assessment[]) =>
13561356
assessments?.filter((assessment) => !isSessionLevelAssessment(assessment)) ?? [];
1357+
13571358
export const isValidException = (
13581359
event: ModelTraceEvent,
13591360
): event is ModelTraceEvent & {

mlflow/server/js/src/shared/web-shared/model-trace-explorer/ModelTraceExplorerMetricSection.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const ModelTraceHeaderMetricSection = ({
99
color,
1010
getTruncatedLabel,
1111
onCopy,
12+
hideLabel = false,
1213
}: {
1314
label: React.ReactNode;
1415
/**
@@ -23,6 +24,7 @@ export const ModelTraceHeaderMetricSection = ({
2324
color?: TagColors;
2425
getTruncatedLabel: (label: string) => string;
2526
onCopy: () => void;
27+
hideLabel?: boolean;
2628
}) => {
2729
const { theme } = useDesignSystemTheme();
2830

@@ -36,14 +38,16 @@ export const ModelTraceHeaderMetricSection = ({
3638
css={{
3739
display: 'flex',
3840
alignItems: 'center',
39-
justifyContent: 'center',
41+
justifyContent: hideLabel ? 'flex-start' : 'center',
4042
flexDirection: 'row',
4143
gap: theme.spacing.sm,
4244
}}
4345
>
44-
<Typography.Text size="md" color="secondary">
45-
{label}
46-
</Typography.Text>
46+
{!hideLabel && (
47+
<Typography.Text size="md" color="secondary">
48+
{label}
49+
</Typography.Text>
50+
)}
4751
<Tooltip componentId="shared.model-trace-explorer.header-details.tooltip" content={value} maxWidth={400}>
4852
<Tag
4953
componentId="shared.model-trace-explorer.header-details.tag"

mlflow/server/js/src/shared/web-shared/model-trace-explorer/ModelTraceHeaderDetails.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ export const ModelTraceHeaderDetails = ({ modelTraceInfo }: { modelTraceInfo: Mo
120120
onCopy={handleCopy}
121121
/>
122122
)}
123-
{statusState && <ModelTraceHeaderStatusTag statusState={statusState} getTruncatedLabel={getTruncatedLabel} />}
124123
{sessionId && experimentId && (
125124
<ModelTraceHeaderSessionIdTag
126125
handleCopy={handleCopy}

mlflow/server/js/src/shared/web-shared/model-trace-explorer/ModelTraceHeaderSessionIdTag.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ export const ModelTraceHeaderSessionIdTag = ({
1515
sessionId,
1616
traceId,
1717
handleCopy,
18+
hideLabel = false,
1819
}: {
1920
experimentId: string;
2021
sessionId: string;
2122
traceId?: string;
2223
handleCopy: () => void;
24+
hideLabel?: boolean;
2325
}) => {
2426
const { theme } = useDesignSystemTheme();
2527
const location = useLocation();
@@ -47,6 +49,7 @@ export const ModelTraceHeaderSessionIdTag = ({
4749
color="default"
4850
getTruncatedLabel={getTruncatedLabel}
4951
onCopy={handleCopy}
52+
hideLabel={hideLabel}
5053
/>
5154
);
5255
}
@@ -56,14 +59,16 @@ export const ModelTraceHeaderSessionIdTag = ({
5659
css={{
5760
display: 'flex',
5861
alignItems: 'center',
59-
justifyContent: 'center',
62+
justifyContent: hideLabel ? 'flex-start' : 'center',
6063
flexDirection: 'row',
6164
gap: theme.spacing.sm,
6265
}}
6366
>
64-
<Typography.Text size="md" color="secondary">
65-
<FormattedMessage defaultMessage="Session ID" description="Label for the session id section" />
66-
</Typography.Text>
67+
{!hideLabel && (
68+
<Typography.Text size="md" color="secondary">
69+
<FormattedMessage defaultMessage="Session ID" description="Label for the session id section" />
70+
</Typography.Text>
71+
)}
6772
<Tooltip
6873
componentId="mlflow.model-trace-explorer.session-id-tag"
6974
content={<FormattedMessage defaultMessage="View chat session" description="Tooltip for the session id tag" />}

mlflow/server/js/src/shared/web-shared/model-trace-explorer/assessments-pane/ExpectationItem.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,26 @@ import { SpanNameDetailViewLink } from './SpanNameDetailViewLink';
1313
import { getSourceIcon } from './utils';
1414
import type { ExpectationAssessment } from '../ModelTrace.types';
1515
import { useModelTraceExplorerViewState } from '../ModelTraceExplorerViewStateContext';
16+
import { ASSESSMENT_SESSION_METADATA_KEY } from '../constants';
17+
import { isEmpty } from 'lodash';
18+
import { ModelTraceHeaderSessionIdTag } from '../ModelTraceHeaderSessionIdTag';
19+
import { useParams } from '../RoutingUtils';
1620

1721
export const ExpectationItem = ({ expectation }: { expectation: ExpectationAssessment }) => {
1822
const { theme } = useDesignSystemTheme();
1923
const [isEditing, setIsEditing] = useState(false);
2024
const [showDeleteModal, setShowDeleteModal] = useState(false);
2125
const [isExpanded, setIsExpanded] = useState(false);
2226
const { nodeMap, activeView } = useModelTraceExplorerViewState();
27+
const { experimentId } = useParams();
2328

2429
const associatedSpan = expectation.span_id ? nodeMap[expectation.span_id] : null;
30+
// indicate if the assessment is session-level
31+
const sessionId = expectation.metadata?.[ASSESSMENT_SESSION_METADATA_KEY];
32+
const showSessionTag = activeView === 'summary' && !isEmpty(sessionId);
2533
// the summary view displays all assessments regardless of span, so
2634
// we need some way to indicate which span an assessment is associated with.
27-
const showAssociatedSpan = activeView === 'summary' && associatedSpan;
35+
const showAssociatedSpan = activeView === 'summary' && associatedSpan && !showSessionTag;
2836

2937
const parsedValue = getParsedExpectationValue(expectation.expectation);
3038
const SourceIcon = getSourceIcon(expectation.source);
@@ -112,6 +120,23 @@ export const ExpectationItem = ({ expectation }: { expectation: ExpectationAsses
112120
<SpanNameDetailViewLink node={associatedSpan} />
113121
</div>
114122
)}
123+
{showSessionTag && (
124+
<div css={{ display: 'flex', flexDirection: 'column', gap: theme.spacing.xs }}>
125+
<Typography.Text size="sm" color="secondary">
126+
<FormattedMessage
127+
defaultMessage="Session"
128+
description="Label for the session to which an assessment belongs"
129+
/>
130+
</Typography.Text>
131+
<ModelTraceHeaderSessionIdTag
132+
experimentId={experimentId ?? ''}
133+
sessionId={sessionId ?? ''}
134+
traceId={expectation.trace_id}
135+
handleCopy={() => {}}
136+
hideLabel
137+
/>
138+
</div>
139+
)}
115140
</div>
116141
);
117142
};

mlflow/server/js/src/shared/web-shared/model-trace-explorer/assessments-pane/FeedbackItemContent.tsx

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isNil } from 'lodash';
1+
import { isEmpty, isNil } from 'lodash';
22
import { useState } from 'react';
33

44
import { Typography, useDesignSystemTheme, NewWindowIcon } from '@databricks/design-system';
@@ -12,8 +12,14 @@ import { SpanNameDetailViewLink } from './SpanNameDetailViewLink';
1212
import type { FeedbackAssessment } from '../ModelTrace.types';
1313
import { useModelTraceExplorerViewState } from '../ModelTraceExplorerViewStateContext';
1414
import { Link, useParams } from '../RoutingUtils';
15-
import { MLFLOW_ASSESSMENT_JUDGE_COST, MLFLOW_ASSESSMENT_SCORER_TRACE_ID } from '../constants';
15+
import {
16+
ASSESSMENT_SESSION_METADATA_KEY,
17+
MLFLOW_ASSESSMENT_JUDGE_COST,
18+
MLFLOW_ASSESSMENT_SCORER_TRACE_ID,
19+
} from '../constants';
1620
import { getExperimentPageTracesTabRoute } from '../routes';
21+
import { isSessionLevelAssessment } from '../ModelTraceExplorer.utils';
22+
import { ModelTraceHeaderSessionIdTag } from '../ModelTraceHeaderSessionIdTag';
1723

1824
export const FeedbackItemContent = ({ feedback }: { feedback: FeedbackAssessment }) => {
1925
const [isHistoryModalVisible, setIsHistoryModalVisible] = useState(false);
@@ -24,9 +30,12 @@ export const FeedbackItemContent = ({ feedback }: { feedback: FeedbackAssessment
2430
const value = feedback.feedback.value;
2531

2632
const associatedSpan = feedback.span_id ? nodeMap[feedback.span_id] : null;
33+
// indicate if the assessment is session-level
34+
const sessionId = feedback.metadata?.[ASSESSMENT_SESSION_METADATA_KEY];
35+
const showSessionTag = activeView === 'summary' && !isEmpty(sessionId);
2736
// the summary view displays all assessments regardless of span, so
2837
// we need some way to indicate which span an assessment is associated with.
29-
const showAssociatedSpan = activeView === 'summary' && associatedSpan;
38+
const showAssociatedSpan = activeView === 'summary' && associatedSpan && !showSessionTag;
3039

3140
const judgeTraceId = feedback.metadata?.[MLFLOW_ASSESSMENT_SCORER_TRACE_ID];
3241
const judgeTraceHref = judgeTraceId && experimentId ? getJudgeTraceHref(experimentId, judgeTraceId) : undefined;
@@ -68,6 +77,29 @@ export const FeedbackItemContent = ({ feedback }: { feedback: FeedbackAssessment
6877
<SpanNameDetailViewLink node={associatedSpan} />
6978
</div>
7079
)}
80+
{showSessionTag && (
81+
<div
82+
css={{
83+
display: 'flex',
84+
flexDirection: 'column',
85+
gap: theme.spacing.xs,
86+
}}
87+
>
88+
<Typography.Text size="sm" color="secondary">
89+
<FormattedMessage
90+
defaultMessage="Session"
91+
description="Label for the session to which an assessment belongs"
92+
/>
93+
</Typography.Text>
94+
<ModelTraceHeaderSessionIdTag
95+
experimentId={experimentId ?? ''}
96+
sessionId={sessionId ?? ''}
97+
traceId={feedback.trace_id}
98+
handleCopy={() => {}}
99+
hideLabel
100+
/>
101+
</div>
102+
)}
71103
{isNil(feedback.feedback.error) && (
72104
<div css={{ display: 'flex', flexDirection: 'column', gap: theme.spacing.xs }}>
73105
<Typography.Text size="sm" color="secondary">

mlflow/server/js/src/shared/web-shared/model-trace-explorer/summary-view/ModelTraceExplorerSummaryView.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ export const ModelTraceExplorerSummaryView = () => {
3333
[updatePaneSizeRatios],
3434
);
3535

36-
// Get only the trace-level assessments (exclude session-level assessments)
37-
const displayedAssessments = useMemo(() => getTraceLevelAssessments(allAssessments), [allAssessments]);
38-
3936
const intermediateNodes = useIntermediateNodes(rootNode);
4037

4138
if (!rootNode) {
@@ -53,7 +50,7 @@ export const ModelTraceExplorerSummaryView = () => {
5350
);
5451
}
5552
const AssessmentsPaneComponent = (
56-
<AssessmentsPane assessments={displayedAssessments} traceId={rootNode.traceId} activeSpanId={undefined} />
53+
<AssessmentsPane assessments={allAssessments} traceId={rootNode.traceId} activeSpanId={undefined} />
5754
);
5855

5956
return !isInComparisonView && assessmentsPaneEnabled && assessmentsPaneExpanded ? (

0 commit comments

Comments
 (0)