Skip to content

Commit d9dff49

Browse files
authored
[HUD] Restrict 'Hide non-viable-strict jobs' to pytorch/pytorch (#8150)
## Summary The "Hide non-viable-strict jobs" setting was [defaulted to enabled in #8146](#8146). However, the viable/strict concept — and the `VIABLE_STRICT_BLOCKING_JOBS` map the filter relies on (`lib/JobClassifierUtil.ts`) — only exists for `pytorch/pytorch`. On any other repo that map is empty, so with the setting now on by default, opening the HUD for a non-pytorch repo would hide **every** column. This PR makes the setting pytorch/pytorch-only: - **Grays out / disables the checkbox** for non-pytorch/pytorch repos (with a tooltip explaining why), via a new `disabled`/`title` prop on `CheckBoxSelector`. - **Makes the filter a no-op** for non-pytorch/pytorch repos in `GroupedHudTable`, so even a value left in `localStorage` from visiting pytorch/pytorch won't hide anything elsewhere. - Adds an `isPyTorchPyTorchRepo(params)` helper in `lib/types.ts` (alongside the other `HudParams` helpers) and uses it for the gating, including the existing `isPyTorchMain` check. ## Test plan - On `pytorch/pytorch`: checkbox is enabled and filtering behaves as before. - On any other repo (e.g. `pytorch/vision`): checkbox is grayed out / not clickable, and no columns are hidden regardless of the stored setting.
1 parent b9b7ab8 commit d9dff49

3 files changed

Lines changed: 39 additions & 8 deletions

File tree

torchci/components/common/CheckBoxSelector.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,50 @@ export default function CheckBoxSelector({
33
setValue,
44
checkBoxName,
55
labelText,
6+
disabled = false,
7+
title,
68
}: {
79
value: boolean;
810
setValue: (_value: boolean) => void;
911
checkBoxName: string;
1012
labelText: string;
13+
disabled?: boolean;
14+
title?: string;
1115
}) {
1216
return (
1317
<div style={{ margin: 0 }}>
1418
<span
1519
onClick={() => {
20+
if (disabled) {
21+
return;
22+
}
1623
setValue(!value);
1724
}}
25+
title={title}
1826
style={{
1927
display: "flex",
2028
alignItems: "center",
2129
gap: "0.25rem",
22-
cursor: "pointer",
30+
cursor: disabled ? "not-allowed" : "pointer",
2331
whiteSpace: "nowrap",
32+
opacity: disabled ? 0.5 : 1,
2433
}}
2534
>
2635
<input
2736
type="checkbox"
2837
name={checkBoxName}
2938
checked={value}
39+
disabled={disabled}
3040
onChange={() => {}}
31-
style={{ margin: 0 }}
41+
style={{ margin: 0, cursor: disabled ? "not-allowed" : "pointer" }}
3242
/>
33-
<label htmlFor={checkBoxName} style={{ margin: 0, cursor: "pointer" }}>
43+
<label
44+
htmlFor={checkBoxName}
45+
style={{
46+
margin: 0,
47+
cursor: disabled ? "not-allowed" : "pointer",
48+
}}
49+
>
3450
{labelText}
3551
</label>
3652
</span>

torchci/lib/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ export interface HudParams {
135135
useRegexFilter?: boolean;
136136
}
137137

138+
export function isPyTorchPyTorchRepo(params: HudParams): boolean {
139+
return params.repoOwner === "pytorch" && params.repoName === "pytorch";
140+
}
141+
138142
export interface PRData {
139143
title: string;
140144
body: string;

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
formatHudUrlForRoute,
4646
Highlight,
4747
HudParams,
48+
isPyTorchPyTorchRepo,
4849
IssueData,
4950
JobData,
5051
packHudParams,
@@ -399,9 +400,11 @@ function FiltersAndSettings({}: {}) {
399400

400401
// Only show autorevert toggle for pytorch/pytorch main
401402
const isPyTorchMain =
402-
params.repoOwner === "pytorch" &&
403-
params.repoName === "pytorch" &&
404-
params.branch === "main";
403+
isPyTorchPyTorchRepo(params) && params.branch === "main";
404+
405+
// The viable/strict concept (and thus this filter) only exists for
406+
// pytorch/pytorch, so the toggle is a no-op for any other repo.
407+
const isPyTorchRepo = isPyTorchPyTorchRepo(params);
405408

406409
return (
407410
<div className={styles.hudControlsRow}>
@@ -450,6 +453,12 @@ function FiltersAndSettings({}: {}) {
450453
checkBoxName="hideNonViableStrict"
451454
key="hideNonViableStrict"
452455
labelText={"Hide non-viable-strict jobs"}
456+
disabled={!isPyTorchRepo}
457+
title={
458+
isPyTorchRepo
459+
? undefined
460+
: "Only applies to the pytorch/pytorch repo"
461+
}
453462
/>,
454463
<CheckBoxSelector
455464
value={hideAlwaysSkipped}
@@ -855,8 +864,10 @@ function GroupedHudTable({ params }: { params: HudParams }) {
855864
return false;
856865
}
857866

858-
// If hiding non-viable-strict, only show jobs/groups that are viable/strict blocking
859-
if (hideNonViableStrict) {
867+
// If hiding non-viable-strict, only show jobs/groups that are viable/strict
868+
// blocking. The viable/strict concept only exists for pytorch/pytorch, so
869+
// this filter is ignored for any other repo (even if the setting is checked).
870+
if (hideNonViableStrict && isPyTorchPyTorchRepo(params)) {
860871
if (
861872
!groupsViableStrictBlocking.has(name) &&
862873
!jobsViableStrictBlocking.has(name)

0 commit comments

Comments
 (0)