8000 [GHF][mergebot] record ghstack dependencies in the commit message by izaitsevfb · Pull Request #105251 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[GHF][mergebot] record ghstack dependencies in the commit message #105251

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

Closed
wants to merge 2 commits into from

Conversation

izaitsevfb
Copy link
Contributor
@izaitsevfb izaitsevfb commented Jul 14, 2023

Currently all information about the dependencies of ghstack PRs (e.g. #105010) is stripped away:

if filter_ghstack:
msg_body = re.sub(RE_GHSTACK_DESC, "", msg_body)

This PR adds this information back in a more compact form. All dependencies (PR numbers) of each PR in ghstack are recorded.

The resulting commit message will look like this (the last line is new):

Mock title (#123)

Mock body text
Pull Request resolved: #123
Approved by: https://github.com/Approver1, https://github.com/Approver2
ghstack dependencies: #1, #2


Testing

Unit tests.


Note Re: # type: ignore[assignment] in unit tests.

I did my due diligence to find alternatives. Unfortunately mypy doesn't support this way of patching methods, and the alternatives are either extremely verbose or don't work for this case. I decided it's not worth the effort (since the problem is limited only to the unit test).

@izaitsevfb izaitsevfb requested a review from a team as a code owner July 14, 2023 22:45
@pytorch-bot
Copy link
pytorch-bot bot commented Jul 14, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/105251

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 2bc8476:
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Jul 14, 2023
@izaitsevfb izaitsevfb requested review from huydhn, PaliC and osalpekar July 14, 2023 22:46
pass

@staticmethod
def mock_pr(num: int, title: str, body: str, closed: bool) -> GitHubPR:
Copy link
Contributor
@huydhn huydhn Jul 15, 2023

Choose a reason for hiding this comment

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

I have a feeling that you don't need to devise your own mock here in test_trymerge unless there is a clear reason to do so. The usual way to mock PR info is to use the generic patches below and uses an actual PR number in PyTorch:

@mock.patch("trymerge.get_rockset_results", side_effect=mocked_rockset_results) <-- Cache all graphql query and use the result as the mock value
@mock.patch("trymerge.gh_graphql", side_effect=mocked_gh_graphql) <-- Cache all Rockset result and use it as the mock value

Here is a recent example I have in mind #105098. Before running the test, you can export GITHUB_TOKEN and ROCKSET_API_KEY readily. When you run the test locally, mocked_gh_graphql would make a single query to PyTorch to get the PR info and cache them locally in .github/scripts/gql_mocks.json for all future use.

@izaitsevfb izaitsevfb force-pushed the record-ghstack-deps-in-commit-msg branch from c984885 to 2bc8476 Compare July 29, 2023 00:09
@izaitsevfb izaitsevfb requested a review from huydhn July 29, 2023 00:21
Copy link
Contributor
@huydhn huydhn left a comment

Choose a reason for hiding this comment

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

LGTM!

@izaitsevfb
Copy link
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 29, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@ZainRizvi
Copy link
Contributor

Hi @izaitsevfb, one of the tests added here depended on the referenced ghstack PR never closing. Since that PR is now merged, the github gql queries the tests makes now return different results, causing the test to fail.

I've disabled this test for now in #107385, can you please fix this test to be more resilient? Either mock parts of the PR or perhaps better yet create a new dummy github account, have it create the ghstack PR you want, and then discard that account's username/password :P

@izaitsevfb
Copy link
Contributor Author
izaitsevfb commented Aug 17, 2023

Hi @izaitsevfb, one of the tests added here depended on the referenced ghstack PR never closing. Since that PR is now merged, the github gql queries the tests makes now return different results, causing the test to fail.

This is weird, I assumed all the requests are mocked. I'll investigate.

cc @huydhn

pytorchmergebot pushed a commit that referenced this pull request Aug 17, 2023
…#107385)

Two fixes:
- Stop querying `pushDate`, which [has been deprecated ](https://docs.github.com/en/graphql/reference/objects) and now always returns null
- Disables the test `test_merge_ghstack_into` which was recently added in #105251. This test used the results of another person's ghstack PR for testing, but as the dev submitted chunks of their PR this test's assumptions have been broken. cc @izaitsevfb for a long term fix here

Pull Request resolved: #107385
Approved by: https://github.com/clee2000
@huydhn
Copy link
Contributor
huydhn commented Aug 17, 2023

This is weird, I assumed all the requests are mocked. I'll investigate.

cc @huydhn

I think so too. I could run the test that Zain mentions fine locally. So just curious if the file gql_mocks.json is removed and repopulated, that would explain the failure. Basically, I could delete gql_mocks.json and run all the tests again to repopulate gql_mocks.json. However, the cached content will be the snapshot at that later time instead. In other words, removing and repopulating gql_mocks.json is not idempotent in the technical jargon. So it's indeed a good idea to prefer closed PRs as test samples so that their contents don't change. Having an open test PR would also work, but we need to keep it open.

(py3.9) huydo@huydo-mbp scripts % pytest -v test_trymerge.py -k test_last_pushed_at
=================================================================== test session starts ====================================================================
platform darwin -- Python 3.9.17, pytest-7.2.0, pluggy-1.0.0 -- /Users/huydo/miniconda3/envs/py3.9/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/Users/huydo/Storage/mine/pytorch/.github/scripts/.hypothesis/examples')
rootdir: /Users/huydo/Storage/mine/pytorch, configfile: pytest.ini
plugins: xdoctest-1.1.0, cpp-2.3.0, resume-0.0.1, rerunfailures-10.3, shard-0.1.2, flakefinder-1.1.0, hypothesis-6.56.4, xdist-3.0.2, profiling-1.7.0, repeat-0.9.1, anyio-3.6.2
collected 39 items / 38 deselected / 1 selected
Running 1 items in this shard: .github/scripts/test_trymerge.py::TestTryMerge::test_last_pushed_at

test_trymerge.py::TestTryMerge::test_last_pushed_at PASSED                                                                                           [100%]

============================================================= 1 passed, 38 deselected in 1.76s =============================================================

@huydhn
Copy link
Contributor
huydhn commented Aug 17, 2023

Ah I get it now, as Zain clean up the pushDate field, the cache becomes invalidated as the input parameters have changed. And this triggers the failures and the content is now indeed different

malfet added a commit that referenced this pull request Sep 27, 2023
One should always use `unittest.assert` methods rather than plain `assert` as later can be turned into a noop if Python runtime is invoked with optimizations enabled

Fixes use of `assert` introduced by #105251
pytorchmergebot pushed a commit that referenced this pull request Sep 27, 2023
One should always use `unittest.assert` methods rather than plain `assert` as later can be turned into a noop if Python runtime is invoked with optimizations enabled

Fixes use of `assert` introduced by #105251

Pull Request resolved: #110179
Approved by: https://github.com/huydhn
@github-actions github-actions bot deleted the record-ghstack-deps-in-commit-msg branch January 28, 2025 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 indexed random
4 participants
0