From 85e4c1005506ca58ab0d01a09193d14291efc6b5 Mon Sep 17 00:00:00 2001 From: clee2000 <44682903+clee2000@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:20:54 -0800 Subject: [PATCH] [ez] Fix revert printer after #4703 (#4727) Forgot about this one in https://github.com/pytorch/test-infra/pull/4703. Also change _event_time usage to created --- .github/workflows/revert-tracker.yml | 6 +++--- tools/torchci/reverts.py | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/revert-tracker.yml b/.github/workflows/revert-tracker.yml index 6efeec28e5..ae2fbdaee6 100644 --- a/.github/workflows/revert-tracker.yml +++ b/.github/workflows/revert-tracker.yml @@ -22,9 +22,9 @@ jobs: fetch-depth: 0 - id: generate-reverts-file run: | - cd test-infra + cd test-infra/tools python3 -m pip install rockset==1.0.3 - python3 -m torchci.scripts.reverts + python3 -m torchci.reverts echo "revert_file=$(cat revert_file_name.txt)" >> "${GITHUB_OUTPUT}" env: ROCKSET_API_KEY: ${{ secrets.ROCKSET_API_KEY }} @@ -35,7 +35,7 @@ jobs: env: API_TOKEN_GITHUB: ${{ secrets.GITHUB_TOKEN }} with: - source_file: test-infra/${{ steps.generate-reverts-file.outputs.revert_file }} + source_file: test-infra/tools/${{ steps.generate-reverts-file.outputs.revert_file }} destination_repo: "pytorch/test-infra" destination_folder: "reverts" destination_branch: generated-stats diff --git a/tools/torchci/reverts.py b/tools/torchci/reverts.py index 394024329b..1cb7e51d83 100644 --- a/tools/torchci/reverts.py +++ b/tools/torchci/reverts.py @@ -4,6 +4,7 @@ import re import shlex from collections import defaultdict +from pathlib import Path from typing import Dict, List, Optional, Tuple from rockset import RocksetClient # type: ignore[import] @@ -12,6 +13,8 @@ # Should match the contents produced by trymerge on revert RE_REVERT_COMMIT_BODY = r"Reverted .* on behalf of .* due to .* \(\[comment\]\((.*)\)\)" +REPO_ROOT = Path(__file__).resolve().parent.parent.parent + CLASSIFICATIONS = { "nosignal": "No Signal", "ignoredsignal": "Ignored Signal", @@ -23,7 +26,6 @@ ROCKSET_REVERT_QUERY = """ SELECT - ic._event_time revert_time, ic.user.login as reverter, ic.body, ic.html_url as comment_url @@ -34,8 +36,8 @@ ic.body, '@pytorch(merge|)bot +revert' ) - AND ic._event_time >= PARSE_TIMESTAMP_ISO8601(:startTime) - AND ic._event_time < PARSE_TIMESTAMP_ISO8601(:stopTime) + AND ic.created >= PARSE_TIMESTAMP_ISO8601(:startTime) + AND ic.created < PARSE_TIMESTAMP_ISO8601(:stopTime) AND ic.user.login != 'pytorch-bot[bot]' """ @@ -104,7 +106,7 @@ def get_rockset_reverts(start_time: str, end_time: str) -> Dict[str, Dict[str, s def get_gitlog_reverts(start_time: str, end_time: str) -> List[GitCommit]: - repo_path = "../pytorch" + repo_path = REPO_ROOT / ".." / "pytorch" remote = "origin" repo = GitRepo(repo_path, remote) all_commits = repo._run_git_log(