From 23cc7974d143851f786db75bc49c9d6d159e2ad4 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Thu, 20 Nov 2025 16:38:16 -0700 Subject: [PATCH 1/8] hidemetadata --- .../components/additionalTestInfo/TestInfo.tsx | 4 ++++ torchci/components/commit/WorkflowBox.tsx | 17 ++++++++--------- .../[workflowId]/[jobId]/[attempt].ts | 1 + .../[jobId]/[attempt]/[[...page]].tsx | 3 ++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/torchci/components/additionalTestInfo/TestInfo.tsx b/torchci/components/additionalTestInfo/TestInfo.tsx index 4eef142c06..1d4ba4858e 100644 --- a/torchci/components/additionalTestInfo/TestInfo.tsx +++ b/torchci/components/additionalTestInfo/TestInfo.tsx @@ -37,6 +37,10 @@ export function genMessage({ return errorString.trim(); } +export function isPendingJob(job: JobData) { + return IsJobInProgress(job.conclusion); +} + export function isPending(jobs: JobData[]) { return jobs.some((job) => IsJobInProgress(job.conclusion)); } diff --git a/torchci/components/commit/WorkflowBox.tsx b/torchci/components/commit/WorkflowBox.tsx index 5ed9135185..9826c21d74 100644 --- a/torchci/components/commit/WorkflowBox.tsx +++ b/torchci/components/commit/WorkflowBox.tsx @@ -1,5 +1,9 @@ import { Button, Stack, styled, Tooltip, Typography } from "@mui/material"; -import { isPending, TestInfo } from "components/additionalTestInfo/TestInfo"; +import { + isPending, + isPendingJob, + TestInfo, +} from "components/additionalTestInfo/TestInfo"; import styles from "components/commit/commit.module.css"; import LogViewer, { SearchLogViewer } from "components/common/log/LogViewer"; import { durationDisplay } from "components/common/TimeUtils"; @@ -97,18 +101,13 @@ function WorkflowJobSummary({ ); } - if (utilMetadata && utilMetadata.length > 0) { - if (utilMetadata.length > 1) { - console.log( - `Multiple util metadata found for job ${job.id}, currently only showing the first one` - ); - } - const m = utilMetadata[0]; + if (job.id && !isPendingJob(job)) { + const m = job; subInfo.push( <> { const router = useRouter(); const { workflowId, jobId, attempt } = router.query; + let shouldFetch = workflowId && jobId; let { data, error } = useSWRImmutable( - `/api/utilization/${workflowId}/${jobId}/${attempt}`, + shouldFetch ? `/api/utilization/${workflowId}/${jobId}/${attempt}` : null, fetcherHandleError, { errorRetryCount: 3, From 37954857642b564a296736f511d29b1f4d3172d4 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Thu, 20 Nov 2025 16:46:17 -0700 Subject: [PATCH 2/8] hidemetadata --- .../[workflowId]/[jobId]/[attempt].ts | 0 .../utilization/[workflowId]/[jobId]/[attempt]/[[...page]].tsx | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename torchci/pages/api/{utilization => job_utilization}/[workflowId]/[jobId]/[attempt].ts (100%) diff --git a/torchci/pages/api/utilization/[workflowId]/[jobId]/[attempt].ts b/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts similarity index 100% rename from torchci/pages/api/utilization/[workflowId]/[jobId]/[attempt].ts rename to torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts diff --git a/torchci/pages/utilization/[workflowId]/[jobId]/[attempt]/[[...page]].tsx b/torchci/pages/utilization/[workflowId]/[jobId]/[attempt]/[[...page]].tsx index 75eab17a6d..104b7c31a7 100644 --- a/torchci/pages/utilization/[workflowId]/[jobId]/[attempt]/[[...page]].tsx +++ b/torchci/pages/utilization/[workflowId]/[jobId]/[attempt]/[[...page]].tsx @@ -11,7 +11,7 @@ const JobUtilization = () => { let shouldFetch = workflowId && jobId; let { data, error } = useSWRImmutable( - shouldFetch ? `/api/utilization/${workflowId}/${jobId}/${attempt}` : null, + shouldFetch ? `/api/job_utilization/${workflowId}/${jobId}/${attempt}` : null, fetcherHandleError, { errorRetryCount: 3, From d65a7ec24b5ef0351cabd792051a78e51bc5d271 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Thu, 20 Nov 2025 16:54:30 -0700 Subject: [PATCH 3/8] hidemetadata --- .../[workflowId]/[jobId]/[attempt]/[[...page]].tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/torchci/pages/utilization/[workflowId]/[jobId]/[attempt]/[[...page]].tsx b/torchci/pages/utilization/[workflowId]/[jobId]/[attempt]/[[...page]].tsx index 104b7c31a7..f073e0f28d 100644 --- a/torchci/pages/utilization/[workflowId]/[jobId]/[attempt]/[[...page]].tsx +++ b/torchci/pages/utilization/[workflowId]/[jobId]/[attempt]/[[...page]].tsx @@ -11,7 +11,9 @@ const JobUtilization = () => { let shouldFetch = workflowId && jobId; let { data, error } = useSWRImmutable( - shouldFetch ? `/api/job_utilization/${workflowId}/${jobId}/${attempt}` : null, + shouldFetch + ? `/api/job_utilization/${workflowId}/${jobId}/${attempt}` + : null, fetcherHandleError, { errorRetryCount: 3, From fb8a8a016f46bd5fbb5b2dc6dde1b43691deeffc Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Thu, 20 Nov 2025 17:11:53 -0700 Subject: [PATCH 4/8] hidemetadata --- .../[workflowId]/[jobId]/[attempt].ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts b/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts index d6a57dff70..5c814a5cbb 100644 --- a/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts +++ b/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts @@ -2,6 +2,9 @@ import { getErrorMessage } from "lib/error_utils"; import fetchUtilization from "lib/utilization/fetchUtilization"; import { UtilizationParams } from "lib/utilization/types"; import { NextApiRequest, NextApiResponse } from "next"; +import { getServerSession } from "next-auth"; +import { authOptions } from "pages/api/auth/[...nextauth]"; + export default async function handler( req: NextApiRequest, @@ -9,9 +12,19 @@ export default async function handler( ) { const { workflowId, jobId, attempt } = req.query; - if (workflowId === undefined || jobId === undefined || attempt == undefined) { + // @ts-ignore + const session = await getServerSession(req, res, authOptions); + if (!session?.user || !session?.accessToken) { + return res.status(401).json({ error: "Authentication required to require utilization data" }); + } + + if (!workflowId || !jobId || !attempt) { + console.log( + "[api job_utilization][warning] No workflowId, jobId, or attempt provided" + ); return res.status(200).json({}); } + const params: UtilizationParams = { workflow_id: workflowId as string, run_attempt: attempt as string, From 4b9c23ae1faac95879543493d96ea5022ec98104 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Thu, 20 Nov 2025 17:23:50 -0700 Subject: [PATCH 5/8] hidemetadata --- .../api/job_utilization/[workflowId]/[jobId]/[attempt].ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts b/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts index 5c814a5cbb..a566ecbb84 100644 --- a/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts +++ b/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts @@ -5,7 +5,6 @@ import { NextApiRequest, NextApiResponse } from "next"; import { getServerSession } from "next-auth"; import { authOptions } from "pages/api/auth/[...nextauth]"; - export default async function handler( req: NextApiRequest, res: NextApiResponse @@ -15,7 +14,9 @@ export default async function handler( // @ts-ignore const session = await getServerSession(req, res, authOptions); if (!session?.user || !session?.accessToken) { - return res.status(401).json({ error: "Authentication required to require utilization data" }); + return res + .status(401) + .json({ error: "Authentication required to require utilization data" }); } if (!workflowId || !jobId || !attempt) { From ccb934bda7a43dddaf76eab97a444e689cd43b88 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Thu, 20 Nov 2025 17:45:45 -0700 Subject: [PATCH 6/8] hidemetadata --- torchci/components/commit/WorkflowBox.tsx | 11 ----------- .../job_utilization/[workflowId]/[jobId]/[attempt].ts | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/torchci/components/commit/WorkflowBox.tsx b/torchci/components/commit/WorkflowBox.tsx index 9826c21d74..b6c74de872 100644 --- a/torchci/components/commit/WorkflowBox.tsx +++ b/torchci/components/commit/WorkflowBox.tsx @@ -48,14 +48,12 @@ const JobButton = styled(Button)({ }); function WorkflowJobSummary({ job, - utilMetadata, artifacts, artifactsToShow, setArtifactsToShow, unstableIssues, }: { job: JobData; - utilMetadata?: UtilizationMetadataInfo[]; artifacts?: Artifact[]; artifactsToShow: Set; setArtifactsToShow: any; @@ -183,10 +181,6 @@ export default function WorkflowBox({ : styles.workflowBoxSuccess; const anchorName = encodeURIComponent(workflowName.toLowerCase()); - - const { utilMetadataList } = useUtilMetadata(workflowId?.toString()); - const groupUtilMetadataList = groupMetadataByJobId(utilMetadataList); - const { artifacts, error } = useArtifacts(jobs.map((job) => job.workflowId)); const [artifactsToShow, setArtifactsToShow] = useState(new Set()); const groupedArtifacts = groupArtifacts(jobs, artifacts); @@ -304,11 +298,6 @@ export default function WorkflowBox({
Date: Thu, 20 Nov 2025 17:49:09 -0700 Subject: [PATCH 7/8] hidemetadata --- .../api/job_utilization/[workflowId]/[jobId]/[attempt].ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts b/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts index 6df07c6d1d..d196c26998 100644 --- a/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts +++ b/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts @@ -16,7 +16,10 @@ export default async function handler( if (!session?.user || !session?.accessToken) { return res .status(401) - .json({ error: "Authentication required to require utilization data, please login in the main hud page" }); + .json({ + error: + "Authentication required to require utilization data, please login in the main hud page", + }); } if (!workflowId || !jobId || !attempt) { From 8c5feec813d7d93d90cb987bcd255e0ac90bfc59 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Thu, 20 Nov 2025 17:53:41 -0700 Subject: [PATCH 8/8] hidemetadata --- .../job_utilization/[workflowId]/[jobId]/[attempt].ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts b/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts index d196c26998..6d8a808ba6 100644 --- a/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts +++ b/torchci/pages/api/job_utilization/[workflowId]/[jobId]/[attempt].ts @@ -14,12 +14,10 @@ export default async function handler( // @ts-ignore const session = await getServerSession(req, res, authOptions); if (!session?.user || !session?.accessToken) { - return res - .status(401) - .json({ - error: - "Authentication required to require utilization data, please login in the main hud page", - }); + return res.status(401).json({ + error: + "Authentication required to require utilization data, please login in the main hud page", + }); } if (!workflowId || !jobId || !attempt) {