14 Commits

Author SHA1 Message Date
754fb834db [BE][CI] bump ruff to 0.9.0: string quote styles (#144569)
Reference: https://docs.astral.sh/ruff/formatter/#f-string-formatting

- Change the outer quotes to double quotes for nested f-strings

```diff
- f'{", ".join(args)}'
+ f"{', '.join(args)}"
```

- Change the inner quotes to double quotes for triple f-strings

```diff
  string = """
-     {', '.join(args)}
+     {", ".join(args)}
  """
```

- Join implicitly concatenated strings

```diff
- string = "short string " "short string " f"{var}"
+ string = f"short string short string {var}"
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/144569
Approved by: https://github.com/Skylion007
ghstack dependencies: #146509
2025-02-24 19:56:09 +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
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
14d87bb5ff [BE] Enable ruff's UP rules and autoformat tools and scripts (#105428)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/105428
Approved by: https://github.com/albanD, https://github.com/soulitzer, https://github.com/malfet
2023-07-19 01:24:44 +00:00
345714e372 Upload merge records to Rockset (#97471)
This upload a record to a new Rockset `merges` collection in `commons` workspace in the following format:

```
{
    "id": comment_id,
    "pr_num": pr_num,
    "owner": owner,
    "project": project,
    "pending_checks": pending_checks,  # At the time of the merge
    "failed_checks": failed_checks,  # At the time of the merge
    "is_failed": is_failed,  # This is set to True if the merge fails to get through for whatever reason
    "dry_run": dry_run,
    "skip_mandatory_checks": skip_mandatory_checks,
    "ignore_current": ignore_current,
    "error": error,  # The same Exception message that will be shown on PR
}
```

To achieve this, I need to tweak `find_matching_merge_rule` a bit to return the list of pending and failed checks in addition to the matching merge rule.  As this function is also used internally, I have confirmed that the internal call doesn't need the return values.  Thus, the change is safe to land.

### Testing

* Unit testing
* Dry-run locally `python3 .github/scripts/trymerge.py --comment-id 1478678477 --dry-run 97293` using an older PR.  The merge obviously failed, but the record was created successfully on Rockset
```
{
  "_id": "52d3152b-ec35-4b5a-91fc-0e7298fc54b5-1",
  "_event_time": "2023-03-23T21:10:32.754368Z",
  "_meta": null,
  "owner": "pytorch",
  "is_failed": true,
  "id": 1478678477,
  "failed_checks": [],
  "dry_run": true,
  "error": "Command `git -C pytorch cherry-pick -x cc0d2e0fba648bb5deda34a9056f2c4192b22314` returned non-zero exit code 1...",
  "ignore_current": false,
  "project": "pytorch",
  "pr_num": 97293,
  "skip_mandatory_checks": false,
  "pending_checks": []
}
```

* Dry-run locally with this PR `python3 .github/scripts/trymerge.py --comment-id 1481949104 --dry-run --force 97471` with `--force`
```
{
  "_id": "dd7d2580-f6e5-47e7-9441-17df86056c14-1",
  "_event_time": "2023-03-23T21:43:53.915911Z",
  "_meta": null,
  "owner": "pytorch",
  "is_failed": true,
  "id": 1481949104,
  "failed_checks": [],
  "dry_run": true,
  "error": "PR #97471 has not been reviewed yet",
  "ignore_current": false,
  "project": "pytorch",
  "pr_num": 97471,
  "skip_mandatory_checks": true,
  "pending_checks": []
}
```

* Dry-run locally with this PR `python3 .github/scripts/trymerge.py --comment-id 1481949104 --dry-run 97471` again with approval rule commented out

```
{
  "_id": "5d7de4e3-1af1-4869-a3b7-d1a9dbced6ce-1",
  "_event_time": "2023-03-24T00:10:41.914111Z",
  "_meta": null,
  "is_failed": false,
  "id": 1481949104,
  "failed_checks": [],
  "error": "",
  "last_commit_sha": "4657400513f0360a0a4f73d46e1aff0882221687",
  "merge_commit_sha": "416bac5b813a181753afade781ae30f4f0843586",
  "ignore_current": false,
  "pending_checks": [
    [
      "pull / linux-focal-py3.8-gcc7 / test (default, 1, 3, linux.2xlarge)",
      "https://github.com/pytorch/pytorch/actions/runs/4506464828/jobs/7933518379",
      12239935788
    ],
    ...
    [
      "trunk / linux-bionic-cuda11.8-py3.10-gcc7 / test (default, 5, 5, linux.4xlarge.nvidia.gpu)",
      "https://github.com/pytorch/pytorch/actions/runs/4506465633/jobs/7933621958",
      12240067113
    ],
    ...
  ],
  "owner": "pytorch",
  "skip_mandatory_checks": true,
  "author": "Huy Do <huydhn@gmail.com>",
  "project": "pytorch",
  "merge_base_sha": "a3b30c5025e3381022fa00b127b0d881f4ef66d4",
  "pr_num": 97471
}
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/97471
Approved by: https://github.com/clee2000
2023-03-27 18:42:00 +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
a37b4fa03a [mergebot] An ignore current flag (#96756)
with https://github.com/pytorch/test-infra/pull/3882

Add -ic/--ignore-current flag for merge.  It ignores the currently failing checks but will stop when there is a new failure.  If there are no pending checks, it fails and tells you to use -f/--force.

Doesn't work on ghstacks with more than 1 PR.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/96756
Approved by: https://github.com/huydhn
2023-03-20 19:07:01 +00:00
481582eb11 Remove land checks in trymerge (#96401)
Remove all references to land checks (rebase on viable strict in a different branch) since its no longer used.  Adding ciflow/trunk on merge and/or rebasing the entire pr is preferred.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/96401
Approved by: https://github.com/huydhn
2023-03-10 18:11:05 +00:00
6894bb0a85 Remove on_green and mandatory_only (#96400)
Our default behavior is on green, and currently the two main modes are on green and force.
Surprisingly, both these flags are pretty much not used anywhere.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/96400
Approved by: https://github.com/huydhn
2023-03-10 18:11:05 +00:00
34353a402e [mergebot] Flatten workflows into jobs, fix bugs (#92097)
* flatten the workflows into just jobs in order to give more specific links (link to the specific job that failed instead of just pull), this should make it easier to implement bypass certain failures in the future
* try catch of MandatoryChecksMissingError from find_matching_merge_rule should fix error where merge loops instead of raising runtime error when trunk job fails
* remove usage of on_green and mandatory_only flags just in case.  on_green and force are the only two behaviors we currently use
* fail if ghstack pr has non ghstack change, tested locally with #92177 but unsure how to write tests b/c requires use of repo._run_git
Pull Request resolved: https://github.com/pytorch/pytorch/pull/92097
Approved by: https://github.com/huydhn, https://github.com/ZainRizvi
2023-01-18 23:38:16 +00:00
f5ee2d8840 [ci] fix bot comment (#87127)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/87127
Approved by: https://github.com/clee2000
2022-10-17 21:27:21 +00:00
1059d3b52d Make mergebot message clearer when starting a new merge (#86311)
Modifying how the merge started message appears to make it more readable.
Also removing some deprecated v1 land checks messages

Old:
<img width="917" alt="image" src="https://user-images.githubusercontent.com/4468967/194150650-c9e384a3-d13c-40aa-975d-f43853790603.png">

New:
<img width="933" alt="image" src="https://user-images.githubusercontent.com/4468967/194151507-a5900cd5-5711-4cab-9447-c2cc6ed0d7b5.png">
Pull Request resolved: https://github.com/pytorch/pytorch/pull/86311
Approved by: https://github.com/malfet, https://github.com/huydhn
2022-10-06 18:47:07 +00:00
95863f2ccc Make mergebot failure messages more readable (#84214)
Reformat how mergebot outputs merge and revert errors to make the failure more obvious and hide text that doesn't actually help most users debug their PRs. (The workflow job helps the DevX team to debug mergebot errors)

### Old message:
<img width="933" alt="image" src="https://user-images.githubusercontent.com/4468967/187276407-fb35880c-5ada-4f1f-a01e-86b5071ab0fd.png">

### New message contents:
<img width="833" alt="image" src="https://user-images.githubusercontent.com/4468967/187276280-e7397edb-1887-41a2-b206-4d005b59f683.png">

### New message contents detailed expanded:
<img width="843" alt="image" src="https://user-images.githubusercontent.com/4468967/187276342-b50e6b28-f19e-4547-bf29-1a7878a3a97c.png">

Pull Request resolved: https://github.com/pytorch/pytorch/pull/84214
Approved by: https://github.com/malfet, https://github.com/huydhn
2022-08-29 22:15:20 +00:00
23b5fcaab9 [mergebot] Update merge bot messages to explain flags (#82907)
## FORCE
@pytorchbot successfully started a merge job. Check the current status [here](None).
The merge job was triggered with the force (-f) flag. This means your change will be merged **immediately**, bypassing any CI checks (ETA: 1-5 minutes). If this is not the intended behavior, feel free to use some of the other merge options in the [wiki](https://github.com/pytorch/pytorch/wiki/Bot-commands).
Please reach out to the [PyTorch DevX Team](https://github.com/pytorch/pytorch/wiki/Dev-Infra-Office-Hours) with feedback or questions!
## GREEN
@pytorchbot successfully started a merge job. Check the current status [here](None).
The merge job was triggered with the green (-g) flag. This means that your change will be merged once all checks on your PR have passed (ETA: 0-4 Hours). If this is not the intended behavior, feel free to use some of the other merge options in the [wiki](https://github.com/pytorch/pytorch/wiki/Bot-commands).
Please reach out to the [PyTorch DevX Team](https://github.com/pytorch/pytorch/wiki/Dev-Infra-Office-Hours) with feedback or questions!
## LAND CHECKS
@pytorchbot successfully started a merge job. Check the current status [here](None).
The merge job was triggered with the land checks (-l) flag. If you did not specify this flag yourself,  you are likely enrolled in the [land checks rollout](https://github.com/pytorch/test-infra/blob/main/torchci/lib/bot/rolloutUtils.ts#L1-L34). This means that your change will be merged once all checks on your PR and the land checks have passed (**ETA 4 Hours**). If you need to coordinate lands between different changes and cannot risk a land race, please add the `ciflow/trunk` label to your PR and wait for signal to complete, and then land your changes in proper order. Having `trunk`, `pull`, and `Lint` pre-run on a PR will bypass land checks and the ETA should be immediate. If this is not the intended behavior, feel free to use some of the other merge options in the [wiki](https://github.com/pytorch/pytorch/wiki/Bot-commands).
Please reach out to the [PyTorch DevX Team](https://github.com/pytorch/pytorch/wiki/Dev-Infra-Office-Hours) with feedback or questions!
## LAND CHECKS
@pytorchbot successfully started a merge job. Check the current status [here](None).
The merge job was triggered with the land checks (-l) flag. If you did not specify this flag yourself,  you are likely enrolled in the [land checks rollout](https://github.com/pytorch/test-infra/blob/main/torchci/lib/bot/rolloutUtils.ts#L1-L34). This means that your change will be merged once all checks on your PR have passed since you have added the `ciflow/trunk` label to your PR (ETA 0-4 Hours). If this is not the intended behavior, feel free to use some of the other merge options in the [wiki](https://github.com/pytorch/pytorch/wiki/Bot-commands).
Please reach out to the [PyTorch DevX Team](https://github.com/pytorch/pytorch/wiki/Dev-Infra-Office-Hours) with feedback or questions!
## NORMAL
@pytorchbot successfully started a merge job. Check the current status [here](None).
The merge job was triggered without a flag. This means that your change will be merged once all checks on your PR have passed (ETA: 0-4 Hours). If this is not the intended behavior, feel free to use some of the other merge options in the [wiki](https://github.com/pytorch/pytorch/wiki/Bot-commands).
Please reach out to the [PyTorch DevX Team](https://github.com/pytorch/pytorch/wiki/Dev-Infra-Office-Hours) with feedback or questions!
## Revert Message
@pytorchbot successfully started a revert job. Check the current status [here](None).
Please reach out to the [PyTorch DevX Team](https://github.com/pytorch/pytorch/wiki/Dev-Infra-Office-Hours) with feedback or questions!
## TROUBLESHOOTING
 If you believe this is an error, you can use the old behavior with `@pytorchbot merge -g` (optionally with the `ciflow/trunk` to get land checks) or use `@pytorchbot merge -f "some reason here"`. For more information, see the [bot wiki](https://github.com/pytorch/pytorch/wiki/Bot-commands).
Please reach out to the [PyTorch DevX Team](https://github.com/pytorch/pytorch/wiki/Dev-Infra-Office-Hours) with feedback or questions!
Pull Request resolved: https://github.com/pytorch/pytorch/pull/82907
Approved by: https://github.com/huydhn, https://github.com/janeyx99
2022-08-11 14:25:15 +00:00