-
Notifications
You must be signed in to change notification settings - Fork 34
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
Repurpose backtracking hook #101
Conversation
Woops, all tests ran locally but probably I did something wrong. Will fix them later. |
c947214
to
b89576c
Compare
Been staring at this line trying to make sense of it: Line 14 in ebf6c51
If I understand correctly, with this change the backtracking might happen even before any dependency is pinned, so the |
Instead of removing it, I'd move it above the |
This makes the tests fail too. Excerpt:
|
Oh right, because we might not pin something that we backtrack on! |
It might make sense to rename backtracking to something related to rejection instead then? Or actually keep this as a separate hook? I'm a bit wary of adding too many hook points (there's a decent performance impact from each of them, in the hot loop) so... 🤷🏽 |
I'm fine renaming or adding a separate hook. IIUC, in both cases we'd be calling a function in the hot loop, regardless of whether we keep the current Apart from the performance question, maybe it doesn't hurt to keep the current |
I can't test right now but I seem to remember the loop you've moved in to tends to be hotter for situations of heavy backtracking. In particular when it's not just that there are two conflicting requirements but there is a third conflicting requirement that was pinned much earlier in the resolution steps then the resolver can get in to a situation where it struggles to find any candidate to pin. If I get a chance I will try some heavy backtracking examples but my next 2 weeks is fairly busy. |
Let's do this:
If someone feels strongly that the backtracking hook is valuable on its own, they can open an issue about that. I don't think that it's particularly useful. :) |
8aa9816
to
e17b359
Compare
Not sure who else should approve this PR or who has merge rights here, but if there are any blockers by other folks I'll happily look into those :) |
@astrojuanlu please add a news fragment in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but please bump __version__
in __init__.py
to 0.9.0.dev0
to reflect the API change.
Do we know if anyone is using the backtracking
hook we should notify?
I'm not aware of anyone -- IIUC pip doesn't really use it either. |
News fragment added, version prebumped 👍🏽 |
Thanks! Is a new release here needed to update the vendoring in pip? |
Sort of. For merging the PR, yes. For experimenting with these changes, no. If you want to experiment with this before a release, you can use a |
Let’s experiement this a bit in pip first and see if we could further improve the interface before cutting a release here. |
Bumps [resolvelib](https://github.com/sarugaku/resolvelib) from 0.8.1 to 1.0.1. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/sarugaku/resolvelib/blob/main/CHANGELOG.rst">resolvelib's changelog</a>.</em></p> <blockquote> <h1>1.0.1 (2023-03-09)</h1> <h2>Bug Fixes</h2> <ul> <li>Fix calls to opaque objects and use provider interface calls instead. <code>[#126](sarugaku/resolvelib#126) <https://github.com/sarugaku/resolvelib/issues/126></code>_</li> </ul> <h1>1.0.0 (2023-03-08)</h1> <h2>Features</h2> <ul> <li>Implement backjumping to significantly speed up the resolution process by skipping over irrelevant parts of the resolution search space. <code>[#113](sarugaku/resolvelib#113) <https://github.com/sarugaku/resolvelib/issues/113></code>_</li> </ul> <h1>0.9.0 (2022-11-17)</h1> <h2>Features</h2> <ul> <li>A new reporter hook <code>rejecting_candidate</code> is added, replacing <code>backtracking</code>. The hook is called every time the resolver rejects a conflicting candidate before trying out the next one in line. <code>[#101](sarugaku/resolvelib#101) <https://github.com/sarugaku/resolvelib/issues/101></code>_</li> </ul> <h2>Bug Fixes</h2> <ul> <li>Some valid states that were previously rejected are now accepted. This affects states where multiple candidates for the same dependency conflict with each other. The <code>information</code> argument passed to <code>AbstractProvider.get_preference</code> may now contain empty iterators. This has always been allowed by the method definition but it was previously not possible in practice. <code>[#91](sarugaku/resolvelib#91) <https://github.com/sarugaku/resolvelib/issues/91></code>_</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/sarugaku/resolvelib/commit/c9ef371ad96e698bf3e0bb09acc682bd43e39bd7"><code>c9ef371</code></a> Release 1.0.1</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/fb97e4c71fe520ae6d1704b7be8bd742430cd6e6"><code>fb97e4c</code></a> Add missing news fragment for patch release</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/34bb1a7474e6a45103eeb08d9bbfd1a48e1b1cd3"><code>34bb1a7</code></a> Merge pull request <a href="https://redirect.github.com/sarugaku/resolvelib/issues/127">#127</a> from sarugaku/avoid-intermediate-set</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/409bcf753074ba5b03ffd259511bf12b5d181fde"><code>409bcf7</code></a> Use itertools.chain to avoid intermediate set</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/e8fecf776aafab9104eb0d101c4de08ce3c37eaf"><code>e8fecf7</code></a> Merge pull request <a href="https://redirect.github.com/sarugaku/resolvelib/issues/126">#126</a> from sarugaku/fix-</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/5ede4c4bd205e5c61d339ba957deb44c4f5400f9"><code>5ede4c4</code></a> use set comprehension</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/7e8adca961b96c159d3391049e6a6a37e25ed525"><code>7e8adca</code></a> fix: use the protocol method instead of .name attribute</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/02fb73619d536b14b621ecddb98ad24ccd6093d2"><code>02fb736</code></a> Merge pull request <a href="https://redirect.github.com/sarugaku/resolvelib/issues/125">#125</a> from sarugaku/release/1.0</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/69ae3253545a1da31a0096686693eed5c2dee08c"><code>69ae325</code></a> Update release process</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/40c867a2b7d12e3736ccf6c621a44a1b0dbefbc7"><code>40c867a</code></a> Prebump to 1.0.1.dev0</li> <li>Additional commits viewable in <a href="https://github.com/sarugaku/resolvelib/compare/0.8.1...1.0.1">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=resolvelib&package-manager=pip&previous-version=0.8.1&new-version=1.0.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) You can trigger a rebase of this PR by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details>> **Note** > Automatic rebases have been disabled on this pull request as it has been open for over 30 days.
Bumps [resolvelib](https://github.com/sarugaku/resolvelib) from 0.8.1 to 1.0.1. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/sarugaku/resolvelib/blob/main/CHANGELOG.rst">resolvelib's changelog</a>.</em></p> <blockquote> <h1>1.0.1 (2023-03-09)</h1> <h2>Bug Fixes</h2> <ul> <li>Fix calls to opaque objects and use provider interface calls instead. <code>[#126](sarugaku/resolvelib#126) <https://github.com/sarugaku/resolvelib/issues/126></code>_</li> </ul> <h1>1.0.0 (2023-03-08)</h1> <h2>Features</h2> <ul> <li>Implement backjumping to significantly speed up the resolution process by skipping over irrelevant parts of the resolution search space. <code>[#113](sarugaku/resolvelib#113) <https://github.com/sarugaku/resolvelib/issues/113></code>_</li> </ul> <h1>0.9.0 (2022-11-17)</h1> <h2>Features</h2> <ul> <li>A new reporter hook <code>rejecting_candidate</code> is added, replacing <code>backtracking</code>. The hook is called every time the resolver rejects a conflicting candidate before trying out the next one in line. <code>[#101](sarugaku/resolvelib#101) <https://github.com/sarugaku/resolvelib/issues/101></code>_</li> </ul> <h2>Bug Fixes</h2> <ul> <li>Some valid states that were previously rejected are now accepted. This affects states where multiple candidates for the same dependency conflict with each other. The <code>information</code> argument passed to <code>AbstractProvider.get_preference</code> may now contain empty iterators. This has always been allowed by the method definition but it was previously not possible in practice. <code>[#91](sarugaku/resolvelib#91) <https://github.com/sarugaku/resolvelib/issues/91></code>_</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/sarugaku/resolvelib/commit/c9ef371ad96e698bf3e0bb09acc682bd43e39bd7"><code>c9ef371</code></a> Release 1.0.1</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/fb97e4c71fe520ae6d1704b7be8bd742430cd6e6"><code>fb97e4c</code></a> Add missing news fragment for patch release</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/34bb1a7474e6a45103eeb08d9bbfd1a48e1b1cd3"><code>34bb1a7</code></a> Merge pull request <a href="https://redirect.github.com/sarugaku/resolvelib/issues/127">#127</a> from sarugaku/avoid-intermediate-set</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/409bcf753074ba5b03ffd259511bf12b5d181fde"><code>409bcf7</code></a> Use itertools.chain to avoid intermediate set</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/e8fecf776aafab9104eb0d101c4de08ce3c37eaf"><code>e8fecf7</code></a> Merge pull request <a href="https://redirect.github.com/sarugaku/resolvelib/issues/126">#126</a> from sarugaku/fix-</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/5ede4c4bd205e5c61d339ba957deb44c4f5400f9"><code>5ede4c4</code></a> use set comprehension</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/7e8adca961b96c159d3391049e6a6a37e25ed525"><code>7e8adca</code></a> fix: use the protocol method instead of .name attribute</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/02fb73619d536b14b621ecddb98ad24ccd6093d2"><code>02fb736</code></a> Merge pull request <a href="https://redirect.github.com/sarugaku/resolvelib/issues/125">#125</a> from sarugaku/release/1.0</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/69ae3253545a1da31a0096686693eed5c2dee08c"><code>69ae325</code></a> Update release process</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/40c867a2b7d12e3736ccf6c621a44a1b0dbefbc7"><code>40c867a</code></a> Prebump to 1.0.1.dev0</li> <li>Additional commits viewable in <a href="https://github.com/sarugaku/resolvelib/compare/0.8.1...1.0.1">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=resolvelib&package-manager=pip&previous-version=0.8.1&new-version=1.0.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) You can trigger a rebase of this PR by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details>> **Note** > Automatic rebases have been disabled on this pull request as it has been open for over 30 days. --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [resolvelib](https://github.com/sarugaku/resolvelib) from 0.8.1 to 0.9.0. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/sarugaku/resolvelib/blob/main/CHANGELOG.rst">resolvelib's changelog</a>.</em></p> <blockquote> <h1>0.9.0 (2022-11-17)</h1> <h2>Features</h2> <ul> <li>A new reporter hook <code>rejecting_candidate</code> is added, replacing <code>backtracking</code>. The hook is called every time the resolver rejects a conflicting candidate before trying out the next one in line. <code>[#101](sarugaku/resolvelib#101) <https://github.com/sarugaku/resolvelib/issues/101></code>_</li> </ul> <h2>Bug Fixes</h2> <ul> <li>Some valid states that were previously rejected are now accepted. This affects states where multiple candidates for the same dependency conflict with each other. The <code>information</code> argument passed to <code>AbstractProvider.get_preference</code> may now contain empty iterators. This has always been allowed by the method definition but it was previously not possible in practice. <code>[#91](sarugaku/resolvelib#91) <https://github.com/sarugaku/resolvelib/issues/91></code>_</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/sarugaku/resolvelib/commit/a65e197764a357b64466fd9f0c05dff1d8380747"><code>a65e197</code></a> Release 0.9.0</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/262f110f67ae7791864e200bb9d03f3da3865f04"><code>262f110</code></a> Fix towncrier arg</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/ed26eb833e14083b679aa1cb30fac8ee83375087"><code>ed26eb8</code></a> Merge pull request <a href="https://redirect.github.com/sarugaku/resolvelib/issues/111">#111</a> from sanderr/issue/91-criteria-compatibility-check-fix</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/546a11f6f8d00e3b0ea71a1862bae7e8816ebdbe"><code>546a11f</code></a> added Resolution to type stub</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/6e9cf49c3d373fde265dddcc3a51dbda43d8912d"><code>6e9cf49</code></a> pep8</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/20df2c8ba8a6905b5166c931a0ae820969698894"><code>20df2c8</code></a> use packaging instead of setuptools</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/84205835e0865f078dce86990aef99e9bf583272"><code>8420583</code></a> Merge pull request <a href="https://redirect.github.com/sarugaku/resolvelib/issues/112">#112</a> from sanderr/issue/103-test-deprecation-warnings</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/3d71c81052577852df532d556f470c851d2ee885"><code>3d71c81</code></a> fixed invalid version specifiers in a test index</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/ad9eaca8a0c2f9ccff8c04186be6cff1e1d547dd"><code>ad9eaca</code></a> removed TODO</li> <li><a href="https://github.com/sarugaku/resolvelib/commit/cc1c220d0c15980fef81adaa6de336c40d6820a3"><code>cc1c220</code></a> added news fragment</li> <li>Additional commits viewable in <a href="https://github.com/sarugaku/resolvelib/compare/0.8.1...0.9.0">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=resolvelib&package-manager=pip&previous-version=0.8.1&new-version=0.9.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Maxwell Cash <[email protected]>
See discussion at pypa/pip#10937. The idea is to change the place where the
backtracking
hook is called, and add extra parameters so more detailed info messages about conflicting dependencies can be printed.