Skip to content

Commit

Permalink
[ch][kpis] TTS chart (#5686)
Browse files Browse the repository at this point in the history
* Add CH query for TTS chart, works with rs/ch toggle button
* CH date_trunc('week') truncates to monday, but toStartOfWeek can let
you choose which day to truncate to. The second keeps the results the
same, but date_trunc lets you choose granularities better. For parity
with RS, I am putting this query to trunc to sunday, but we might want
to change this later
  • Loading branch information
clee2000 authored Sep 26, 2024
1 parent 616ee5d commit 97c0543
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
22 changes: 11 additions & 11 deletions torchci/clickhouse_queries/time_to_signal/query.sql
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
-- !!! Query is not converted to CH syntax yet. Delete this line when it gets converted
with
tts as (
SELECT
MAX(
DATE_DIFF(
'second',
PARSE_TIMESTAMP_ISO8601(w.created_at),
PARSE_TIMESTAMP_ISO8601(w.updated_at)
w.created_at,
w.updated_at
)
) as duration_sec,
w.head_sha,
ARBITRARY(IF(w.head_branch = 'main', 'main', 'not main')) as branch,
MIN(PARSE_TIMESTAMP_ISO8601(w.created_at)) as created_at
any(IF(w.head_branch = 'main', 'main', 'not main')) as branch,
MIN(w.created_at) as created_at
FROM
commons.workflow_run w
default.workflow_run w final
WHERE
ARRAY_CONTAINS(['pull', 'trunk'], LOWER(w.name))
AND PARSE_TIMESTAMP_ISO8601(w.created_at) >= PARSE_DATETIME_ISO8601(:startTime)
lower(w.name) in ['pull', 'trunk']
AND w.created_at >= {startTime: DateTime64(3)}
AND w.head_repository.full_name = 'pytorch/pytorch'
and w.id in (select id from materialized_views.workflow_run_by_created_at where created_at >= {startTime: DateTime64})
group by
w.head_sha
having
bool_and(
min(
w.conclusion = 'success'
and w.run_attempt = 1
)
) = 1
)
select
CAST(DATE_TRUNC('week', t.created_at) as string) AS week_bucket,
toStartOfWeek(t.created_at, 0) AS week_bucket,
avg(t.duration_sec / 3600.0) as avg_tts,
t.branch
from
Expand Down
15 changes: 7 additions & 8 deletions torchci/pages/kpis.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Grid } from "@mui/material";
import TimeSeriesPanel from "components/metrics/panels/TimeSeriesPanel";
import { useCHContext } from "components/UseClickhouseProvider";
import dayjs from "dayjs";
import { RocksetParam } from "lib/rockset";
import { useState } from "react";
import { RStoCHTimeParams } from "./metrics";

const ROW_HEIGHT = 240;

Expand All @@ -24,6 +26,9 @@ export default function Kpis() {
},
];

const clickhouseTimeParams = RStoCHTimeParams(timeParams);
const useCH = useCHContext().useCH;

// deprecate this in Q3 2023
const contributionTimeParams: RocksetParam[] = [
{
Expand Down Expand Up @@ -104,20 +109,14 @@ export default function Kpis() {
title={"Avg time-to-signal - E2E (Weekly)"}
queryName={"time_to_signal"}
queryCollection={"pytorch_dev_infra_kpis"}
queryParams={[
{
name: "buildOrAll",
type: "string",
value: "all",
},
...timeParams,
]}
queryParams={useCH ? clickhouseTimeParams : timeParams}
granularity={"week"}
timeFieldName={"week_bucket"}
yAxisFieldName={"avg_tts"}
yAxisLabel={"Hours"}
yAxisRenderer={(unit) => `${unit}`}
groupByFieldName="branch"
useClickHouse={useCH}
/>
</Grid>

Expand Down
2 changes: 1 addition & 1 deletion torchci/pages/metrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ function JobsDuration({

const ROW_HEIGHT = 375;

function RStoCHTimeParams(params: RocksetParam[]) {
export function RStoCHTimeParams(params: RocksetParam[]) {
return {
startTime: params
.find((p) => p.name === "startTime")
Expand Down

0 comments on commit 97c0543

Please sign in to comment.