Skip to content

Commit 7cb79fc

Browse files
authored
[HUD][CH] Everything on metrics page to use ClickHouse only and remove migration related code (#6046)
As in title. Most things were already switched by previous, similar PRs for components
1 parent a259b2e commit 7cb79fc

File tree

1 file changed

+44
-100
lines changed

1 file changed

+44
-100
lines changed

torchci/pages/metrics.tsx

Lines changed: 44 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ import ScalarPanel, {
2323
import TablePanel from "components/metrics/panels/TablePanel";
2424
import TimeSeriesPanel from "components/metrics/panels/TimeSeriesPanel";
2525
import { durationDisplay } from "components/TimeUtils";
26-
import { useCHContext } from "components/UseClickhouseProvider";
2726
import dayjs from "dayjs";
2827
import { EChartsOption } from "echarts";
2928
import ReactECharts from "echarts-for-react";
3029
import { fetcher } from "lib/GeneralUtils";
31-
import { RocksetParam } from "lib/rockset";
3230
import { useEffect, useState } from "react";
3331
import useSWR from "swr";
3432

@@ -378,39 +376,25 @@ function JobsDuration({
378376
branchName,
379377
queryName,
380378
metricName,
381-
percentileParam,
379+
percentile,
382380
timeParams,
383-
useClickHouse = false,
384381
}: {
385382
title: string;
386383
branchName: string;
387384
queryName: string;
388385
metricName: string;
389-
percentileParam: RocksetParam;
390-
timeParams: RocksetParam[];
391-
useClickHouse?: boolean;
386+
percentile: number;
387+
timeParams: { [key: string]: string };
392388
}) {
393-
const ttsPercentile = percentileParam.value;
394-
395-
let metricHeaderName: string = `p${ttsPercentile * 100}`;
396-
let queryParams: RocksetParam[] | {} = useClickHouse
397-
? {
398-
...RStoCHTimeParams(timeParams),
399-
branch: branchName,
400-
percentile: ttsPercentile,
401-
}
402-
: [
403-
{
404-
name: "branch",
405-
type: "string",
406-
value: branchName,
407-
},
408-
percentileParam,
409-
...timeParams,
410-
];
389+
let metricHeaderName: string = `p${percentile * 100}`;
390+
let queryParams = {
391+
...timeParams,
392+
branch: branchName,
393+
percentile: percentile,
394+
};
411395

412396
// -1 is the specical case where we will show the avg instead
413-
if (ttsPercentile === -1) {
397+
if (percentile === -1) {
414398
metricHeaderName = "avg";
415399
queryName = queryName.replace("percentile", "avg");
416400
}
@@ -431,66 +415,30 @@ function JobsDuration({
431415

432416
const ROW_HEIGHT = 375;
433417

434-
export function RStoCHTimeParams(params: RocksetParam[]) {
435-
return {
436-
startTime: params
437-
.find((p) => p.name === "startTime")
438-
?.value.utc()
439-
.format("YYYY-MM-DDTHH:mm:ss.SSS"),
440-
stopTime: params
441-
.find((p) => p.name === "stopTime")
442-
?.value.utc()
443-
.format("YYYY-MM-DDTHH:mm:ss.SSS"),
444-
};
445-
}
446-
447418
export default function Page() {
448419
const [startTime, setStartTime] = useState(dayjs().subtract(1, "week"));
449420
const [stopTime, setStopTime] = useState(dayjs());
450421
const [timeRange, setTimeRange] = useState<number>(7);
451422

452-
// TODO (huydhn): Clean this up once ClickHouse migration finishes
453-
const { useCH: useClickHouse } = useCHContext();
454-
455-
const timeParams: RocksetParam[] = [
456-
{
457-
name: "startTime",
458-
type: "string",
459-
value: startTime,
460-
},
461-
{
462-
name: "stopTime",
463-
type: "string",
464-
value: stopTime,
465-
},
466-
];
467-
const timeParamsClickHouse = RStoCHTimeParams(timeParams);
423+
const timeParams = {
424+
startTime: startTime.utc().format("YYYY-MM-DDTHH:mm:ss.SSS"),
425+
stopTime: stopTime.utc().format("YYYY-MM-DDTHH:mm:ss.SSS"),
426+
};
468427

469428
const [ttsPercentile, setTtsPercentile] = useState<number>(0.5);
470429

471-
const percentileParam: RocksetParam = {
472-
name: "percentile",
473-
type: "float",
474-
value: ttsPercentile,
475-
};
476-
477430
// Split the aggregated red % into broken trunk and flaky red %
478-
const queryCollection = "metrics";
479431
const queryName = "master_commit_red_avg";
480432

481433
// Query both broken trunk and flaky red % in one query to some
482434
// save CPU usage. This query is quite expensive to run
483-
const url = useClickHouse
484-
? `/api/clickhouse/${queryName}?parameters=${encodeURIComponent(
485-
JSON.stringify({
486-
...timeParamsClickHouse,
487-
// TODO (huydhn): Figure out a way to have default parameters for ClickHouse queries
488-
workflowNames: ["lint", "pull", "trunk"],
489-
})
490-
)}`
491-
: `/api/query/${queryCollection}/${queryName}?parameters=${encodeURIComponent(
492-
JSON.stringify(timeParams)
493-
)}`;
435+
const url = `/api/clickhouse/${queryName}?parameters=${encodeURIComponent(
436+
JSON.stringify({
437+
...timeParams,
438+
// TODO (huydhn): Figure out a way to have default parameters for ClickHouse queries
439+
workflowNames: ["lint", "pull", "trunk"],
440+
})
441+
)}`;
494442

495443
const { data } = useSWR(url, fetcher, {
496444
refreshInterval: 5 * 60 * 1000, // refresh every 5 minutes
@@ -533,7 +481,7 @@ export default function Page() {
533481

534482
<Grid container spacing={2}>
535483
<Grid item md={6} xs={12} height={ROW_HEIGHT}>
536-
<MasterCommitRedPanel params={timeParamsClickHouse} />
484+
<MasterCommitRedPanel params={timeParams} />
537485
</Grid>
538486

539487
<Grid container item lg={2} md={3} xs={6} justifyContent={"stretch"}>
@@ -571,7 +519,7 @@ export default function Page() {
571519
metricName={"metric"}
572520
valueRenderer={(value) => value.toFixed(1) + "%"}
573521
queryParams={{
574-
...timeParamsClickHouse,
522+
...timeParams,
575523
merge_type: "Failure",
576524
one_bucket: true,
577525
granularity: "week", // Not used but ClickHouse requires it
@@ -584,7 +532,7 @@ export default function Page() {
584532
metricName={"metric"}
585533
valueRenderer={(value) => value.toFixed(1) + "%"}
586534
queryParams={{
587-
...timeParamsClickHouse,
535+
...timeParams,
588536
merge_type: "Impatience",
589537
one_bucket: true,
590538
granularity: "week", // Not used but ClickHouse requires it
@@ -603,10 +551,10 @@ export default function Page() {
603551
<ScalarPanel
604552
title={"Time to Red Signal (p90 TTRS - mins)"}
605553
queryName={"ttrs_percentiles"}
606-
metricName={useClickHouse ? "custom" : "ttrs_mins"}
554+
metricName={"custom"}
607555
valueRenderer={(value) => value}
608556
queryParams={{
609-
...timeParamsClickHouse,
557+
...timeParams,
610558
one_bucket: true,
611559
percentile_to_get: 0.9,
612560
workflow: "pull",
@@ -616,10 +564,10 @@ export default function Page() {
616564
<ScalarPanel
617565
title={"Time to Red Signal (p75 TTRS - mins)"}
618566
queryName={"ttrs_percentiles"}
619-
metricName={useClickHouse ? "custom" : "ttrs_mins"}
567+
metricName={"custom"}
620568
valueRenderer={(value) => value}
621569
queryParams={{
622-
...timeParamsClickHouse,
570+
...timeParams,
623571
one_bucket: true,
624572
percentile_to_get: 0.75,
625573
workflow: "pull",
@@ -642,7 +590,7 @@ export default function Page() {
642590
valueRenderer={(value) => durationDisplay(value)}
643591
queryParams={{
644592
repo: "pytorch",
645-
owner: "pytorch", // Not a parameter for the rockset query
593+
owner: "pytorch",
646594
head: "refs/heads/main",
647595
}}
648596
badThreshold={(value) => value > 60 * 60 * 6} // 6 hours
@@ -726,15 +674,15 @@ export default function Page() {
726674
queryName={"reverts"}
727675
metricName={"num"}
728676
valueRenderer={(value: string) => value}
729-
queryParams={timeParamsClickHouse}
677+
queryParams={timeParams}
730678
badThreshold={(value) => value > 10}
731679
/>
732680
<ScalarPanel
733681
title={"# commits"}
734682
queryName={"num_commits_master"}
735683
metricName={"num"}
736684
valueRenderer={(value) => value}
737-
queryParams={timeParamsClickHouse}
685+
queryParams={timeParams}
738686
badThreshold={(_) => false}
739687
/>
740688
</Stack>
@@ -749,7 +697,7 @@ export default function Page() {
749697
>
750698
<WorkflowDuration
751699
percentile={ttsPercentile}
752-
timeParams={timeParamsClickHouse}
700+
timeParams={timeParams}
753701
workflowNames={["pull", "trunk"]}
754702
/>
755703
</Stack>
@@ -814,7 +762,7 @@ export default function Page() {
814762
title={"Queue times historical"}
815763
queryName={"queue_times_historical"}
816764
queryParams={{
817-
...timeParamsClickHouse,
765+
...timeParams,
818766
granlarity: "hour",
819767
}}
820768
granularity={"hour"}
@@ -829,7 +777,7 @@ export default function Page() {
829777
<TimeSeriesPanel
830778
title={"Workflow load per Day"}
831779
queryName={"workflow_load"}
832-
queryParams={{ ...timeParamsClickHouse, repo: "pytorch/pytorch" }}
780+
queryParams={{ ...timeParams, repo: "pytorch/pytorch" }}
833781
granularity={"hour"}
834782
groupByFieldName={"name"}
835783
timeFieldName={"granularity_bucket"}
@@ -844,46 +792,42 @@ export default function Page() {
844792
branchName={"%"}
845793
queryName={"tts_percentile"}
846794
metricName={"tts_sec"}
847-
percentileParam={percentileParam}
795+
percentile={ttsPercentile}
848796
timeParams={timeParams}
849-
useClickHouse={useClickHouse}
850797
/>
851798

852799
<JobsDuration
853800
title={"Job time-to-signal, main-only"}
854801
branchName={"main"}
855802
queryName={"tts_percentile"}
856803
metricName={"tts_sec"}
857-
percentileParam={percentileParam}
804+
percentile={ttsPercentile}
858805
timeParams={timeParams}
859-
useClickHouse={useClickHouse}
860806
/>
861807

862808
<JobsDuration
863809
title={"Job duration, all branches"}
864810
branchName={"%"}
865811
queryName={"job_duration_percentile"}
866812
metricName={"duration_sec"}
867-
percentileParam={percentileParam}
813+
percentile={ttsPercentile}
868814
timeParams={timeParams}
869-
useClickHouse={useClickHouse}
870815
/>
871816

872817
<JobsDuration
873818
title={"Job duration, main-only"}
874819
branchName={"main"}
875820
queryName={"job_duration_percentile"}
876821
metricName={"duration_sec"}
877-
percentileParam={percentileParam}
822+
percentile={ttsPercentile}
878823
timeParams={timeParams}
879-
useClickHouse={useClickHouse}
880824
/>
881825

882826
<Grid item xs={6} height={ROW_HEIGHT}>
883827
<TablePanel
884828
title={"Failed Jobs Log Classifications"}
885829
queryName={"log_captures_count"}
886-
queryParams={timeParamsClickHouse}
830+
queryParams={timeParams}
887831
columns={[
888832
{ field: "num", headerName: "Count", flex: 1 },
889833
{ field: "example", headerName: "Example", flex: 4 },
@@ -912,7 +856,7 @@ export default function Page() {
912856
<TimeSeriesPanel
913857
title={"Number of new disabled tests"}
914858
queryName={"disabled_test_historical"}
915-
queryParams={{ ...timeParamsClickHouse, repo: "pytorch/pytorch" }}
859+
queryParams={{ ...timeParams, repo: "pytorch/pytorch" }}
916860
granularity={"day"}
917861
timeFieldName={"granularity_bucket"}
918862
yAxisFieldName={"number_of_new_disabled_tests"}
@@ -937,7 +881,7 @@ export default function Page() {
937881
<TimeSeriesPanel
938882
title={"LF vs Meta: Success rate delta"}
939883
queryName={"lf_rollover_health"}
940-
queryParams={{ ...timeParamsClickHouse, days_ago: timeRange }}
884+
queryParams={{ ...timeParams, days_ago: timeRange }}
941885
granularity={"day"}
942886
timeFieldName={"bucket"}
943887
yAxisLabel={"rate delta"}
@@ -951,7 +895,7 @@ export default function Page() {
951895
<TimeSeriesPanel
952896
title={"LF vs Meta: Cancelled rate delta"}
953897
queryName={"lf_rollover_health"}
954-
queryParams={{ ...timeParamsClickHouse, days_ago: timeRange }}
898+
queryParams={{ ...timeParams, days_ago: timeRange }}
955899
granularity={"day"}
956900
timeFieldName={"bucket"}
957901
yAxisLabel={"rate delta"}
@@ -965,7 +909,7 @@ export default function Page() {
965909
<TimeSeriesPanel
966910
title={"LF vs Meta: Duration increase ratio"}
967911
queryName={"lf_rollover_health"}
968-
queryParams={{ ...timeParamsClickHouse, days_ago: timeRange }}
912+
queryParams={{ ...timeParams, days_ago: timeRange }}
969913
granularity={"day"}
970914
timeFieldName={"bucket"}
971915
yAxisLabel="increase ratio"
@@ -978,7 +922,7 @@ export default function Page() {
978922
<TimeSeriesPanel
979923
title={"Percentage of jobs rolled over to Linux Foundation"}
980924
queryName={"lf_rollover_percentage"}
981-
queryParams={{ ...timeParamsClickHouse, days_ago: timeRange }}
925+
queryParams={{ ...timeParams, days_ago: timeRange }}
982926
granularity={"hour"}
983927
timeFieldName={"bucket"}
984928
yAxisFieldName={"percentage"}

0 commit comments

Comments
 (0)