Skip to content

[autorevert] Add workflow restarts #6962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 5, 2025
Merged

[autorevert] Add workflow restarts #6962

merged 3 commits into from
Aug 5, 2025

Conversation

izaitsevfb
Copy link
Contributor

Summary

Adds workflow restart capability to the PyTorch auto-revert tool, enabling automatic re-running of workflows for commits that match autorevert patterns but haven't been reverted yet.

Changes

  • Added restart methods to WorkflowRestartChecker:

    • restart_workflow(): Restarts a workflow for a specific commit with duplicate prevention
    • Checks ClickHouse for existing restarts before attempting
  • Enhanced autorevert-checker command:

    • Added --do-restart flag to enable automatic workflow restarts
    • Added --dry-run flag to preview restart actions without execution
    • Restarts workflows only for non-reverted commits matching autorevert patterns
  • Fixed workflow naming consistency:

    • Normalized workflow names by removing .yml extension for ClickHouse queries
    • Added .yml extension only for GitHub API calls
  • Updated do-restart command:

    • Now requires commit SHA (removed unused restart_latest_workflow)
    • Leverages same restart logic with duplicate prevention

Usage

  # Check patterns and restart workflows
  python -m pytorch_auto_revert autorevert-checker pull trunk --do-restart

  # Dry run to preview restarts
  python -m pytorch_auto_revert autorevert-checker pull trunk --do-restart --dry-run

  # Manual restart
  python -m pytorch_auto_revert do-restart trunk abc123def

Testing

python -m pytorch_auto_revert autorevert-checker inductor --hours 12 --do-restart --dry-run
Fetching workflow data for 1 workflows since 2025-07-30T22:47:17.357776...
Found 19 commits with job data for workflow 'inductor'
✓ 1 AUTOREVERT PATTERN DETECTED

Pattern #1:
Failure rule: 'GHA error'
Recent commits with failure: f89c28cc 5b2ad927
Older commit without failure: 7a4167a1
✗ NOT REVERTED: 5b2ad9279cb2e440d45253d28f2101a75fd42344 was not reverted
⟳ ALREADY RESTARTED: inductor for 5b2ad927

==================================================
SUMMARY STATISTICS
==================================================
Workflow(s): inductor
Timeframe: 12 hours
Commits checked: 19
Auto revert patterns detected: 1
Actual reverts inside auto revert patterns detected (precision): 0 (0.0%)
Total revert commits in period: 0

Total reverts excluding ghfirst: 0
No non-ghfirst reverts found in the period
Per workflow precision:
inductor: 0 reverts out of 1 patterns (0.0%) [excluding ghfirst: 0 (0.0%)]

@izaitsevfb izaitsevfb requested a review from jeanschmidt July 31, 2025 17:59
@pytorch-bot pytorch-bot bot added the ci-no-td label Jul 31, 2025
Copy link

vercel bot commented Jul 31, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
torchci ⬜️ Ignored (Inspect) Visit Preview Aug 5, 2025 10:09pm

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 31, 2025
workflow_file_name = f"{normalized_workflow_name}.yml"

url = (
f"https://api.github.com/repos/{repo_owner}/{repo_name}"
Copy link
Contributor

@jeanschmidt jeanschmidt Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this API is available in the github main sdk we're already importing for this.

@izaitsevfb izaitsevfb merged commit bc704b6 into main Aug 5, 2025
6 checks passed
@izaitsevfb izaitsevfb deleted the autorevert-do-restarts branch August 5, 2025 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-no-td CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants