Skip to content

Commit df84100

Browse files
authored
[HUD] Put time range on last_successful_jobs query (#7134)
Reason: reduces # rows that need to be scanned => reduce time and resources. 60 days is an arbitrary limit since last docs push is currently 17 days (we should probably investigate) I'm too lazy to do perf right now but this should be a big improvement Also add `getValue` function to scalar panel so you can specify how to get your data This is used for the last docs push query to handle the case when there is no data
1 parent ff7eb66 commit df84100

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

torchci/clickhouse_queries/last_successful_jobs/query.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ where
1010
and job.conclusion = 'success'
1111
and job.head_branch = 'main'
1212
and job.html_url like '%/pytorch/pytorch/%' -- proxy for workflow.repository.'full_name' = 'pytorch/pytorch'
13+
and job.started_at > now() - interval 60 day
1314
group by
1415
job.head_sha
1516
having

torchci/components/metrics/panels/ScalarPanel.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ export default function ScalarPanel({
6666
metricName,
6767
// Callback to decide whether the scalar value is "bad" and should be displayed red.
6868
badThreshold,
69+
// Custom function to retrieve the value from the query
70+
getValue = (_data: any) => _data?.[0]?.[metricName],
6971
}: {
7072
title: string;
7173
queryName: string;
7274
queryParams: { [key: string]: any };
7375
valueRenderer: (_value: any) => string;
7476
metricName: string;
7577
badThreshold: (_value: any) => boolean;
78+
getValue?: (_data: any) => any;
7679
}) {
7780
const url = `/api/clickhouse/${queryName}?parameters=${encodeURIComponent(
7881
JSON.stringify(queryParams)
@@ -86,7 +89,7 @@ export default function ScalarPanel({
8689
return <Skeleton variant={"rectangular"} height={"100%"} />;
8790
}
8891

89-
const value = data.length > 0 ? data[0][metricName] : undefined;
92+
const value = getValue(data);
9093
return (
9194
<ScalarPanelWithValue
9295
title={title}

torchci/pages/metrics.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,11 +720,16 @@ export default function Page() {
720720
title={"Last docs push"}
721721
queryName={"last_successful_jobs"}
722722
metricName={"last_success_seconds_ago"}
723-
valueRenderer={(value) => durationDisplay(value)}
723+
getValue={(data) => data?.[0]?.last_success_seconds_ago || ">60d"}
724+
valueRenderer={(value) =>
725+
value === ">60d" ? value : durationDisplay(value)
726+
}
724727
queryParams={{
725728
jobNames: docsJobNames,
726729
}}
727-
badThreshold={(value) => value > 3 * 24 * 60 * 60} // 3 day
730+
badThreshold={(value) =>
731+
value === ">60d" || value > 3 * 24 * 60 * 60
732+
} // 3 day
728733
/>
729734
</Stack>
730735
</Grid>

0 commit comments

Comments
 (0)