From 23cc7974d143851f786db75bc49c9d6d159e2ad4 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Thu, 20 Nov 2025 16:38:16 -0700 Subject: [PATCH 1/5] 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/5] 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/5] 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/5] 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/5] 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) {