-
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
Causes returned by _attempt_to_pin_criterion
are too broad (causing searching unnecessary parts of a dependency graph)
#171
Comments
FYI, I'm not sure in resolvelib's current design cause narrowing like this is possible, but if it can happen at the resolvelib level I think it would be best as then it benefits all clients and keeps resolution optimizations out of the downstream library. So I've opened this issue somewhat optimistically, and I'll report back on my findings once I try. |
Okay, so specifically the issue is the information included in the Criteron is too broad here: https://github.com/sarugaku/resolvelib/blob/1.1.0b1/src/resolvelib/resolvers/resolution.py#L138 But I'm not sure it's possible to fix this, because it looks like you can't recreate the Criterion object with less information and rerun the And I'm not sure what other test can be done at the resolvelib level to see if a smaller information list still creates a conflict. 🙁 |
I think the main issue is how to detect conflicting version ranges. Look at the following conflicts:
We can't even decide if I developed a library for this purpose but I don't think it's as mature as |
Thanks, I'll take a look. But it seems to me that's too specific for resolvelib? That it generically deals with conflicts but doesn't consider the source of those conflicts, that's left up to the provider? Which means any narrowing of causes would need to be left up to the provider, either via existing APIs or a new one. |
Makes sense, would need another method for providers to implement. |
It should be possible to validate if this works without a new API, the provider could narrow any time they are passed from resolvelib, and do what work the provider needs. I plan to make a PoC on pip side to see if it's worthwhile. The advantage to a dedicated API would be that resolvelib can reduce the amount it has to keep in state, and the provider wouldn't need to keep narrowing the same causes repeatedly. So if the PoC works out I'll consider what that API should look like. |
I've hacked together a branch of pip that uses I'll clean it up, test it against other optimizations, and look at making a new API for resolvelib so the provider can pass the improvements directly into the resolution. |
Okay, after working on this for a little bit I realized there's a problem with this approach (or at least implementing it in pip), there are basically two types of causes which cause backtracks:
So, if two causes provided are |
In a complex resolution the causes returned by
_attempt_to_pin_criterion
when rejecting a candidate are far too broad, if we take a look at the example in pypa/pip#13037 (comment) I've created a log that prints out each rejection: pypa/pip#13037 (comment)Looking at one of the rejections:
This should be ideally narrowed to:
This would allow downstream libraries (like pip) that use cases to prefer backtracking to hone in on the correct causes, and it would produce a much more focused message to the user, especially when hitting an impossible resolution.
Because resolvelib is so generic a cause narrowing is a little tricky, but I propose the following steps:
I think this could be a huge speed up for very problamatic resolutions where the downstream library uses the causes to determine what to prefer, I will look to make a PR in the coming weeks.
The text was updated successfully, but these errors were encountered: