Skip to content

Commit 086e0ee

Browse files
committed
[autorevert] Fix bug on job retrival for autorevert lambda
1 parent a445ab6 commit 086e0ee

4 files changed

Lines changed: 18 additions & 19 deletions

File tree

aws/lambda/pytorch-auto-revert/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ run-local: venv/bin/python
2323

2424
.PHONY: run-local-workflows
2525
run-local-workflows: venv/bin/python
26-
venv/bin/python -m pytorch_auto_revert workflows pull.yml
26+
venv/bin/python -m pytorch_auto_revert autorevert-checker Lint trunk pull inductor linux-binary-manywheel --hours 4320
2727

2828
deployment.zip:
2929
mkdir -p deployment

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,14 @@ def main(*args, **kwargs) -> None:
159159
"ClickHouse connection test failed. Please check your configuration."
160160
)
161161

162-
if opts.subcommand == "lambda":
163-
print("TODO: run lambda flow")
162+
if opts.subcommand is None:
163+
autorevert_checker(
164+
["Lint", "trunk", "pull", "inductor", "linux-binary-manywheel", ],
165+
hours=2,
166+
verbose=True,
167+
do_restart=True,
168+
dry_run=False,
169+
)
164170
elif opts.subcommand == "autorevert-checker":
165171
autorevert_checker(
166172
opts.workflows,

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

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def __init__(self, workflow_names: List[str] = None, lookback_hours: int = 48):
7070
self._commit_history = None
7171

7272
def get_workflow_commits(self, workflow_name: str) -> List[CommitJobs]:
73-
"""Get workflow commits for a specific workflow, fetching if needed."""
73+
"""Get workflow commits for a specific workflow, fetching if needed. From newer to older"""
7474
if workflow_name not in self._workflow_commits_cache:
7575
self._fetch_workflow_data()
7676
return self._workflow_commits_cache.get(workflow_name, [])
@@ -90,7 +90,7 @@ def commit_history(self) -> List[Dict]:
9090
return self._commit_history or []
9191

9292
def _fetch_workflow_data(self):
93-
"""Fetch workflow job data from ClickHouse for all workflows in batch."""
93+
"""Fetch workflow job data from ClickHouse for all workflows in batch. From newer to older"""
9494
if not self.workflow_names:
9595
return
9696

@@ -217,11 +217,11 @@ def _find_last_commit_with_job(
217217
for job in commit.jobs:
218218
if job.name.split("(")[0] == job_name: # Normalize job name
219219
job_results.append(job)
220-
if job_results:
221-
return (
222-
commit,
223-
job_results,
224-
)
220+
if job_results:
221+
return (
222+
commit,
223+
job_results,
224+
)
225225
return None, None
226226

227227
def detect_autorevert_pattern_workflow(self, workflow_name: str) -> List[Dict]:
@@ -304,18 +304,11 @@ def detect_autorevert_pattern_workflow(self, workflow_name: str) -> List[Dict]:
304304
# No older commit with the same job found
305305
continue
306306

307-
if any(
308-
j.name.split("(")[0] != job_name
309-
for j in last_commit_with_same_job.failed_jobs
310-
):
311-
# newr commit has the same job failing
312-
continue
313-
314307
if any(
315308
j.classification_rule == suspected_failure_class_rule
316309
for j in last_same_jobs
317310
):
318-
# The last commit with the same job has the same failure classification
311+
# The older commit has the same job failing with same rule
319312
continue
320313

321314
patterns.append(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def autorevert_checker(
108108
"category", "uncategorized"
109109
)
110110
print(
111-
f"✓ REVERTED ({category}): {second_commit[:8]} was reverted by {revert_result['revert_sha'][:8]} "
111+
f"✓ REVERTED ({category}): {second_commit} was reverted by {revert_result['revert_sha'][:8]} "
112112
f"after {revert_result['hours_after_target']:.1f} hours"
113113
)
114114
reverted_patterns.append(pattern)

0 commit comments

Comments
 (0)