Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions torchci/components/additionalTestInfo/TestInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
17 changes: 8 additions & 9 deletions torchci/components/commit/WorkflowBox.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -97,18 +101,13 @@ function WorkflowJobSummary({
</JobButton>
);
}
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(
<>
<JobButton
variant="outlined"
href={`/utilization/${m.workflow_id}/${m.job_id}/${m.run_attempt}`}
href={`/utilization/${m.workflowId}/${m.id}/${m.runAttempt}`}
data-ga-action="utilization_report_click"
data-ga-label="nav_button"
data-ga-category="user_interaction"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@ 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,
res: NextApiResponse
) {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ const JobUtilization = () => {
const router = useRouter();
const { workflowId, jobId, attempt } = router.query;

let shouldFetch = workflowId && jobId;
let { data, error } = useSWRImmutable(
`/api/utilization/${workflowId}/${jobId}/${attempt}`,
shouldFetch
? `/api/job_utilization/${workflowId}/${jobId}/${attempt}`
: null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to pass in the authorization token here? I mean it does block the api, but now I think it blocks for every one

fetcherHandleError,
{
errorRetryCount: 3,
Expand Down