From d1082bbaea7c1b9792dd039b906a2c4282347d70 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Fri, 17 Oct 2025 15:03:55 -0700 Subject: [PATCH 1/2] tc --- .../workflows/update_test_file_ratings.yml | 15 +++++++++ tools/torchci/td/get_all_test_names.py | 32 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tools/torchci/td/get_all_test_names.py diff --git a/.github/workflows/update_test_file_ratings.yml b/.github/workflows/update_test_file_ratings.yml index e3321663bb..7704fda752 100644 --- a/.github/workflows/update_test_file_ratings.yml +++ b/.github/workflows/update_test_file_ratings.yml @@ -55,6 +55,7 @@ jobs: python3 test-infra/tools/torchci/td/historical_file_failure_correlation.py python3 test-infra/tools/torchci/td/historical_class_failure_correlation.py python3 test-infra/tools/torchci/td/td_heuristic_historical_edited_files.py + python3 test-infra/tools/torchci/td/get_all_test_names.py # Do not run this one, it won't change # python3 test-infra/tools/torchci/td/td_heuristic_profiling.py @@ -104,3 +105,17 @@ jobs: user_email: "test-infra@pytorch.org" user_name: "Pytorch Test Infra" commit_message: "Updating TD heuristic: historical edited files" + + - name: Push historical edited files heuristic to test-infra repository + if: github.event_name != 'pull_request' + uses: dmnemec/copy_file_to_another_repo_action@eebb594efdf52bc12e1b461988d7254322dac131 + env: + API_TOKEN_GITHUB: ${{ secrets.GITHUB_TOKEN }} + with: + source_file: "td_all_tests.json" + destination_repo: "pytorch/test-infra" + destination_folder: "stats" + destination_branch: generated-stats + user_email: "test-infra@pytorch.org" + user_name: "Pytorch Test Infra" + commit_message: "Updating TD heuristic: historical edited files" diff --git a/tools/torchci/td/get_all_test_names.py b/tools/torchci/td/get_all_test_names.py new file mode 100644 index 0000000000..3a0efa6c72 --- /dev/null +++ b/tools/torchci/td/get_all_test_names.py @@ -0,0 +1,32 @@ +import json + +from torchci.clickhouse import query_clickhouse + +ALL_TESTS_QUERY = """ +SELECT + name, + classname, + invoking_file +FROM ( + SELECT + name, + classname, + invoking_file, + maxMerge(last_run) AS last_run + FROM tests.distinct_names + GROUP BY name, classname, invoking_file +) +WHERE last_run > now() - INTERVAL 1 WEEK +""" + + +if __name__ == "__main__": + all_tests = query_clickhouse( + ALL_TESTS_QUERY, {} + ) + for test in all_tests: + test["file"] = test["invoking_file"].replace(".", "/") + ".py" + del test["invoking_file"] + + with open("td_all_tests.json", mode="w") as file: + json.dump(all_tests, file, sort_keys=True, indent=2) From 347c29d95413725c7d980fedcebcd72813dbdd35 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Fri, 17 Oct 2025 15:04:16 -0700 Subject: [PATCH 2/2] tc --- tools/torchci/td/get_all_test_names.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/torchci/td/get_all_test_names.py b/tools/torchci/td/get_all_test_names.py index 3a0efa6c72..da19d1203a 100644 --- a/tools/torchci/td/get_all_test_names.py +++ b/tools/torchci/td/get_all_test_names.py @@ -2,6 +2,7 @@ from torchci.clickhouse import query_clickhouse + ALL_TESTS_QUERY = """ SELECT name, @@ -21,9 +22,7 @@ if __name__ == "__main__": - all_tests = query_clickhouse( - ALL_TESTS_QUERY, {} - ) + all_tests = query_clickhouse(ALL_TESTS_QUERY, {}) for test in all_tests: test["file"] = test["invoking_file"].replace(".", "/") + ".py" del test["invoking_file"]