Skip to content

Commit f8430fb

Browse files
author
Catherine Lee
committed
tc
1 parent e085fb7 commit f8430fb

11 files changed

Lines changed: 30 additions & 4 deletions

File tree

tools/torchci/update_test_times.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
TEST_TIMES_URL = "https://raw.githubusercontent.com/pytorch/test-infra/generated-stats/stats/test-times.json"
99
TEST_CLASS_TIMES_URL = "https://raw.githubusercontent.com/pytorch/test-infra/generated-stats/stats/test-class-times.json"
1010

11-
TEST_TIME_PER_FILE_QUERY_NAME = "test_time_per_file"
12-
TEST_TIME_PER_FILE_PERIODIC_JOBS_QUERY_NAME = "test_time_per_file_periodic_jobs"
13-
TEST_TIME_PER_CLASS_QUERY_NAME = "test_time_per_class"
14-
TEST_TIME_PER_CLASS_PERIODIC_JOBS_QUERY_NAME = "test_time_per_class_periodic_jobs"
11+
TEST_TIME_PER_FILE_QUERY_NAME = "test_times/per_file"
12+
TEST_TIME_PER_FILE_PERIODIC_JOBS_QUERY_NAME = "test_times/per_file_periodic_jobs"
13+
TEST_TIME_PER_CLASS_QUERY_NAME = "test_times/per_class"
14+
TEST_TIME_PER_CLASS_PERIODIC_JOBS_QUERY_NAME = "test_times/per_class_periodic_jobs"
15+
JOB_NAMES_PAST_MONTH_QUERY_NAME = "test_times/job_names_past_month"
1516

1617

1718
def get_file_data_from_db():
@@ -77,6 +78,18 @@ def convert_test_class_times_to_default_dict(d):
7778
return new_d
7879

7980

81+
def clean_up_test_times(test_times) -> None:
82+
# Remove old environments that no longer run jobs
83+
job_names_past_month = query_clickhouse_saved(
84+
JOB_NAMES_PAST_MONTH_QUERY_NAME, {}
85+
)
86+
job_names = {row["base_name"] for row in job_names_past_month}
87+
job_names.add("default") # Add default to job names
88+
for env in list(test_times.keys()):
89+
if env not in job_names:
90+
del test_times[env]
91+
92+
8093
def gen_test_file_times(db_results, old_test_times):
8194
# Use old test times because sometimes we want to manually edit the test
8295
# times json and want those changes to persist. Unfortunately this means
@@ -108,6 +121,8 @@ def gen_test_file_times(db_results, old_test_times):
108121
# usually in the default test config like distributed
109122
test_times["default"]["default"] = test_times_no_test_config
110123

124+
clean_up_test_times(test_times)
125+
111126
return test_times
112127

113128

@@ -153,6 +168,8 @@ def gen_test_class_times(db_results, old_test_times):
153168
# usually in the default test config like distributed
154169
test_times["default"]["default"] = test_times_no_test_config
155170

171+
clean_up_test_times(test_times)
172+
156173
return test_times
157174

158175

torchci/clickhouse_queries/test_time_per_class/params.json renamed to torchci/clickhouse_queries/test_times/job_names_past_month/params.json

File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT DISTINCT
2+
REGEXP_EXTRACT(j.name, '^(.*) /', 1) AS base_name
3+
FROM
4+
default.workflow_job j
5+
WHERE j.created_at > now() - INTERVAL 1 MONTH

torchci/clickhouse_queries/test_time_per_class_periodic_jobs/params.json renamed to torchci/clickhouse_queries/test_times/per_class/params.json

File renamed without changes.

torchci/clickhouse_queries/test_time_per_class/query.sql renamed to torchci/clickhouse_queries/test_times/per_class/query.sql

File renamed without changes.

torchci/clickhouse_queries/test_time_per_file/params.json renamed to torchci/clickhouse_queries/test_times/per_class_periodic_jobs/params.json

File renamed without changes.

torchci/clickhouse_queries/test_time_per_class_periodic_jobs/query.sql renamed to torchci/clickhouse_queries/test_times/per_class_periodic_jobs/query.sql

File renamed without changes.

torchci/clickhouse_queries/test_time_per_file_periodic_jobs/params.json renamed to torchci/clickhouse_queries/test_times/per_file/params.json

File renamed without changes.

torchci/clickhouse_queries/test_time_per_file/query.sql renamed to torchci/clickhouse_queries/test_times/per_file/query.sql

File renamed without changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"params": {},
3+
"tests": [{}]
4+
}

0 commit comments

Comments
 (0)