Skip to content

Commit e3e4869

Browse files
authored
Fix list commit bug (#7470)
Fix list commit bug introduced by compiler
1 parent 5b1edd8 commit e3e4869

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

torchci/lib/benchmark/api_helper/backend/common/utils.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Utility to extract params from either GET or POST
22
import dayjs from "dayjs";
3+
import { queryClickhouseSaved } from "lib/clickhouse";
34
import { NextApiRequest } from "next";
45
import { BenchmarkCompilerListCommitQueryBuilder } from "../dataFetchers/queryBuilderUtils/compilerQueryBuilder";
56
import { CommitResult } from "./type";
@@ -380,19 +381,34 @@ function subsampleCommitsByDate(data: any[], maxCount: number | undefined) {
380381
};
381382
}
382383

383-
async function listCommitsFromDb(queryParams: any) {
384+
async function listCompilerCommitsFromDb(queryParams: any) {
384385
// fetch metadata from db
385386
const fetcher = new BenchmarkCompilerListCommitQueryBuilder();
386387
const data = await fetcher.applyQuery(queryParams);
387388
const result = fetcher.postProcess(data);
388389
return result;
389390
}
390391

391-
export async function getCommitsWithSampling(
392+
export async function listGeneralCommits(tableName: string, queryParams: any) {
393+
const commit_results = await queryClickhouseSaved(tableName, queryParams);
394+
let maxCount = undefined;
395+
// if subsampling is specified, use it
396+
if (queryParams.sampling) {
397+
maxCount = queryParams.sampling.max;
398+
const res = subsampleCommitsByDate(commit_results, maxCount);
399+
return res;
400+
}
401+
return {
402+
data: commit_results,
403+
is_sampled: false,
404+
};
405+
}
406+
407+
export async function getCompilerCommitsWithSampling(
392408
tableName: string,
393409
queryParams: any
394410
): Promise<CommitResult> {
395-
const commit_results = await listCommitsFromDb(queryParams);
411+
const commit_results = await listCompilerCommitsFromDb(queryParams);
396412
let maxCount = undefined;
397413
// if subsampling is specified, use it
398414
if (queryParams.sampling) {

torchci/lib/benchmark/api_helper/backend/compilers/compiler_benchmark_data.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from "../common/type";
66
import {
77
emptyTimeSeriesResponse,
8-
getCommitsWithSampling,
8+
getCompilerCommitsWithSampling,
99
} from "../common/utils";
1010
import { BenchmarkCompilerBenchmarkDataQueryBuilder } from "../dataFetchers/queryBuilderUtils/compilerQueryBuilder";
1111
import { extractBackendSqlStyle, toApiArch } from "./helpers/common";
@@ -63,7 +63,7 @@ export async function getCompilerCommits(
6363
if (!inputParams.startTime || !inputParams.stopTime) {
6464
throw new Error("no start/end time provided in request");
6565
}
66-
return await getCommitsWithSampling(
66+
return await getCompilerCommitsWithSampling(
6767
COMPILER_BENCHMARK_COMMITS_TABLE_NAME,
6868
inputParams
6969
);
@@ -91,7 +91,7 @@ export async function getCompilerBenchmarkTimeRangeQueryParams(
9191
);
9292
}
9393
if (!queryParams.workflows || queryParams.workflows.length == 0) {
94-
const { data: commit_results } = await getCommitsWithSampling(
94+
const { data: commit_results } = await getCompilerCommitsWithSampling(
9595
COMPILER_BENCHMARK_COMMITS_TABLE_NAME,
9696
queryParams
9797
);

torchci/lib/benchmark/api_helper/backend/list_commits.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CommitResult } from "./common/type";
2-
import { getCommitsWithSampling, groupByBenchmarkData } from "./common/utils";
2+
import { groupByBenchmarkData, listGeneralCommits } from "./common/utils";
33
import { getCompilerCommits } from "./compilers/compiler_benchmark_data";
44

55
const BENCHMARK_DEFAULT_LIST_COMMITS_QUERY_NAME =
@@ -62,7 +62,7 @@ async function getBenmarkCommits(
6262
case "compiler_precompute":
6363
return await getCompilerCommits(query_params);
6464
default:
65-
return await getCommits(query_params);
65+
return await getGeneralCommits(query_params);
6666
}
6767
}
6868

@@ -91,7 +91,7 @@ const defaultGetCommitsInputs: any = {
9191
mode: "",
9292
};
9393

94-
export async function getCommits(inputparams: any) {
94+
export async function getGeneralCommits(inputparams: any) {
9595
if (!inputparams.repo) {
9696
throw new Error("no repo provided in request");
9797
}
@@ -126,7 +126,7 @@ export async function getCommits(inputparams: any) {
126126
queryParams
127127
);
128128

129-
return await getCommitsWithSampling(
129+
return await listGeneralCommits(
130130
BENCHMARK_DEFAULT_LIST_COMMITS_QUERY_NAME,
131131
queryParams
132132
);

0 commit comments

Comments
 (0)