Skip to content

Commit baa135f

Browse files
authored
[HUD][CH] Move TimeSeriesPanel to only use CH (#6032)
This is part of an effort to remove all references to Rockset after the migration is finished. The torchci/pages/_githubrunnersutilization.tsx page has not yet been migrated, so I copied the old component into a new file to be used by that page. There's a lot of code duplication but this file will be deleted after jan 1 2025 and if this page still depends on it, I will leave the page broken
1 parent 3597d3b commit baa135f

File tree

8 files changed

+473
-199
lines changed

8 files changed

+473
-199
lines changed

torchci/components/metrics/panels/TimeSeriesPanel.tsx

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import utc from "dayjs/plugin/utc";
88
import { EChartsOption } from "echarts";
99
import ReactECharts from "echarts-for-react";
1010
import { fetcher } from "lib/GeneralUtils";
11-
import { RocksetParam } from "lib/rockset";
1211
import _ from "lodash";
1312
import useSWR from "swr";
1413
dayjs.extend(utc);
@@ -256,11 +255,9 @@ export function TimeSeriesPanelWithData({
256255
export default function TimeSeriesPanel({
257256
// Human-readable title of the panel.
258257
title,
259-
// Query lambda collection in Rockset.
260-
queryCollection = "metrics",
261-
// Query lambda name in Rockset.
258+
// Query name
262259
queryName,
263-
// Rockset query parameters
260+
// Query parameters
264261
queryParams,
265262
// Granularity of the time buckets.
266263
granularity,
@@ -279,7 +276,6 @@ export default function TimeSeriesPanel({
279276
yAxisLabel,
280277
// Additional EChartsOption (ex max y value)
281278
additionalOptions,
282-
useClickHouse = false,
283279
smooth = true,
284280
chartType = "line",
285281
sort_by = "name",
@@ -290,9 +286,8 @@ export default function TimeSeriesPanel({
290286
dataReader = undefined,
291287
}: {
292288
title: string;
293-
queryCollection?: string;
294289
queryName: string;
295-
queryParams: RocksetParam[] | {};
290+
queryParams: { [key: string]: any };
296291
granularity: Granularity;
297292
groupByFieldName?: string;
298293
timeFieldName: string;
@@ -301,7 +296,6 @@ export default function TimeSeriesPanel({
301296
yAxisRenderer: (_value: any) => string;
302297
yAxisLabel?: string;
303298
additionalOptions?: EChartsOption;
304-
useClickHouse?: boolean;
305299
smooth?: boolean;
306300
chartType?: ChartType;
307301
sort_by?: "total" | "name";
@@ -313,19 +307,12 @@ export default function TimeSeriesPanel({
313307
// - Granularity
314308
// - Group by
315309
// - Time field
316-
const url = useClickHouse
317-
? `/api/clickhouse/${queryName}?parameters=${encodeURIComponent(
318-
JSON.stringify({
319-
...(queryParams as {}),
320-
granularity: granularity as string,
321-
})
322-
)}`
323-
: `/api/query/${queryCollection}/${queryName}?parameters=${encodeURIComponent(
324-
JSON.stringify([
325-
...(queryParams as RocksetParam[]),
326-
{ name: "granularity", type: "string", value: granularity },
327-
])
328-
)}`;
310+
const url = `/api/clickhouse/${queryName}?parameters=${encodeURIComponent(
311+
JSON.stringify({
312+
...queryParams,
313+
granularity: granularity as string,
314+
})
315+
)}`;
329316

330317
const { data: rawData } = useSWR(url, fetcher, {
331318
refreshInterval: auto_refresh ? 5 * 60 * 1000 : 0,
@@ -336,21 +323,11 @@ export default function TimeSeriesPanel({
336323
}
337324
const data = dataReader ? dataReader(rawData) : rawData;
338325

339-
let startTime, stopTime;
340-
if (useClickHouse) {
341-
startTime = (queryParams as any)["startTime"];
342-
stopTime = (queryParams as any)["stopTime"];
343-
} else {
344-
startTime = (queryParams as RocksetParam[]).find(
345-
(p) => p.name === "startTime"
346-
)?.value;
347-
stopTime = (queryParams as RocksetParam[]).find(
348-
(p) => p.name === "stopTime"
349-
)?.value;
350-
}
326+
let startTime = queryParams["startTime"];
327+
let stopTime = queryParams["stopTime"];
351328

352329
// Clamp to the nearest granularity (e.g. nearest hour) so that the times will
353-
// align with the data we get from Rockset
330+
// align with the data we get from the database
354331
startTime = dayjs.utc(startTime).startOf(granularity);
355332
stopTime = dayjs.utc(stopTime).endOf(granularity);
356333

0 commit comments

Comments
 (0)