From 9162b96d2f48514b257ddb42714261e894e541b0 Mon Sep 17 00:00:00 2001 From: clee2000 <44682903+clee2000@users.noreply.github.com> Date: Fri, 3 Jan 2025 12:59:05 -0800 Subject: [PATCH] [ez][HUD] Remove rockset api route and utils files (#6132) Remove the rockset api route Remove the utils file for rockset in torchci Remove the TablePanelRS that got added for migration purposes --- .../metrics/panels/TablePanelRS.tsx | 123 ------------------ torchci/lib/rockset.ts | 16 --- .../api/query/[collection]/[lambdaName].ts | 32 ----- 3 files changed, 171 deletions(-) delete mode 100644 torchci/components/metrics/panels/TablePanelRS.tsx delete mode 100644 torchci/lib/rockset.ts delete mode 100644 torchci/pages/api/query/[collection]/[lambdaName].ts diff --git a/torchci/components/metrics/panels/TablePanelRS.tsx b/torchci/components/metrics/panels/TablePanelRS.tsx deleted file mode 100644 index b670be6440..0000000000 --- a/torchci/components/metrics/panels/TablePanelRS.tsx +++ /dev/null @@ -1,123 +0,0 @@ -/* -This file is an exact copy of TablePanel.tsx prior to moving it to only use -ClickHouse. After Jan 1 2025, this file will be deleted and all pages depending -on it will be broken. -*/ -import HelpIcon from "@mui/icons-material/Help"; -import { Skeleton, Typography } from "@mui/material"; -import IconButton from "@mui/material/IconButton"; -import { DataGrid, GridColDef } from "@mui/x-data-grid"; -import { RocksetParam } from "lib/rockset"; -import useSWR from "swr"; - -const fetcher = (url: string) => fetch(url).then((res) => res.json()); - -export default function TablePanel({ - // Human-readable title for this panel. - title, - // Query lambda collection in Rockset. - queryCollection = "metrics", - // Query lambda name in Rockset, ("metrics" collection is assumed). - queryName, - // Params to pass to the Rockset query. - queryParams, - // Column definitions for the data grid. - columns, - // Props to propagate to the data grid. - dataGridProps, - // An optional help link to display in the title - helpLink, - // An optional flag to show the table footer - showFooter, - useClickHouse = false, -}: { - title: string; - queryCollection?: string; - queryName: string; - queryParams: RocksetParam[] | {}; - columns: GridColDef[]; - dataGridProps: any; - helpLink?: string; - showFooter?: boolean; - useClickHouse?: boolean; -}) { - const url = useClickHouse - ? `/api/clickhouse/${queryName}?parameters=${encodeURIComponent( - JSON.stringify(queryParams) - )}` - : `/api/query/${queryCollection}/${queryName}?parameters=${encodeURIComponent( - JSON.stringify(queryParams) - )}`; - - const { data } = useSWR(url, fetcher, { - refreshInterval: 5 * 60 * 1000, // refresh every 5 minutes - }); - - return ( - - ); -} - -export function TablePanelWithData({ - // Human-readable title for this panel. - title, - // The raw data to display in the table - data, - // Column definitions for the data grid. - columns, - // Props to propagate to the data grid. - dataGridProps, - // An optional help link to display in the title - helpLink, - // An optional flag to show the table footer - showFooter, -}: { - title: string; - data: any; - columns: GridColDef[]; - dataGridProps: any; - helpLink?: string; - showFooter?: boolean; -}) { - if (data === undefined) { - return ; - } - - function helpLinkOnClick() { - window.open(helpLink, "_blank"); - } - - function Header() { - return ( - - {title}{" "} - {helpLink !== undefined && ( - - - - )} - - ); - } - - return ( - - ); -} diff --git a/torchci/lib/rockset.ts b/torchci/lib/rockset.ts deleted file mode 100644 index 064f753908..0000000000 --- a/torchci/lib/rockset.ts +++ /dev/null @@ -1,16 +0,0 @@ -import rockset, { MainApi } from "@rockset/client"; - -// Type for Rockset query lambda parameters. -export interface RocksetParam { - name: string; - // This is not complete, but we only really have string/int/float params atm. - type: "string" | "int" | "float" | "bool"; - value: any; -} - -export default function getRocksetClient(): MainApi { - if (typeof process.env.ROCKSET_API_KEY === "undefined") { - throw "ROCKSET_API_KEY is not defined, add it to your .env.local file"; - } - return rockset(process.env.ROCKSET_API_KEY); -} diff --git a/torchci/pages/api/query/[collection]/[lambdaName].ts b/torchci/pages/api/query/[collection]/[lambdaName].ts deleted file mode 100644 index eb8edfd895..0000000000 --- a/torchci/pages/api/query/[collection]/[lambdaName].ts +++ /dev/null @@ -1,32 +0,0 @@ -import getRocksetClient, { RocksetParam } from "lib/rockset"; -import type { NextApiRequest, NextApiResponse } from "next"; -import rocksetVersions from "rockset/prodVersions.json"; - -export const config = { - api: { - // TODO: Choose a higher limit than the 4mb default for compilers_benchmark_performance - // and then try to figure out how to make the results smaller later - responseLimit: "8mb", - }, -}; - -export default async function handler( - req: NextApiRequest, - res: NextApiResponse -) { - const collection = req.query.collection as string; - const lambdaName = req.query.lambdaName as string; - // @ts-expect-error - const version = rocksetVersions[collection][lambdaName]; - const parameters: RocksetParam[] = JSON.parse(req.query.parameters as string); - - const client = getRocksetClient(); - const response = await client.queryLambdas.executeQueryLambda( - collection, - lambdaName, - version, - { parameters } - ); - - res.status(200).json(response.results); -}