Skip to content

[HUD][TTS] Add granularity, time, etc to permalink #6989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2025
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
2 changes: 1 addition & 1 deletion torchci/pages/metrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export function TtsPercentilePicker({
Percentile
</InputLabel>
<Select
defaultValue={ttsPercentile}
value={ttsPercentile}
label="Percentile"
labelId="tts-percentile-picker-select-label"
onChange={handleChange}
Expand Down
100 changes: 70 additions & 30 deletions torchci/pages/tts/[repoOwner]/[repoName]/[branch]/[[...page]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ export default function Page() {
const repoOwner: string = (router.query.repoOwner as string) ?? "pytorch";
const repoName: string = (router.query.repoName as string) ?? "pytorch";
const branch: string = (router.query.branch as string) ?? "main";
const jobNamesCompressed: string =
(router.query.jobNamesCompressed as string) ?? "";
const [startTime, setStartTime] = useState(dayjs().subtract(1, "week"));
const [stopTime, setStopTime] = useState(dayjs());
const [granularity, setGranularity] = useState<Granularity>("day");
Expand All @@ -95,6 +93,58 @@ export default function Page() {
[key: string]: boolean;
}>({});

useEffect(() => {
if (router.query.jobName) {
setSelectedJobs((prev) => ({
...prev,
[router.query.jobName as string]: true,
}));
}
if (router.query.startTime) {
setStartTime(dayjs(router.query.startTime as string));
}
if (router.query.stopTime) {
setStopTime(dayjs(router.query.stopTime as string));
}
if (router.query.granularity) {
setGranularity(router.query.granularity as string as Granularity);
}
if (router.query.timeRange) {
setTimeRange(parseInt(router.query.timeRange as string) || 7);
}
if (router.query.ttsPercentile) {
setTtsPercentile(parseFloat(router.query.ttsPercentile as string) || 0.5);
}

const jobNamesFromLink = JSON.parse(
router.query.jobNamesCompressed
? decompressFromEncodedURIComponent(
router.query.jobNamesCompressed as string
)
: "[]"
);

if (router.query.jobName) {
jobNamesFromLink.push(router.query.jobName as string);
}

if (tts_true_series.length > 0) {
setSelectedJobs(
tts_true_series.reduce((acc: any, item: any) => {
acc[item.name] = jobNamesFromLink.includes(item.name);
return acc;
}, {} as any)
);
} else {
setSelectedJobs(
jobNamesFromLink.reduce((acc: any, item: any) => {
acc[item] = true;
return acc;
}, {} as any)
);
}
}, [router.query]);

const GRAPHS_HEIGHT = 800;

const queryParams: { [key: string]: any } = {
Expand Down Expand Up @@ -127,6 +177,19 @@ export default function Page() {
fetcher
);

useEffect(() => {
if (data != undefined) {
const jobNames = data.map((item) => item.full_name);
setSelectedJobs((prev) => {
const newJobs = jobNames.reduce((acc: any, jobName: string) => {
acc[jobName] = false;
return acc;
}, {});
return { ...newJobs, ...prev };
});
}
}, [data]);

const timeFieldName = "granularity_bucket";
const groupByFieldName = "full_name";
const tts_true_series = seriesWithInterpolatedTimes(
Expand Down Expand Up @@ -155,34 +218,6 @@ export default function Page() {
(item: any) => selectedJobs[item["name"]]
);

useEffect(() => {
const jobNamesFromLink = JSON.parse(
jobNamesCompressed != ""
? decompressFromEncodedURIComponent(jobNamesCompressed)
: "[]"
);

if (router.query.jobName) {
jobNamesFromLink.push(router.query.jobName as string);
}

if (tts_true_series.length > 0) {
setSelectedJobs(
tts_true_series.reduce((acc: any, item: any) => {
acc[item.name] = jobNamesFromLink.includes(item.name);
return acc;
}, {} as any)
);
} else {
setSelectedJobs(
jobNamesFromLink.reduce((acc: any, item: any) => {
acc[item] = true;
return acc;
}, {} as any)
);
}
}, [data, jobNamesCompressed, router.query.jobName]);

const permalink =
typeof window !== "undefined" &&
`${window.location.protocol}/${window.location.host}${router.asPath.replace(
Expand All @@ -194,6 +229,11 @@ export default function Page() {
Object.keys(selectedJobs).filter((key) => selectedJobs[key])
)
),
startTime: startTime.utc().format("YYYY-MM-DDTHH:mm:ss.SSS"),
stopTime: stopTime.utc().format("YYYY-MM-DDTHH:mm:ss.SSS"),
granularity: granularity,
timeRange: timeRange.toString(),
ttsPercentile: ttsPercentile.toString(),
})}`;

return (
Expand Down