Skip to content

Commit 50d017c

Browse files
committed
20250814193153
1 parent 076105a commit 50d017c

7 files changed

Lines changed: 17 additions & 46 deletions

File tree

aws/lambda/pytorch-auto-revert/pytorch_auto_revert/__main__.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from .clickhouse_client_helper import CHCliFactory
1111
from .github_client_helper import GHClientFactory
1212
from .testers.autorevert import autorevert_checker
13-
from .testers.do_restart import do_restart_workflow
1413
from .testers.restart_checker import workflow_restart_checker
1514

1615

@@ -65,7 +64,7 @@ def get_opts() -> argparse.Namespace:
6564
parser.add_argument(
6665
"--dry-run",
6766
action="store_true",
68-
help="Show what would be restarted without actually doing it (use with --do-restart)",
67+
help="Show what would be restarted without actually doing it",
6968
)
7069

7170
# no subcommand runs the lambda flow
@@ -125,19 +124,6 @@ def get_opts() -> argparse.Namespace:
125124
help="If no `--commit` specified, look back days for bulk query (default: 7)",
126125
)
127126

128-
# do-restart subcommand
129-
do_restart_parser = subparsers.add_parser(
130-
"do-restart", help="Restart a workflow for a specific commit"
131-
)
132-
do_restart_parser.add_argument(
133-
"workflow",
134-
help="Workflow file name to restart (e.g., trunk.yml)",
135-
)
136-
do_restart_parser.add_argument(
137-
"commit",
138-
help="Commit SHA to restart the workflow for",
139-
)
140-
141127
return parser.parse_args()
142128

143129

@@ -191,8 +177,6 @@ def main(*args, **kwargs) -> None:
191177
)
192178
elif opts.subcommand == "workflow-restart-checker":
193179
workflow_restart_checker(opts.workflow, commit=opts.commit, days=opts.days)
194-
elif opts.subcommand == "do-restart":
195-
do_restart_workflow(opts.workflow, commit=opts.commit)
196180

197181

198182
if __name__ == "__main__":

aws/lambda/pytorch-auto-revert/pytorch_auto_revert/autorevert_checker.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ def has_pending_jobs(self) -> bool:
4545
"""Check if any jobs are not yet completed (queued/in_progress)."""
4646
return any(j.status != "completed" for j in self.jobs)
4747

48-
@property
48+
@cached_property
4949
def job_base_names(self) -> Set[str]:
50-
if not hasattr(self, "_job_base_names"):
51-
self._job_base_names = self.get_job_base_names()
52-
return self._job_base_names
50+
return self.get_job_base_names()
5351

5452
def normalize_job_name(self, name: str) -> str:
5553
"""Normalize job name to a stable base for matching across commits.
@@ -100,7 +98,6 @@ def workflow_commits(self) -> List[CommitJobs]:
10098

10199
@cached_property
102100
def commit_history(self) -> List[Dict]:
103-
"""Get commit history, fetching if needed."""
104101
return self._fetch_commit_history()
105102

106103
@cached_property

aws/lambda/pytorch-auto-revert/pytorch_auto_revert/testers/autorevert.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,8 @@ def autorevert_checker(
116116

117117
# For clarity in naming
118118
workflow_name = pattern["workflow_name"]
119-
first_failing = pattern["newer_commits"][
120-
1
121-
] # the older of the two failing commits
122-
previous_commit = pattern[
123-
"older_commit"
124-
] # previously successful commit for the matched job
119+
first_failing = pattern["newer_commits"][1]
120+
previous_commit = pattern["older_commit"]
125121
# Prepare base DTO for logging events for this pattern
126122
evt = AutoRevertEvent(
127123
workflow=workflow_name,

aws/lambda/pytorch-auto-revert/pytorch_auto_revert/testers/do_restart.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

aws/lambda/pytorch-auto-revert/pytorch_auto_revert/testers/restart_checker.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33

44
def workflow_restart_checker(workflow: str, commit: str = None, days: int = 7) -> None:
5-
checker = WorkflowRestartChecker()
65
if commit:
76
# Check specific commit
8-
result = checker.has_restarted_workflow(workflow, commit)
7+
result = WorkflowRestartChecker().has_restarted_workflow(workflow, commit)
98
print(f"Commit {commit}: {'✓ RESTARTED' if result else '✗ Not restarted'}")
109
else:
1110
# Get all restarted commits in date range
12-
commits = checker.get_restarted_commits(workflow, days)
11+
commits = WorkflowRestartChecker().get_restarted_commits(workflow, days)
1312
print(f"Restarted commits for {workflow} (last {days} days):")
1413
if commits:
1514
for commit in sorted(commits):

aws/lambda/pytorch-auto-revert/pytorch_auto_revert/workflow_checker.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import logging
77
from datetime import datetime, timedelta
8-
from functools import cached_property
98
from typing import Dict, Set
109

1110
from .clickhouse_client_helper import CHCliFactory
@@ -173,6 +172,5 @@ def restart_workflow(self, workflow_name: str, commit_sha: str) -> bool:
173172
logging.error(f"Error dispatching workflow {workflow_name}: {e}")
174173
return False
175174

176-
@cached_property
177175
def resolver(self) -> WorkflowResolver:
178176
return WorkflowResolver.get(f"{self.repo_owner}/{self.repo_name}")

aws/lambda/pytorch-auto-revert/pytorch_auto_revert/workflow_resolver.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from __future__ import annotations
99

1010
import os
11-
from dataclasses import dataclass
1211
import re
12+
from dataclasses import dataclass
1313
from typing import Optional
1414

1515
import github
@@ -45,13 +45,19 @@ def __init__(
4545
self._by_file: dict[str, WorkflowRef] = {}
4646
self._build_indices()
4747

48-
def __new__(cls, repo_full_name: str, repository: "github.Repository.Repository") -> WorkflowResolver:
48+
def __new__(
49+
cls, repo_full_name: str, repository: "github.Repository.Repository"
50+
) -> WorkflowResolver:
4951
"""Create or return a cached resolver for the given repo."""
5052

5153
if re.match(r"^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$", repo_full_name) is None:
52-
raise ValueError(f"Invalid repo format: {repo_full_name}. Expected 'owner/repo'.")
54+
raise ValueError(
55+
f"Invalid repo format: {repo_full_name}. Expected 'owner/repo'."
56+
)
5357

54-
if repository is None or not isinstance(repository, github.Repository.Repository):
58+
if repository is None or not isinstance(
59+
repository, github.Repository.Repository
60+
):
5561
raise ValueError(f"Invalid repository object for {repo_full_name}.")
5662

5763
if repo_full_name not in cls._resolver_cache:

0 commit comments

Comments
 (0)