Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ export class BenchmarkDataQuery extends ExecutableQueryBase {
private _extra_keys = new Set<string>();

DEFAULT_PARAMS = {
arch: "",
mode: "",
device: "",
branches: [],
backends: [],
devices: [],
arches: [],
dtypes: [],
modes: [],
granularity: "hour",
excludedMetrics: [],
models: [],
branches: [],
workflows: [],
backends: [],
dtypes: [],
};

// must included in all select statement
Expand Down Expand Up @@ -169,8 +169,8 @@ export class BenchmarkDataQuery extends ExecutableQueryBase {
OR empty({backends: Array(String) })
)
AND (
o.benchmark.'mode' = {mode: String }
OR {mode: String } = ''
has({modes: Array(String) }, o.benchmark.'mode')
OR empty({modes: Array(String) })
)
AND (
has({dtypes: Array(String) }, o.benchmark.'dtype')
Expand Down Expand Up @@ -222,9 +222,9 @@ export class BenchmarkDataQuery extends ExecutableQueryBase {
startsWith({device: String }, device)
OR {device: String } = ''
)
AND (
arch LIKE concat('%', {arch: String }, '%')
OR {arch: String } = ''
AND (
multiSearchAnyCaseInsensitive(arch, {arches: Array(String)})
OR empty({arches: Array(String)})
)
{{WHERE}}
ORDER BY
Expand Down Expand Up @@ -356,14 +356,23 @@ export class BenchmarkDataQuery extends ExecutableQueryBase {
inputs.dtypes = [inputs.dtype];
}

if (inputs.mode && !inputs.modes) {
inputs.modes = [inputs.mode];
}
if (inputs.model && !inputs.models) {
inputs.models = [inputs.model];
}
if (inputs.branch && !inputs.branches) {
inputs.branches = [inputs.branch];
}

if (inputs.arch && !inputs.arches) {
inputs.arches = [inputs.arch];
}

const params = { ...this.DEFAULT_PARAMS, ...inputs };

console.log("[benchmarkDatQueryBuilder] query calls to db:", params);
return params;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ export class BenchmarkListCommitQueryBuilder
private _DEFAULT_QUERY_PARAMS = {
branches: [],
devices: [],
arch: [],
arches: [],
dtypes: [],
modes: [],
backends: [],
startTime: "",
stopTime: "",
};
Expand Down Expand Up @@ -58,15 +59,17 @@ WHERE
has({backends: Array(String)}, model_backend)
OR empty({backends: Array(String)})
)
AND notEmpty(device)
AND (benchmark_dtype = {dtype: String} OR empty({dtype: String}))
AND (
arch LIKE concat('%', {arch: String}, '%')
OR {arch: String} = ''
has({dtypes: Array(String) },benchmark_dtype)
OR empty({dtypes: Array(String) })
)
AND (
startsWith(device, {device: String})
OR {device: String} = ''
multiSearchAnyCaseInsensitive(arch, {arches: Array(String)})
OR empty({arches: Array(String)})
)
AND (
has({devices: Array(String)}, device)
OR empty({devices: Array(String) })
)
{{WHERE}}
GROUP BY
Expand All @@ -83,15 +86,42 @@ ORDER BY
build() {
return this.builder.build();
}

addWhere(where: string[]) {
this.builder.addWhere(where);
}

toQueryParams(inputs: any, id?: string) {
return {
if (inputs.backend && !inputs.backends) {
inputs.backends = [inputs.backend];
}

if (inputs.dtype && !inputs.dtypes) {
inputs.dtypes = [inputs.dtype];
}

if (inputs.model && !inputs.models) {
inputs.models = [inputs.model];
}
if (inputs.branch && !inputs.branches) {
inputs.branches = [inputs.branch];
}

if (inputs.arch && !inputs.arches) {
inputs.arches = [inputs.arch];
}

if (inputs.device && !inputs.devices) {
inputs.devices = [inputs.device];
}

const params = {
...this._DEFAULT_QUERY_PARAMS,
...inputs,
};

console.log("[listCommitQueryBuilder] query calls to db:", params);
return params;
}
postProcess(data: any) {
return data;
Expand Down
39 changes: 38 additions & 1 deletion torchci/pages/api/benchmark/get_time_series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CompilerQueryType } from "lib/benchmark/api_helper/backend/common/type"
import { readApiGetParams } from "lib/benchmark/api_helper/backend/common/utils";
import { getCompilerBenchmarkTimeSeriesData } from "lib/benchmark/api_helper/backend/compilers/compiler_benchmark_data";
import { getBenchmarkDataFetcher } from "lib/benchmark/api_helper/backend/dataFetchers/fetchers";
import { getGeneralCommits } from "lib/benchmark/api_helper/backend/list_commits";
import type { NextApiRequest, NextApiResponse } from "next";

/**
Expand Down Expand Up @@ -101,7 +102,43 @@ async function getGenernalBenchmarkTimeSeries(
formats: string[],
id: string
) {
const params = await getGeneralBenchmarkTimeRangeQueryParams(
id,
query_params
);

const fetcher = getBenchmarkDataFetcher(id);
const result = await fetcher.applyQuery(query_params);
const result = await fetcher.applyQuery(params);
return fetcher.applyFormat(result, formats);
}

export async function getGeneralBenchmarkTimeRangeQueryParams(
id: string,
inputparams: any
) {
const queryParams = {
...inputparams, // override with caller's values
};

if (!queryParams.workflows || queryParams.workflows.length == 0) {
const { data: commit_results } = await getGeneralCommits(id, queryParams);
const unique_workflows = [
...new Set(commit_results.map((c: any) => c.workflow_id)),
];
console.log(
`no workflows provided in request, searched unqiue workflows based on
start/end time unique_workflows: ${unique_workflows.length}`
);
if (commit_results.length > 0) {
queryParams["workflows"] = unique_workflows;
} else {
console.log(`no workflow found in clickhouse using ${queryParams}`);
return [];
}
} else {
console.log(
`input provided workflows found using ${queryParams.workflows}`
);
}
return queryParams;
}