Skip to content

Commit 0a8af5b

Browse files
committed
tc
1 parent 0bd89b6 commit 0a8af5b

File tree

6 files changed

+168
-71
lines changed

6 files changed

+168
-71
lines changed

torchci/components/HudGroupingSettings/MainPageSettings.tsx

Lines changed: 85 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import {
22
closestCenter,
33
DndContext,
4-
KeyboardSensor,
54
PointerSensor,
65
useSensor,
76
useSensors,
87
} from "@dnd-kit/core";
98
import {
109
SortableContext,
11-
sortableKeyboardCoordinates,
1210
useSortable,
1311
verticalListSortingStrategy,
1412
} from "@dnd-kit/sortable";
1513
import { CSS } from "@dnd-kit/utilities";
14+
import { DragHandle } from "@mui/icons-material";
1615
import {
1716
Button,
1817
Dialog,
@@ -35,7 +34,6 @@ import {
3534
isDupName,
3635
saveTreeData,
3736
} from "./mainPageSettingsUtils";
38-
import { DragHandle } from "@mui/icons-material";
3937

4038
function validRegex(value: string) {
4139
try {
@@ -63,7 +61,13 @@ function EditSectionDialog({
6361

6462
return (
6563
<>
66-
<Button onClick={() => {setOpen(true)}}>Edit</Button>
64+
<Button
65+
onClick={() => {
66+
setOpen(true);
67+
}}
68+
>
69+
Edit
70+
</Button>
6771
<Dialog
6872
open={open}
6973
closeAfterTransition={false}
@@ -124,6 +128,54 @@ function EditSectionDialog({
124128
);
125129
}
126130

131+
function ResetButton({ onConfirm }: { onConfirm: () => void }) {
132+
const [open, setOpen] = useState(false);
133+
134+
return (
135+
<>
136+
<Button
137+
onClick={() => {
138+
setOpen(true);
139+
}}
140+
>
141+
Reset
142+
</Button>
143+
<Dialog
144+
open={open}
145+
closeAfterTransition={false}
146+
onClose={() => setOpen(false)}
147+
aria-modal
148+
>
149+
<DialogContent>
150+
<Stack spacing={2}>
151+
<Typography>
152+
Are you sure you want to reset to default group settings?
153+
</Typography>
154+
<Stack direction="row" spacing={2}>
155+
<Button
156+
onClick={() => {
157+
onConfirm();
158+
setOpen(false);
159+
}}
160+
color="error"
161+
>
162+
Yes
163+
</Button>
164+
<Button
165+
onClick={() => {
166+
setOpen(false);
167+
}}
168+
>
169+
No
170+
</Button>
171+
</Stack>
172+
</Stack>
173+
</DialogContent>
174+
</Dialog>
175+
</>
176+
);
177+
}
178+
127179
export default function SettingsModal({
128180
visible,
129181
handleClose,
@@ -140,9 +192,7 @@ export default function SettingsModal({
140192
return a.filterPriority - b.filterPriority;
141193
});
142194

143-
const sensors = useSensors(
144-
useSensor(PointerSensor),
145-
);
195+
const sensors = useSensors(useSensor(PointerSensor));
146196

147197
function addSection() {
148198
setTreeData([
@@ -164,7 +214,25 @@ export default function SettingsModal({
164214
}
165215

166216
function removeSection(name: string) {
167-
setTreeData(treeData.filter((node) => node.name !== name));
217+
const removedNode = treeData.find((node) => node.name === name);
218+
const filterPriority = removedNode!.filterPriority;
219+
const displayPriority = removedNode!.displayPriority;
220+
const newTreeData = treeData
221+
.filter((node) => node.name !== name)
222+
.map((node) => {
223+
return {
224+
...node,
225+
filterPriority:
226+
node.filterPriority > filterPriority
227+
? node.filterPriority - 1
228+
: node.filterPriority,
229+
displayPriority:
230+
node.displayPriority > displayPriority
231+
? node.displayPriority - 1
232+
: node.displayPriority,
233+
};
234+
});
235+
setTreeData(newTreeData);
168236
}
169237

170238
function setItem(name: string, newName: string, regex: string) {
@@ -274,7 +342,10 @@ export default function SettingsModal({
274342
open={visible}
275343
fullWidth={true}
276344
maxWidth="xl"
277-
onClose={handleClose}
345+
onClose={() => {
346+
saveTreeData(treeData);
347+
handleClose();
348+
}}
278349
onClick={(e) => e.stopPropagation()}
279350
>
280351
<Stack
@@ -293,14 +364,12 @@ export default function SettingsModal({
293364
>
294365
Save
295366
</Button>
296-
<Button
297-
onClick={() => {
367+
<ResetButton
368+
onConfirm={() => {
298369
saveTreeData(getDefaultGroupSettings());
299370
setTreeData(getDefaultGroupSettings());
300371
}}
301-
>
302-
Reset
303-
</Button>
372+
/>
304373
<Button
305374
onClick={() =>
306375
setOrderBy(orderBy == "display" ? "filter" : "display")
@@ -310,7 +379,7 @@ export default function SettingsModal({
310379
</Button>
311380
</Stack>
312381
<Button onClick={handleClose} color={"error"}>
313-
Close
382+
Close without Saving
314383
</Button>
315384
</Stack>
316385

@@ -325,7 +394,7 @@ export default function SettingsModal({
325394
strategy={verticalListSortingStrategy}
326395
>
327396
{treeDataOrdered.map((id) => (
328-
<Node key={id.name} data={id}/>
397+
<Node key={id.name} data={id} />
329398
))}
330399
</SortableContext>
331400
</DndContext>

torchci/components/HudGroupingSettings/hudGroupingSettings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export function getGroupingData(
6969
}
7070

7171
return {
72+
shaGrid,
7273
groupNameMapping,
7374
jobsWithFailures,
7475
groupsWithFailures,

torchci/components/HudGroupingSettings/mainPageSettingsUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ export function getStoredTreeData(): Group[] {
3939

4040
export function getNonDupNewName(treeData: Group[]) {
4141
let i = 0;
42-
while (isDupName(treeData, `New Group ${i}`)) {
42+
while (isDupName(treeData, `NEW GROUP ${i}`)) {
4343
i++;
4444
}
45-
return `New Group ${i}`;
45+
return `NEW GROUP ${i}`;
4646
}
4747

4848
export function isDupName(treeData: Group[], name: string): boolean {

torchci/lib/JobClassifierUtil.ts

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { GroupedJobStatus, JobStatus } from "components/job/GroupJobConclusion";
22
import { getOpenUnstableIssues } from "lib/jobUtils";
33
import { IssueData, RowData } from "./types";
4+
import { Group } from "components/HudGroupingSettings/mainPageSettingsUtils";
45

56
const GROUP_MEMORY_LEAK_CHECK = "Memory Leak Check";
67
const GROUP_RERUN_DISABLED_TESTS = "Rerun Disabled Tests";
@@ -157,48 +158,19 @@ export const groups = [
157158
},
158159
];
159160

160-
// Jobs on HUD home page will be sorted according to this list, with anything left off at the end
161-
// Reorder elements in this list to reorder the groups on the HUD
162-
const HUD_GROUP_SORTING = [
163-
GROUP_LINT,
164-
GROUP_LINUX,
165-
GROUP_WINDOWS,
166-
GROUP_IOS,
167-
GROUP_MAC,
168-
GROUP_ROCM,
169-
GROUP_XPU,
170-
GROUP_XLA,
171-
GROUP_OTHER_VIABLE_STRICT_BLOCKING, // placed after the last group that tends to have viable/strict blocking jobs
172-
GROUP_VLLM,
173-
GROUP_PARALLEL,
174-
GROUP_LIBTORCH,
175-
GROUP_ANDROID,
176-
GROUP_BINARY_LINUX,
177-
GROUP_DOCKER,
178-
GROUP_CALC_DOCKER_IMAGE,
179-
GROUP_CI_DOCKER_IMAGE_BUILDS,
180-
GROUP_CI_CIRCLECI_PYTORCH_IOS,
181-
GROUP_PERIODIC,
182-
GROUP_SLOW,
183-
GROUP_DOCS,
184-
GROUP_INDUCTOR,
185-
GROUP_INDUCTOR_PERIODIC,
186-
GROUP_ANNOTATIONS_AND_LABELING,
187-
GROUP_BINARY_WINDOWS,
188-
GROUP_MEMORY_LEAK_CHECK,
189-
GROUP_RERUN_DISABLED_TESTS,
190-
// These two groups should always be at the end
191-
GROUP_OTHER,
192-
GROUP_UNSTABLE,
193-
];
194161

195162
// Accepts a list of group names and returns that list sorted according to
196163
// the order defined in HUD_GROUP_SORTING
197-
export function sortGroupNamesForHUD(groupNames: string[]): string[] {
164+
export function sortGroupNamesForHUD(
165+
groupNames: string[],
166+
groupSettings: Group[]
167+
): string[] {
198168
let result: string[] = [];
199-
for (const group of HUD_GROUP_SORTING) {
200-
if (groupNames.includes(group)) {
201-
result.push(group);
169+
for (const group of groupSettings.sort(
170+
(a, b) => a.displayPriority - b.displayPriority
171+
)) {
172+
if (groupNames.includes(group.name)) {
173+
result.push(group.name);
202174
}
203175
}
204176

torchci/pages/hud/[repoOwner]/[repoName]/[branch]/[[...page]].tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Button } from "@mui/material";
12
import CheckBoxSelector from "components/common/CheckBoxSelector";
23
import CopyLink from "components/common/CopyLink";
34
import LoadingPage from "components/common/LoadingPage";
@@ -10,13 +11,15 @@ import {
1011
GroupHudTableHeader,
1112
passesGroupFilter,
1213
} from "components/hud/GroupHudTableHeaders";
14+
import { getGroupingData } from "components/HudGroupingSettings/hudGroupingSettings";
15+
import SettingsModal from "components/HudGroupingSettings/MainPageSettings";
1316
import HudGroupedCell from "components/job/GroupJobConclusion";
1417
import JobConclusion from "components/job/JobConclusion";
1518
import JobFilterInput from "components/job/JobFilterInput";
1619
import JobTooltip from "components/job/JobTooltip";
1720
import SettingsPanel from "components/SettingsPanel";
1821
import { fetcher } from "lib/GeneralUtils";
19-
import { isUnstableGroup } from "lib/JobClassifierUtil";
22+
import { isUnstableGroup, sortGroupNamesForHUD } from "lib/JobClassifierUtil";
2023
import {
2124
isFailedJob,
2225
isRerunDisabledTestsJob,
@@ -285,6 +288,7 @@ function FiltersAndSettings({}: {}) {
285288
const { jobFilter, handleSubmit } = useTableFilter(params);
286289
const [mergeEphemeralLF, setMergeEphemeralLF] = useContext(MergeLFContext);
287290
const [settingsPanelOpen, setSettingsPanelOpen] = useState(false);
291+
const [groupingSettingsOpen, setGroupingSettingsOpen] = useState(false);
288292
const [hideUnstable, setHideUnstable] = usePreference("hideUnstable");
289293
const [hideGreenColumns, setHideGreenColumns] =
290294
useHideGreenColumnsPreference();
@@ -340,6 +344,11 @@ function FiltersAndSettings({}: {}) {
340344
isOpen={settingsPanelOpen}
341345
onToggle={() => setSettingsPanelOpen(!settingsPanelOpen)}
342346
/>
347+
<Button onClick={() => setGroupingSettingsOpen(true)}>Groupings</Button>
348+
<SettingsModal
349+
visible={groupingSettingsOpen}
350+
handleClose={() => setGroupingSettingsOpen(false)}
351+
/>
343352
</div>
344353
);
345354
}
@@ -557,13 +566,18 @@ function GroupedHudTable({ params }: { params: HudParams }) {
557566
const [hideGreenColumns] = useHideGreenColumnsPreference();
558567
const [useGrouping] = useGroupingPreference(params.nameFilter);
559568

560-
const { shaGrid, groupNameMapping, jobsWithFailures, groupsWithFailures } =
561-
getGroupingData(
562-
data ?? [],
563-
jobNames,
564-
(!useGrouping && hideUnstable) || (useGrouping && !hideUnstable),
565-
unstableIssuesData ?? []
566-
);
569+
const {
570+
shaGrid,
571+
groupNameMapping,
572+
jobsWithFailures,
573+
groupsWithFailures,
574+
groupSettings,
575+
} = getGroupingData(
576+
data ?? [],
577+
jobNames,
578+
(!useGrouping && hideUnstable) || (useGrouping && !hideUnstable),
579+
unstableIssuesData ?? []
580+
);
567581

568582
const [expandedGroups, setExpandedGroups] = useState(new Set<string>());
569583

0 commit comments

Comments
 (0)