-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Separate pip's UI from the underlying logic #6541
Comments
@pypa/pip-committers Thoughts? |
In principle this seems like a good idea. How easy it will be in practice is the big question, of course :-) |
Personally, I haven't really had any problems with the status quo with respect to log messages. For example, I've been able to test log messages without any problem that occur in functions (e.g. using If there's an idea for separating e.g. log message text from the surrounding "business logic" code, I think it would be helpful to see an example in a real function. If something other than a logging call were to be used, what would the function call look like if the "business logic" function wanted to communicate (log) that a certain event has happened? And what would it look like to test that compared to testing the log message directly? |
Just to set the tone here, if we can figure out a clearer idea for ourselves, on what approach to use for logging, that's good enough. I am not married to the idea in OP. Maybe we won't have a blanket answer but it'll be handy to have this discussion none the less. TBH, I'm not sure what this might look like either. For all I know, I might just be over-engineering here. :) (fleshing this out with more thoughts) Right now, we use multiple ways to handle doing the logging-related logic and message formatting:
I think the first two aren't ideal -- they work but occasionally feel more like a workaround than a scalable solution. IOW, I'd like to avoid having helper functions (like I guess OP suggests moving everything to Formatting messages in Exception sub-classes also provides the same separation. Additionally, it is a two-stage process (initialize-raise vs call) and bubbles up, so there would be cases where that's more useful. I'm still not sure how that should look though in terms of organization.
I feel the Off-Topic:
We would still be able to apply our current testing approaches. In addition, we can also test just the log message generation and/or mock out the "UI" bits and check that the correct information is being passed through. IOW, we'd have more atomic tests for the "UI" side of things and possibly "business" as well; while the end-to-end stays the same. |
I don't personally like how pip's UI looks, and could redesign it if you want |
@RDIL we have a few UX folks working on pip for ~1 year now, conducting user research that we'd be using to better prioritize and design the UI based on the UX research. None the less, this issue is more about restructuring of the codebase / responsibilities, not redesigning the UI. That would be #4649. :) |
What's the problem this feature will solve?
Currently, pip directly uses logging to log the output on the command line. This means that core logic within pip contains messages that show up on the user. This has various effects, such as complication of code to create better error messages, mixing of "UI" and "business logic" etc.
Describe the solution you'd like
Separate the "core" and "ui" of pip, by using a few objects that act as a layer of abstraction between the two.
I wanted to make note of this idea, even though I'm not sure what this would look like yet or how complicated the implementation/transition would be.
I definitely think this has the potential to improve some bits within pip, especially since error message creation / wording can be better separated from the logic that handles things along with making it explicit at the interface of what the error messages should contain.
Alternative Solutions
Maintain status quo, of logging error messages directly and adding a helper function when the error-messaging logic becomes too complicated.
Additional context
https://www.destroyallsoftware.com/talks/boundaries is a good talk, that's sorta related but not a source/inspiration of this idea.
The closest equivalent to this that I can think of, is taking the idea of the
deprecated
helper and applying it to pip's entire logging stack.The text was updated successfully, but these errors were encountered: