Skip to content

Commit 3b459e5

Browse files
authored
Fix analysis systems with same names (#478)
* avoid analysis on systems with the same names * remove console log * refactor code * show systemID for systems with duplicate names * change warning message
1 parent df86f38 commit 3b459e5

File tree

4 files changed

+54
-37
lines changed

4 files changed

+54
-37
lines changed

frontend/src/components/Analysis/AnalysisDrawer/index.tsx

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useCallback, useEffect, useState } from "react";
2-
import { Drawer, Spin } from "antd";
2+
import { Drawer, Spin, Tooltip } from "antd";
33
import { SystemModel } from "../../../models";
44
import { ErrorBoundary, AnalysisReport } from "../../../components";
55
import { PageState } from "../../../utils";
@@ -8,6 +8,7 @@ import {
88
SystemAnalysesReturn,
99
SystemsAnalysesBody,
1010
} from "../../../clients/openapi";
11+
import { WarningOutlined } from "@ant-design/icons";
1112
import { parseFineGrainedResults, valuesToIntervals } from "../utils";
1213
import { ResultFineGrainedParsed, BucketIntervals } from "../types";
1314
import ReactGA from "react-ga4";
@@ -194,14 +195,38 @@ export function AnalysisDrawer({ systems, closeDrawer }: Props) {
194195
setBucketInfoUpdated(false);
195196
}
196197

197-
function getDrawerTitle(): string {
198+
function getDrawerTitle(): React.ReactNode {
199+
const systemNames = systems.map((sys) => sys.system_name);
200+
const distinctSystemNames = new Set(systemNames);
201+
const duplicateNameWarning =
202+
distinctSystemNames.size !== systemNames.length;
203+
const duplicateNameWarningMsg =
204+
"The systems have duplicate names. Unique system IDs are attached to distinguish between them. Please change system names using the edit button on `Systems` page.";
198205
if (systems.length === 1) {
199206
return `Single Analysis of ${systems[0].system_name}`;
200207
} else if (systems.length === 2) {
201208
const systemNames = systems.map((sys) => sys.system_name).join(" and ");
202-
return `Pairwise Analysis of ${systemNames}`;
209+
return (
210+
<div>
211+
Pairwise Analysis of {systemNames}{" "}
212+
{duplicateNameWarning && (
213+
<Tooltip title={duplicateNameWarningMsg}>
214+
<WarningOutlined />
215+
</Tooltip>
216+
)}
217+
</div>
218+
);
203219
}
204-
return "Analysis";
220+
return (
221+
<div>
222+
Analysis{" "}
223+
{duplicateNameWarning && (
224+
<Tooltip title={duplicateNameWarningMsg}>
225+
<WarningOutlined />
226+
</Tooltip>
227+
)}
228+
</div>
229+
);
205230
}
206231

207232
function renderDrawerContent(): React.ReactElement {

frontend/src/components/Analysis/AnalysisReport/FineGrainedAnalysis/FineGrainedBarChart.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ export function FineGrainedBarChart(props: Props) {
3030
onBarClick,
3131
} = props;
3232
// For invariant variables across all systems, we can simply take from the first result
33-
const systemNames = systems.map((system) => system.system_name);
33+
function getSystemNames(systems: SystemModel[]) {
34+
const systemNames = systems.map((sys) => sys.system_name);
35+
const distinctSystemNames = new Set(systemNames);
36+
if (distinctSystemNames.size !== systemNames.length) {
37+
return systems.map((sys) => sys.system_name + "_" + sys.system_id);
38+
} else {
39+
return systemNames;
40+
}
41+
}
42+
const systemNames = getSystemNames(systems);
3443
const resultFirst = results[0];
3544
const bucketNames = resultFirst.bucketNames;
3645
const featureName = resultFirst.featureName;

frontend/src/components/Analysis/AnalysisReport/OverallMetricsBarChart.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@ export function OverallMetricsBarChart({
1919
metricNames,
2020
onBarClick,
2121
}: Props) {
22-
const systemNames = systems.map((system) => system.system_name);
22+
function getSystemNames(systems: SystemModel[]) {
23+
const systemNames = systems.map((sys) => sys.system_name);
24+
const distinctSystemNames = new Set(systemNames);
25+
if (distinctSystemNames.size !== systemNames.length) {
26+
return systems.map((sys) => sys.system_name + "_" + sys.system_id);
27+
} else {
28+
return systemNames;
29+
}
30+
}
31+
const systemNames = getSystemNames(systems);
2332
const resultsValues: number[][] = [];
2433
const resultsNumbersOfSamples: number[][] = [];
2534
const resultsConfidenceScores: Array<[number, number]>[] = [];

frontend/src/components/SystemsTable/SystemTableTools.tsx

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ export function SystemTableTools({
125125
Analysis
126126
</Button>
127127
);
128-
// Pairwise analysis
129-
} else if (selectedSystemIDs.length === 2) {
128+
// Pairwise or multiple system analysis
129+
} else {
130130
let disabled = false;
131131
let warning = false;
132132
let tooltipMessage = "";
@@ -144,35 +144,9 @@ export function SystemTableTools({
144144
disabled={disabled}
145145
onClick={() => onActiveSystemChange(selectedSystemIDs)}
146146
>
147-
Pairwise Analysis
148-
{warning && <WarningOutlined />}
149-
</Button>
150-
);
151-
if (tooltipMessage !== "") {
152-
analysisButton = (
153-
<Tooltip title={tooltipMessage}>{analysisButton}</Tooltip>
154-
);
155-
}
156-
// three or more systems
157-
} else if (selectedSystemIDs.length >= 3) {
158-
let disabled = false;
159-
let warning = false;
160-
let tooltipMessage = "";
161-
if (selectedSystemDatasetNames.has("unspecified")) {
162-
warning = true;
163-
tooltipMessage =
164-
"Unspecified dataset name detected. Proceed if you are certain the systems use the same dataset.";
165-
} else if (selectedSystemDatasetNames.size > 1) {
166-
disabled = true;
167-
tooltipMessage =
168-
"Cannot perform multiple analysis on systems with different dataset names.";
169-
}
170-
analysisButton = (
171-
<Button
172-
disabled={disabled}
173-
onClick={() => onActiveSystemChange(selectedSystemIDs)}
174-
>
175-
Multiple System Analysis
147+
{selectedSystemIDs.length === 2
148+
? "Pairwise Analysis"
149+
: "Multiple System Analysis"}
176150
{warning && <WarningOutlined />}
177151
</Button>
178152
);

0 commit comments

Comments
 (0)