This repository was archived by the owner on Oct 26, 2026. It is now read-only.
Repository navigation
Make InfoTreeGenerator Prioritized - #92
Merged
gselzer merged 2 commits intoOct 18, 2023
Merged
Conversation
This allows us to sort them, and find the highest-priority
gselzer
deleted the
scijava/scijava-ops-engine/info-tree-generator-extensible
branch
October 18, 2023 18:41
ctrueden
reviewed
Oct 18, 2023
|
|
||
| @Override | ||
| default double getPriority() { | ||
| return Priority.NORMAL; |
Member
There was a problem hiding this comment.
@gselzer Make it makes sense for the Prioritized interface itself to have this default?
Member
Author
There was a problem hiding this comment.
I kinda like the fact that it doesn't - it makes you think about what the priority should be amongst the existing implementations. And there's the fact that this was the smallest necessary change to avoid our bug.
| if (suitableGenerators.size() > 1) throw new IllegalArgumentException( | ||
| "Signature " + signature + | ||
| " is able to be reified by multiple generators: " + suitableGenerators); | ||
| return suitableGenerators.get(0); |
Member
There was a problem hiding this comment.
What if the top two InfoTreeGenerator instances have the same priority? Should we fail fast? (I don't have an opinion, just pointing out that right now, on ties, one of them arbitrarily wins.)
Member
Author
There was a problem hiding this comment.
I'm going to say YAGNI for now
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@ctrueden noted here that current logic could throw errors if there are multiple InfoTreeGenerators that match a particular Op signature, and outlined two choices:
InfoTreeGenerator, so people can't implement it, and hardcode the priority.InfoTreeGenerators could reify the signature, choose the highest priority.This PR chooses option 2 as it is the less-API-breaking change, and because a priority-based system makes more sense than encoding an ordering by e.g. position in a
List. This PR doesn't hideInfoTreeGenerator, but it also does not prevent us doing so in the future, and I'm not particularly against hiding it until we decide we need it.Hiding
InfoTreeGeneratorwould be as simple as moving it to a non-exported package. I still believe we'd want to service-load the implementations, as otherwise we'd probably introduce sub-package dependencies, failing the build, but that should still work if we move the package of theInfoTreeGenerator.Closes scijava/scijava#87