28 Commits

Author SHA1 Message Date
7d39e73c57 Fix more URLs (#153277)
Or ignore them.
Found by running the lint_urls.sh script locally with https://github.com/pytorch/pytorch/pull/153246

Pull Request resolved: https://github.com/pytorch/pytorch/pull/153277
Approved by: https://github.com/malfet
2025-05-14 16:23:50 +00:00
60f98262f1 PEP585: .github (#145707)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/145707
Approved by: https://github.com/huydhn
2025-01-27 21:21:01 +00:00
747b38c131 [BE][Easy][2/19] enforce style for empty lines in import segments in .ci/ and .github/ (#129753)
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501. Most changes are auto-generated by linter.

You can review these PRs via:

```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/129753
Approved by: https://github.com/malfet
ghstack dependencies: #129752
2024-07-16 09:40:00 +00:00
c5fafe9f48 [BE]: TRY002 - Ban raising vanilla exceptions (#124570)
Adds a ruff lint rule to ban raising raw exceptions. Most of these should at the very least be runtime exception, value errors, type errors or some other errors. There are hundreds of instance of these bad exception types already in the codebase, so I have noqa'd most of them. Hopefully this error code will get commiters to rethink what exception type they should raise when they submit a PR.

I also encourage people to gradually go and fix all the existing noqas that have been added so they can be removed overtime and our exception typing can be improved.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/124570
Approved by: https://github.com/ezyang
2024-04-21 22:26:40 +00:00
3fc38e6c83 [GHF] Abort merge on rebase failure (#113960)
Abort merges invoked with `-r` if there is nothing to rebase

Make `rebase_onto`/`rebase_ghstack_onto` return False if rebase is no-op and abort merge in that case

Remove `-e` option from both trymerge and tryrebase workflows as  one should never report failures on workflow dispatch

Pull Request resolved: https://github.com/pytorch/pytorch/pull/113960
Approved by: https://github.com/clee2000
2023-11-17 23:11:00 +00:00
9b499b417e [BE]: Apply subprocess check to github scripts (#111684)
Add subproces checks to raise exceptions in Github scripts
Pull Request resolved: https://github.com/pytorch/pytorch/pull/111684
Approved by: https://github.com/albanD
2023-10-20 23:37:57 +00:00
57f23ca58b Bot message changes for -f and rebase (#106150)
* Encourage people to use -i instead of -f for mergebot
* Add additional info for when rebase fails due to lacking permissions

<details><summary>dryrun</summary>

````
csl@csl-mbp ~/zzzzzzzz/pytorch [csl/errormsgs] $
(forpytorch) python3 .github/scripts/tryrebase.py 106089 --branch viable/strict --dry-run
+ git -C /Users/csl/zzzzzzzz/pytorch rev-parse --verify refs/remotes/origin/viable/strict
@pytorchbot started a rebase job onto [refs/remotes/origin/viable/strict](7c97c943fb). Check the current status [here](None)
+ git -C /Users/csl/zzzzzzzz/pytorch fetch origin pull/106089/head:pull/106089/head
+ git -C /Users/csl/zzzzzzzz/pytorch rebase refs/remotes/origin/viable/strict pull/106089/head
+ git -C /Users/csl/zzzzzzzz/pytorch rev-parse --verify pull/106089/head
+ git -C /Users/csl/zzzzzzzz/pytorch rev-parse --verify refs/remotes/origin/viable/strict
+ git -C /Users/csl/zzzzzzzz/pytorch push --dry-run -f https://github.com/Lightning-Sandbox/pytorch.git pull/106089/head:fix/spaces
stdout:
remote: Permission to Lightning-Sandbox/pytorch.git denied to clee2000.
fatal: unable to access 'https://github.com/Lightning-Sandbox/pytorch.git/': The requested URL returned error: 403

stderr:

Rebase failed due to Command `git -C /Users/csl/zzzzzzzz/pytorch push --dry-run -f https://github.com/Lightning-Sandbox/pytorch.git pull/106089/head:fix/spaces` returned non-zero exit code 128
```
remote: Permission to Lightning-Sandbox/pytorch.git denied to clee2000.
fatal: unable to access 'https://github.com/Lightning-Sandbox/pytorch.git/': The requested URL returned error: 403
```
This is likely because the author did not allow edits from maintainers on the PR or because the repo has additional permissions settings that mergebot does not qualify.
````
</details>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/106150
Approved by: https://github.com/huydhn
2023-07-28 16:13:51 +00:00
54fe828cd0 Improve rebase message when PR is uptodate (#101504)
Also, preserve target branch commit revision at time of merge

Fixes https://github.com/pytorch/test-infra/issues/4148
Pull Request resolved: https://github.com/pytorch/pytorch/pull/101504
Approved by: https://github.com/ZainRizvi, https://github.com/huydhn
2023-05-16 17:26:08 +00:00
20deccf8a1 BE changes for tryrebase.py (#101503)
- Use context manager rather than explicit ```try: finally:```

- Add `ref/remotes` prefix to `onto_branch` in `main` rather than in
`rebase_onto` functions

- Define `MAIN_BRANCH` and `VIABLE_STRICT_BRANCH` constants in tests.
- Replace `self.assertTrue(x in y)` with `self.assertIn(x, y)`
Pull Request resolved: https://github.com/pytorch/pytorch/pull/101503
Approved by: https://github.com/ZainRizvi, https://github.com/huydhn
2023-05-16 17:26:08 +00:00
4c0dce50fd [BE] Apply ufmt to run_test and GitHub Python util scripts (#97588)
This has been bugging me for a while as I'm working on these Python scripts and they are not tracked by ufmt linter.  So I add these script into that linter.

```
[[linter]]
code = 'UFMT'
include_patterns = [
    '.github/**/*.py',
    'test/run_test.py',
```

This change should just work and not break anything as ufmt (black + usort) linter is very safe to use for standalone util scripts.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/97588
Approved by: https://github.com/kit1980
2023-03-26 04:52:55 +00:00
5ba4dafccd Retry Merge: extract utils from check labels ptr (#94899)
Fixes #88098

This is the rebased and retry merging branch of the reverted PR: https://github.com/pytorch/pytorch/pull/94597

Pull Request resolved: https://github.com/pytorch/pytorch/pull/94899
Approved by: https://github.com/kit1980
2023-03-01 20:40:30 +00:00
7c3fc2c7f0 Revert "Issue-88098: extract utils from check labels (#94597)"
This reverts commit 2c76838d7ff96cc7aa3a30cae54fded70e0bccc5.

Reverted https://github.com/pytorch/pytorch/pull/94597 on behalf of https://github.com/jeanschmidt due to reverting due internal breakages https://fburl.com/sandcastle/3ukij9xp
2023-02-13 20:19:50 +00:00
2c76838d7f Issue-88098: extract utils from check labels (#94597)
Fixes #88098

This is a mirror of the same PR (https://github.com/Goldspear/pytorch/pull/2) that has been reviewed in my fork (due to it's a stacked PR).

======================
## Context

This is the 2nd of the 3 PRs to address issue-88098.

## What Changed
1. Extract comment related utils from trymerge.py to github_utils.py
2. Extract label related utils from trymerge.py and check_labels.py to label_utils.py

## Tests
* pytorch-dummy repo [trymerge run ](https://github.com/Goldspear/pytorch-dummy/actions/runs/4118944174)merged the test PR [OK](https://github.com/Goldspear/pytorch-dummy/pull/2).

## Note to Reviewers
Due to higher degree of complexity involved to extract GitHubPR class, it's worth having a separate issue to handle that part of refactoring. This issue only focusing on refactoring where necessary to ship the functional diff.

* 1st PR: https://github.com/pytorch/pytorch/pull/94179
* 2nd PR: this one
* 3rd PR: https://github.com/Goldspear/pytorch/pull/3

Pull Request resolved: https://github.com/pytorch/pytorch/pull/94597
Approved by: https://github.com/ZainRizvi
2023-02-12 12:18:53 +00:00
d7674e70f4 Fix for tryrebase after PR was merged (#91337)
rebasing certain merged prs results in the rebased branch pointing at the target branch b/c git believes the pr has already been included in the branch.  Git does not replay the changes onto the target branch because the change is already in the target branch

This usually affects PRs with only 1 commit (more commits -> trymerge squashes them when merged -> git believes that the change is not in the target branch b/c the squashed commit is different from the individual changes).

It might also affect ghstack changes b/c behind the scenes the ghstack PRs are all contained within one commit on the orig branch, but I'm not sure about this.

helps w/ https://github.com/pytorch/test-infra/issues/836
looks like https://github.com/clee2000/random-testing/pull/44#issuecomment-1363439534
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91337
Approved by: https://github.com/ZainRizvi
2022-12-28 18:44:08 +00:00
0745242ca5 Fix wrong committer when rebase and merge (#91330)
When using in the context of the merge workflow, the committer's name and email have already been set as part of the workflow, i.e. https://github.com/pytorch/pytorch/actions/runs/3754075933/jobs/6377965897:

```
git config --global user.email "pytorchmergebot@users.noreply.github.com"
git config --global user.name "PyTorch MergeBot"
```

Trying to overwrite this in tryrebase's ghstack logic would lead to the wrong committer showing up.  The fix check if the email and name have already been set so that the code doesn't overwrite them.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/91330
Approved by: https://github.com/kit1980, https://github.com/clee2000, https://github.com/malfet
2022-12-23 17:22:49 +00:00
5edbc92683 print stderr for ghstack rebase (#87795)
current output tends to be empty on failure, which makes it hard to debug
Pull Request resolved: https://github.com/pytorch/pytorch/pull/87795
Approved by: https://github.com/huydhn, https://github.com/ZainRizvi
2022-10-26 22:10:10 +00:00
3964b9aebc rebase via comment - ghstack commit author fix (#80747)
fixes #80635
tested on pytorch-canary: https://github.com/pytorch/pytorch-canary/pull/115
steal the identity of the committer of the commit on the orig branch instead of overwriting it with mergebot's identity
Pull Request resolved: https://github.com/pytorch/pytorch/pull/80747
Approved by: https://github.com/malfet, https://github.com/seemethere
2022-07-01 02:03:16 +00:00
50ce30520b [GHF][BE] Comment on reverted commit (#79913)
Makes it easier to see which version of PR were reverted when same PR is
reopened to re-land the change

Re-factor `gh_post_comment` into local `_gh_post_comment` that takes URL
and comment body and add two implementations: `gh_post_pr_comment` and
`gh_post_commit_comment`

Use later in revert bot after `Reverted` label is added to PR

Pull Request resolved: https://github.com/pytorch/pytorch/pull/79913
Approved by: https://github.com/atalman
2022-06-22 02:46:48 +00:00
bd7cd7c356 Revert "[GHF][BE] Comment on reverted commit (#79913)"
This reverts commit 4843b58f4bfb6eb51c27094a3722f8c6cce2ed0d.

Reverted https://github.com/pytorch/pytorch/pull/79913 on behalf of https://github.com/malfet due to Breaks lint
2022-06-22 02:28:13 +00:00
4843b58f4b [GHF][BE] Comment on reverted commit (#79913)
Makes it easier to see which version of PR were reverted when same PR is
reopened to re-land the change

Re-factor `gh_post_comment` into local `_gh_post_comment` that takes URL
and comment body and add two implementations: `gh_post_pr_comment` and
`gh_post_commit_comment`

Use later in revert bot after `Reverted` label is added to PR

Pull Request resolved: https://github.com/pytorch/pytorch/pull/79913
Approved by: https://github.com/atalman
2022-06-22 01:23:12 +00:00
b6378103c0 Add comment link for Job Run URL (#78823)
This adds a comment to link to the job run url whenever the job starts. As discussed here https://github.com/pytorch/test-infra/issues/360
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78823
Approved by: https://github.com/suo, https://github.com/seemethere
2022-06-03 20:31:19 +00:00
bb20296190 rebase via comment - better ghstack comment (#78833)
Fixes https://github.com/pytorch/pytorch/issues/78830

i have no idea how ghstack works, so ill take your word for it
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78833
Approved by: https://github.com/suo, https://github.com/seemethere
2022-06-03 20:04:03 +00:00
86c42d63c8 rebase via comment - rebase to any branch (#78772)
pr in test infra: https://github.com/pytorch/test-infra/pull/366
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78772
Approved by: https://github.com/suo, https://github.com/janeyx99
2022-06-03 17:13:11 +00:00
a171ea6b47 rebase bot - add ghstack config (#78561)
Fixes #78539
testing pr: https://github.com/clee2000/random-testing/pull/14
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78561
Approved by: https://github.com/janeyx99, https://github.com/seemethere
2022-05-31 23:37:37 +00:00
dde56ca329 fixing invalid upstream for rebase to viable/strict (#78371)
Testing rebase functionality [#78360](https://github.com/pytorch/pytorch/pull/78360) failed due to `invalid upstream 'viable/strict'`. Fixing by changing branch string to "refs/remotes/origin/viable/strict"
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78371
Approved by: https://github.com/janeyx99
2022-05-26 17:43:39 +00:00
bbb2964bd8 Add functionality for rebasebot to rebase onto viable/strict branch (#78276)
Fixes #325
**Summary**: Currently, the pytorchbot only allows for rebasing to the master branch. These modifications add functionality for rebasing to the 'viable/strict' branch of pytorch/pytorch by adding a flag to the comment.
**Test Plan:** tested manually on personal fork ([#1](https://github.com/swang392/pytorch/pull/1)), and included a test case in test_tryrebase.py that checks if rebasing to viable/strict branch was successful.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78276
Approved by: https://github.com/clee2000, https://github.com/janeyx99
2022-05-25 21:02:39 +00:00
b9087b664f rebase via comment - ghstack (#77911)
enable rebase bot on ghstack

tested on https://github.com/clee2000/random-testing/pull/2 and https://github.com/clee2000/random-testing/pull/1
Pull Request resolved: https://github.com/pytorch/pytorch/pull/77911
Approved by: https://github.com/seemethere
2022-05-20 16:03:31 +00:00
0bd8e237b5 rebase via comment
Fixes #ISSUE_NUMBER

start rebase bot

random testing on my fork, using `on: issue_comment` https://github.com/clee2000/pytorch/pull/6

stealing both code and an identity from mergebot

corresponding pr on test-infra https://github.com/pytorch/test-infra/pull/305

doesnt do ghstack

should accept "@pytorchbot rebase me", "@pytorchbot rebase this", "@pytorchmergebot rebase this"
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76262
Approved by: https://github.com/janeyx99, https://github.com/seemethere
2022-04-27 00:55:05 +00:00