question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refactor the resolver to take a list of parsed requirements

See original GitHub issue

What’s the problem this feature will solve? Currently, the (legacy) resolver takes a list of InstallRequirement objects, which are in an odd state compared to the later parts of pip’s code. They contain a bunch of config information (option flags, etc) but don’t necessarily refer to an actual distribution file (they can be something like pip >= 20.0). The resolver puts these requirements into a RequirementSet and then mutates them as it works through the resolution, preparing them, etc.

The problem here is that it means that the InstallRequirement object has an uncertain status - it is mostly (in particular, in later parts of the processing) expected to contain a link to a distribution, but early on it can be a “requirement specifier style” object that has no actual distribution behind it (and so, for example, can’t be prepared).

Describe the solution you’d like Make the resolver take ParsedRequirement objects, which are what the argument parsing code produces and which don’t have any role in “post resolution” code. This will more completely decouple the classes used by “pre-resolver” code and “post-resolver” code.

The new resolver could then take ParsedRequirement objects as the basis of the resolvelib Requirement objects and InstallRequirement objects as the basis of the resolvelib Candidate objects, and not have to deal with the dual nature of InstallRequirement.

Alternative Solutions The current prototype of the new resolver tries to work with InstallRequirement objects for both phases, but it is hitting errors which appear to be a result of being unable to correctly manage the state changes of InstallRequirement objects.

Additional context Longer term, it might be useful to completely remove the state where an InstallRequirement doesn’t have a populated link. But this is likely to be superseded by a move to the “project” model. In fact, the proposed change here would possibly be useful as a first step towards the “project” model (although that isn’t an explicit goal of this refactoring).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
pfmoorecommented, Mar 8, 2020

Sorry, you’re correct. What I should have said was (1) that I don’t now believe that this refactoring is a blocker for the new resolver implementation and (2) that it’s a bigger piece of work than I’d initially assumed. We can (if my latest experiments are correct) complete the implementation of the new resolver using InstallRequirement if necessary.

This refactoring is on the critical path for moving away from InstallRequirement, but what I was intending to say is that it’s not on the critical path for the new resolver implementation. (Unless, of course, further weird behaviour of InstallRequirement crawls out of the woodwork 🙄)

1reaction
pfmoorecommented, Mar 6, 2020

Ping @uranusjr @pradyunsg - also see this comment on Zulip.

Also, @chrahunt do you have any comments - I feel like I’m re-inventing thoughts you probably had when you proposed the previous set of refactorings, so I’d appreciate your input here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Returning a RequirementSet from Resolver.resolve #7638
The resolver just returns a list of what resolvelib calls "Candidates" - essentially project name and version. In my view the resolver will ......
Read more >
C# Refactoring with dependency injection - Stack Overflow
First, I need to keep track of all those objects, parsing the text and creating a list of what I have called "DocumentObject":....
Read more >
refactoring - Use Set instead of iterating in List - Salesforce Stack ...
I have to refactor this code by using Sets instead of a combination of List and for loop. As in replace the below...
Read more >
Avoid overfetching with properly designed GraphQL resolvers
GraphQL's biggest advantage over REST is that it solves the issue of overfetching data — so long as you have properly designed resolvers....
Read more >
babel/parser
The Babel parser (previously Babylon) is a JavaScript parser used in Babel. The latest ECMAScript version enabled by default (ES2020). Comment attachment.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found