diff --git a/torchci/components/benchmark/llms/ModelGraphPanel.tsx b/torchci/components/benchmark/llms/ModelGraphPanel.tsx index a5b923738e..03ee38c75c 100644 --- a/torchci/components/benchmark/llms/ModelGraphPanel.tsx +++ b/torchci/components/benchmark/llms/ModelGraphPanel.tsx @@ -19,7 +19,6 @@ import { } from "components/metrics/panels/TimeSeriesPanel"; import dayjs from "dayjs"; import { useBenchmark } from "lib/benchmark/llmUtils"; -import { RocksetParam } from "lib/rockset"; import { BranchAndCommit } from "lib/types"; const GRAPH_ROW_HEIGHT = 245; @@ -33,9 +32,8 @@ export function GraphPanel({ metricNames, lBranchAndCommit, rBranchAndCommit, - useClickHouse, }: { - queryParams: RocksetParam[] | {}; + queryParams: { [key: string]: any }; granularity: Granularity; modelName: string; dtypeName: string; @@ -43,7 +41,6 @@ export function GraphPanel({ metricNames: string[]; lBranchAndCommit: BranchAndCommit; rBranchAndCommit: BranchAndCommit; - useClickHouse: boolean; }) { // Do not set the commit here to query all the records in the time range to // draw a chart @@ -55,8 +52,7 @@ export function GraphPanel({ { branch: rBranchAndCommit.branch, commit: "", - }, - useClickHouse + } ); if (data === undefined || data.length === 0) { @@ -75,22 +71,12 @@ export function GraphPanel({ // Clamp to the nearest granularity (e.g. nearest hour) so that the times will // align with the data we get from the database - const startTime = useClickHouse - ? dayjs((queryParams as { [key: string]: any })["startTime"]).startOf( - granularity - ) - : dayjs( - (queryParams as RocksetParam[]).find((p) => p.name === "startTime") - ?.value - ).startOf(granularity); - const stopTime = useClickHouse - ? dayjs((queryParams as { [key: string]: any })["stopTime"]).startOf( - granularity - ) - : dayjs( - (queryParams as RocksetParam[]).find((p) => p.name === "stopTime") - ?.value - ).startOf(granularity); + const startTime = dayjs( + (queryParams as { [key: string]: any })["startTime"] + ).startOf(granularity); + const stopTime = dayjs( + (queryParams as { [key: string]: any })["stopTime"] + ).startOf(granularity); // Only show records between these twos const lWorkflowId = COMMIT_TO_WORKFLOW_ID[lBranchAndCommit.commit]; diff --git a/torchci/lib/benchmark/llmUtils.ts b/torchci/lib/benchmark/llmUtils.ts index 03034913f0..fbdc4e22a0 100644 --- a/torchci/lib/benchmark/llmUtils.ts +++ b/torchci/lib/benchmark/llmUtils.ts @@ -3,71 +3,34 @@ import { LLMsBenchmarkData, } from "components/benchmark/llms/common"; import { fetcher } from "lib/GeneralUtils"; -import { RocksetParam } from "lib/rockset"; import { BranchAndCommit } from "lib/types"; import useSWR from "swr"; export function useBenchmark( - queryParams: RocksetParam[] | {}, + queryParams: { [key: string]: any }, modelName: string, dtypeName: string, deviceName: string, branchAndCommit: BranchAndCommit, - useClickHouse: boolean = false, getJobId: boolean = false ) { const queryCollection = "benchmarks"; const queryName = "oss_ci_benchmark_llms"; - const queryParamsWithBranchAndCommit: - | RocksetParam[] - | { [key: string]: any } = useClickHouse - ? { - getJobId: getJobId, - ...queryParams, - } - : [ - { - name: "getJobId", - type: "bool", - value: getJobId, - }, - ...(queryParams as RocksetParam[]), - ]; - - if (useClickHouse) { - (queryParamsWithBranchAndCommit as { [key: string]: any })["branches"] = - branchAndCommit.branch ? [branchAndCommit.branch] : []; - } else { - if (branchAndCommit.branch) { - queryParamsWithBranchAndCommit.push({ - name: "branches", - type: "string", - value: branchAndCommit.branch, - }); - } - } + const queryParamsWithBranchAndCommit: { [key: string]: any } = { + getJobId: getJobId, + ...queryParams, + }; - if (useClickHouse) { - (queryParamsWithBranchAndCommit as { [key: string]: any })["commits"] = - branchAndCommit.commit ? [branchAndCommit.commit] : []; - } else { - if (branchAndCommit.commit) { - queryParamsWithBranchAndCommit.push({ - name: "commits", - type: "string", - value: branchAndCommit.commit, - }); - } - } + (queryParamsWithBranchAndCommit as { [key: string]: any })["branches"] = + branchAndCommit.branch ? [branchAndCommit.branch] : []; + + (queryParamsWithBranchAndCommit as { [key: string]: any })["commits"] = + branchAndCommit.commit ? [branchAndCommit.commit] : []; - const url = useClickHouse - ? `/api/clickhouse/${queryName}?parameters=${encodeURIComponent( - JSON.stringify(queryParamsWithBranchAndCommit) - )}` - : `/api/query/${queryCollection}/${queryName}?parameters=${encodeURIComponent( - JSON.stringify(queryParamsWithBranchAndCommit) - )}`; + const url = `/api/clickhouse/${queryName}?parameters=${encodeURIComponent( + JSON.stringify(queryParamsWithBranchAndCommit) + )}`; return useSWR(url, fetcher, { refreshInterval: 60 * 60 * 1000, // refresh every hour diff --git a/torchci/pages/benchmark/llms.tsx b/torchci/pages/benchmark/llms.tsx index 54b8aeec91..6bdcfc0ac0 100644 --- a/torchci/pages/benchmark/llms.tsx +++ b/torchci/pages/benchmark/llms.tsx @@ -19,17 +19,15 @@ import { DTypePicker } from "components/benchmark/ModeAndDTypePicker"; import CopyLink from "components/CopyLink"; import GranularityPicker from "components/GranularityPicker"; import { Granularity } from "components/metrics/panels/TimeSeriesPanel"; -import { useCHContext } from "components/UseClickhouseProvider"; import dayjs from "dayjs"; import { useBenchmark } from "lib/benchmark/llmUtils"; import { fetcher } from "lib/GeneralUtils"; -import { RocksetParam } from "lib/rockset"; import { BranchAndCommit } from "lib/types"; import _ from "lodash"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; import useSWR from "swr"; -import { RStoCHTimeParams, TimeRangePicker } from "../metrics"; +import { TimeRangePicker } from "../metrics"; function Report({ queryParams, @@ -43,9 +41,8 @@ function Report({ metricNames, lBranchAndCommit, rBranchAndCommit, - useClickHouse, }: { - queryParams: RocksetParam[] | {}; + queryParams: { [key: string]: any }; startTime: dayjs.Dayjs; stopTime: dayjs.Dayjs; granularity: Granularity; @@ -56,7 +53,6 @@ function Report({ metricNames: string[]; lBranchAndCommit: BranchAndCommit; rBranchAndCommit: BranchAndCommit; - useClickHouse: boolean; }) { const { data: lData, error: _lError } = useBenchmark( queryParams, @@ -64,7 +60,6 @@ function Report({ dtypeName, deviceName, lBranchAndCommit, - useClickHouse, true ); const { data: rData, error: _rError } = useBenchmark( @@ -73,7 +68,6 @@ function Report({ dtypeName, deviceName, rBranchAndCommit, - useClickHouse, true ); @@ -123,7 +117,6 @@ function Report({ metricNames={metricNames} lBranchAndCommit={lBranchAndCommit} rBranchAndCommit={rBranchAndCommit} - useClickHouse={useClickHouse} /> (DEFAULT_DTYPE_NAME); const [deviceName, setDeviceName] = useState(DEFAULT_DEVICE_NAME); - // TODO (huydhn): Clean this up once ClickHouse migration finishes - const { useCH: useClickHouse } = useCHContext(); - // Set the dropdown value what is in the param useEffect(() => { const startTime: string = (router.query.startTime as string) ?? undefined; @@ -242,60 +232,7 @@ export default function Page() { const queryCollection = "benchmarks"; const queryName = "oss_ci_benchmark_names"; - - const timeParams: RocksetParam[] = [ - { - name: "startTime", - type: "string", - value: startTime, - }, - { - name: "stopTime", - type: "string", - value: stopTime, - }, - ]; - const timeParamsClickHouse = RStoCHTimeParams(timeParams); - - const queryParams: RocksetParam[] = [ - { - name: "deviceArch", - type: "string", - value: deviceName === DEFAULT_DEVICE_NAME ? "" : deviceName, - }, - { - name: "dtypes", - type: "string", - value: dtypeName === DEFAULT_DTYPE_NAME ? "" : dtypeName, - }, - { - name: "excludedMetrics", - type: "string", - value: EXCLUDED_METRICS.join(","), - }, - { - name: "filenames", - type: "string", - value: REPO_TO_BENCHMARKS[repoName].join(","), - }, - { - name: "granularity", - type: "string", - value: granularity, - }, - { - name: "names", - type: "string", - value: modelName === DEFAULT_MODEL_NAME ? "" : modelName, - }, - { - name: "repo", - type: "string", - value: repoName, - }, - ...timeParams, - ]; - const queryParamsClickHouse = { + const queryParams = { deviceArch: deviceName === DEFAULT_DEVICE_NAME ? "" : deviceName, dtypes: dtypeName === DEFAULT_DTYPE_NAME ? [] : [dtypeName], excludedMetrics: EXCLUDED_METRICS, @@ -303,16 +240,13 @@ export default function Page() { granularity: granularity, names: modelName === DEFAULT_MODEL_NAME ? [] : [modelName], repo: repoName, - ...timeParamsClickHouse, + startTime: dayjs(startTime).utc().format("YYYY-MM-DDTHH:mm:ss.SSS"), + stopTime: dayjs(stopTime).utc().format("YYYY-MM-DDTHH:mm:ss.SSS"), }; - const url = useClickHouse - ? `/api/clickhouse/${queryName}?parameters=${encodeURIComponent( - JSON.stringify(queryParamsClickHouse) - )}` - : `/api/query/${queryCollection}/${queryName}?parameters=${encodeURIComponent( - JSON.stringify(queryParams) - )}`; + const url = `/api/clickhouse/${queryName}?parameters=${encodeURIComponent( + JSON.stringify(queryParams) + )}`; const { data } = useSWR(url, fetcher, { refreshInterval: 60 * 60 * 1000, // refresh every hour @@ -391,7 +325,7 @@ export default function Page() { —Diff→ @@ -407,7 +341,7 @@ export default function Page() { );