Skip to content

Commit 634a4c6

Browse files
authored
[HUD] Show the unstable button even if the job is successful (#6094)
Previously it only used up if the job was failing, but when the job is no longer failing, the button goes away, making it hard to track down the issue How to check preview: look for an unstable job (as of writing this, there is one) check that the button shows up. Also check that the button doesn't show up on other jobs
1 parent 4796068 commit 634a4c6

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

torchci/components/JobLinks.tsx

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import dayjs from "dayjs";
22
import { useSession } from "next-auth/react";
33
import { IssueLabelApiResponse } from "pages/api/issue/[label]";
44
import useSWR from "swr";
5-
import { isFailure, IsJobInProgress } from "../lib/JobClassifierUtil";
5+
import { IsJobInProgress } from "../lib/JobClassifierUtil";
66
import { isFailedJob, transformJobName } from "../lib/jobUtils";
77
import { IssueData, JobData } from "../lib/types";
88
import CopyLink from "./CopyLink";
@@ -206,18 +206,18 @@ function formatUnstableJobBody() {
206206
}
207207

208208
function UnstableJob({ job, label }: { job: JobData; label: string }) {
209-
const swrKey = isFailure(job.conclusion) ? `/api/issue/${label}` : null;
210-
const { data: issues } = useSWR<IssueLabelApiResponse>(swrKey, fetcher, {
211-
// Set a 60s cache for the request, so that lots of tooltip hovers don't
212-
// spam the backend. Since actually mutating the state (through filing a
213-
// disable issue) is a pretty heavy operation, 60s of staleness is fine.
214-
dedupingInterval: 60 * 1000,
215-
refreshInterval: 60 * 1000, // refresh every minute
216-
});
217-
218-
if (!isFailure(job.conclusion)) {
219-
return null;
220-
}
209+
const swrKey = `/api/issue/${label}`;
210+
const { data: issues, isLoading } = useSWR<IssueLabelApiResponse>(
211+
swrKey,
212+
fetcher,
213+
{
214+
// Set a 60s cache for the request, so that lots of tooltip hovers don't
215+
// spam the backend. Since actually mutating the state (through filing a
216+
// disable issue) is a pretty heavy operation, 60s of staleness is fine.
217+
dedupingInterval: 60 * 1000,
218+
refreshInterval: 60 * 1000, // refresh every minute
219+
}
220+
);
221221

222222
const jobName = transformJobName(job.name);
223223
// Ignore invalid job name
@@ -226,10 +226,16 @@ function UnstableJob({ job, label }: { job: JobData; label: string }) {
226226
}
227227

228228
// If we don't yet have any data, show a loading state.
229-
if (issues === undefined) {
229+
if (isLoading) {
230230
return <span>checking for disable jobs</span>;
231231
}
232232

233+
if (issues === undefined) {
234+
// Usually this means that it's loading but add this check just in case it
235+
// actually returns undefined somehow and hide it from users.
236+
return null;
237+
}
238+
233239
// At this point, we should show something. Search the existing disable issues
234240
// for a matching one.
235241
const issueTitle = `UNSTABLE ${jobName}`;
@@ -238,6 +244,11 @@ function UnstableJob({ job, label }: { job: JobData; label: string }) {
238244
const matchingIssues = issues.filter((issue) =>
239245
issueTitle.includes(issue.title)
240246
);
247+
248+
if (matchingIssues.length == 0) {
249+
return null;
250+
}
251+
241252
const repo = job.repo ?? "pytorch/pytorch";
242253

243254
return (

0 commit comments

Comments
 (0)