|
8 | 8 | TEST_TIMES_URL = "https://raw.githubusercontent.com/pytorch/test-infra/generated-stats/stats/test-times.json" |
9 | 9 | TEST_CLASS_TIMES_URL = "https://raw.githubusercontent.com/pytorch/test-infra/generated-stats/stats/test-class-times.json" |
10 | 10 |
|
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" |
15 | 16 |
|
16 | 17 |
|
17 | 18 | def get_file_data_from_db(): |
@@ -77,6 +78,18 @@ def convert_test_class_times_to_default_dict(d): |
77 | 78 | return new_d |
78 | 79 |
|
79 | 80 |
|
| 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 | + |
80 | 93 | def gen_test_file_times(db_results, old_test_times): |
81 | 94 | # Use old test times because sometimes we want to manually edit the test |
82 | 95 | # 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): |
108 | 121 | # usually in the default test config like distributed |
109 | 122 | test_times["default"]["default"] = test_times_no_test_config |
110 | 123 |
|
| 124 | + clean_up_test_times(test_times) |
| 125 | + |
111 | 126 | return test_times |
112 | 127 |
|
113 | 128 |
|
@@ -153,6 +168,8 @@ def gen_test_class_times(db_results, old_test_times): |
153 | 168 | # usually in the default test config like distributed |
154 | 169 | test_times["default"]["default"] = test_times_no_test_config |
155 | 170 |
|
| 171 | + clean_up_test_times(test_times) |
| 172 | + |
156 | 173 | return test_times |
157 | 174 |
|
158 | 175 |
|
|
0 commit comments