-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
MNT metadata routing: remove MethodMapping.from_str() and sort caller, callee in MethodPair()
#28422
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
MNT metadata routing: remove MethodMapping.from_str() and sort caller, callee in MethodPair()
#28422
Conversation
|
Looking at the diff, I'm not sure if this is simplifying things. The The CI fails and the prints are still there though. |
|
I have now removed the print statements (oh my) and added the and that I am not sure why the shorter output was expected and how to handle that yet. Edit: Concerning removing I think this is more explicit and easier to understand, since there are not several parallel ways of mapping methods together for the routing, but only one way. It's rather seldom that I believe that having only this one way to do the routing, that is readable even if you don't look into what |
I think this is similar to the way people can pass a string as a scorer, or a I think even allowing to pass a list instead of just a string would be okay, and the list results in a one to one mapping between caller and callee. |
thomasjpfan
left a comment
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.
I think even allowing to pass a list instead of just a string would be okay, and the list results in a one to one mapping between caller and callee.
Are you think of this API for a list of strings?
.add(method_mapping=["fit", "predict", "score"])It's not obvious to me that the mapping is "one-to-one" from fit to fit.
Maybe:
.add(method_mapping=MethodMapping().add_one_to_one(["fit", "predict", "score"]))Looking at the method_mapping="one-to-one" API with fresher eyes, I agree that "one-to-one" is a bit implicit. It's hard to tell from the code itself which methods are being routed.
|
Thanks for your insight, @thomasjpfan. 🔸 |
I think it's simple enough to infer "one-to-one" when there is only one method. But then there is a significant complexity jump for adding a second mapping. Concretely: .add(method_mapping="score")
# Adding the second mapping requires learning another object and syntax:
.add(method_mapping=method_mapping=MethodMapping()
.add(caller="score", callee="score")
.add(caller="predict", callee="predict"))For all one-to-one mappings, I am considering: # Single string for a single mapping:
.add(method_mapping=MethodMapping().add_one_to_one("score"))
# Add a second mapping by using a list:
.add(method_mapping=MethodMapping().add_one_to_one(["score", "predict"])) |
|
I agree we can remove |
|
I'm a bit frustrated with how this discussion goes. It's a PR, not an issue. There is a concrete proposal to discuss and new ideas need to be compared with the proposal. The goal of my proposal is to simplify the implementation of metadata routing by dropping two of three options for building the mapping for the routing. I had your verbal agreement for removing This is hardly used (8 times throughout the whole repo) and mainly in test files. sklearn/metrics/_scorer.py, l. 186 In the diff you can also see, that I have substituted it with another, already existing method. Inventing yet another method instead is not in accordance with the intention of this PR (which aims to simplify). |
|
We can only have a final agreement on a concrete implementation @StefanieSenger . It's normal that we see the implementation and we realize it doesn't look as good as we thought. In this particular case, I thought removing If you feel frustrated, it's okay to move to another issue / PR and let this rest a bit and you can come back to it with fresh eyes when you feel like it. Or close it and leave it for a later date. But the discussion here is a very normal and expected part of the development cycle. |
|
I'm sorry @adrinjalali and @thomasjpfan. Now I know that you were thinking and discussing about facilitating third party development rather than trying to keep I now don't know what I could do or provide to move this forward. Let's see which direction the discussion on #28467 will take. |
|
I'd need some guidance in translating the consensus from issue #28467 into this PR. Should I incorporate the creation of the new method here and replace Or keep the status quo, which is |
|
I think we can keep this PR as is (removing |
Co-authored-by: Adrin Jalali <[email protected]>
|
I merged Otherwise the PR LGTM. |
|
Got a conflict here. Could you fix please @StefanieSenger ? We can merge then. |
|
more conflicts here @StefanieSenger |
What does this implement/fix? Explain your changes.
This PR aims to simplify some things about the development side of metadata routing: how routing and consuming methods are mapped together.
It does not change any functionality, but rather helps to make the code more readable.
MethodMapping.from_str()and it's usage are removed from the entire codebase. The alternative functionality,MethodMapping.add()that was existing next to it already before, is now used instead. This ensures consistency and clarity.callerandcalleeinMethodPair()are consistently sorted so thatcallercomes first. These two have been kwarguments before, but putting caller always first supports code readability.These should have been two separate PRs really, I recognise. Merging these two things together happened by accident.