-
Notifications
You must be signed in to change notification settings - Fork 7
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
Resolves #71 including fixes from downstream depenedencies #72
Draft
nimakarimipour
wants to merge
1
commit into
master
Choose a base branch
from
nimak/issue-71
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
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.
So, hard to tell without a test case, but won't this apply every fix in target that is part of the fix tree, even if intermediate fixes aren't applied?
Basically, the logic here is: Traverse the entire fix of trees and keep the root fix and any fix for a triggered error from a downstream dependency, but eliminate the fixes in between.
But I think the logic we want is: Keep the root fix, then, for each child (fix caused by an error triggered by the root fix) keep the child iff the child is a fix for a triggered error from a downstream dependency, then recurse on its children (equivalently: we prune from the tree all paths that pass through fixes other than the root fix originating from errors in the target).
Consider for example:
Assume a large enough
DEPTH
.With tree-at-a-time, we get:
With the algorithm as implemented and fix-at-a-time, we get:
Because the change to
foo()
is the root fix, and all changes to the arguments ofbar
andbaz
derive from errors inDep
.BUT, what I'd expect from fix-at-a-time is:
(No errors left of
Dep
, without adding extra fixes that aren't either the root fix or needed to avoid immediate errors inDep
)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.
Thank you for your note and the example to describe that. Actually I thought about this issue, however, I think even in this case the output result will be the same. We annotate a module iteratively. If both fixes on
bar()
return andbar()
param exists in the original fix tree, that means if paramo
is annotated as@Nullable
fix for makingbar()
@Nullable
will be triggered. Therefore even in this example, if we modify the algorithm to apply only the fixes you mentioned, in the next iteration annotator still annotatesbar()
as@Nullable
and the final output will be identical to our current approach.Also we currently do not store the map of
fix
tofix
storing the whichfix
triggered whichfix
instance in tree. We just hold a set of fixes and a set of triggered fixes. To construct that, we need to apply coloring within trees itself. Please let me know if that makes sense or I am missing something thank you 🙂 .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 still think that what the example above shows is that the intermediate state after applying "a single fix" is incorrect. It is true that the example above would probably converge to the same annotations in the fix-at-a-time and tree-at-a-time modes, but nothing guarantees that in the general case, and meanwhile it seems to me that the intermediate state of the code is very much an unexpected one (there are 'fixes'/annotations that were added but would produce no errors anywhere if they were removed).
If we need to apply this hack now to have a reasonable result from the auto-annotator internally, I'd say we do it, for now, but it still feels to me that the correct solution here if we have trees of fixes is to actually have the trees represented somewhere within the report and pruning them in the fix-at-a-time case. I don't see what that has to do with coloring, all you need to know is, when you add fixes to the set of fixes
Set<Fix> tree
(?), which was the fix that triggered the error that required adding the fix, so it seems to me that the structure could be an actual tree, rather than a flat set. Am I missing something here?cc: @msridhar
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 it definitely worths to convert the tree flat structure to actual tree, however, it is still impossible to have a map of fix to fix and by that I mean, there might be two fixes in the tree that trigger the same fix and both be in the same region.
Please consider the class below:
The root fix is
f0
, it continues with annotatingf1
andf2
to@Nullable
and in the end whenf0
,f1
andf2
is@Nullable
, we get to annotatebar()
andbaz()#param
as@Nullable
. Hence, we can't mapf1
orf2
as parent for fix makingbar()
return@Nullable
and justf2
parent for makingbaz()#param
@Nullable
. (From Annotators perspective,f1
andf2
both are cause of makingbaz()#param
as@Nullable
).The tree in theory: (to construct this we need to apply
f1
andf2
separately, coloring within trees).However, we can still have a proximation of the tree as below with our current implementation:
And I think we can deliver the requested output with this tree, will update this PR shortly. Please let me know if I missed anything. Thank you.
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.
But I don't fully understand that how is it possible that we remove a fix from tree and see no triggered errors, they are only in the tree if they resolve a specific error.
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.
Trying to catch up on this discussion, sorry if the questions don't make sense.
For your example, @nimakarimipour:
Since this code returns
f0
, shouldn't there be an edge fromf0
tobar()
(return) in the ideal tree?Also: can we just use tree-at-a-time in the internal deployment to solve this problem? I'm not sure why fix-at-a-time is being used.
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.
See the example I gave above, I am pretty sure that after one iteration of applying annotations with the current code here, you'd get:
There, you can remove the
@Nullable
on the argument ofbaz(...)
and will get no additional error comparing to the code with the annotation.(Your existing errors are both about the return of
bar
andbaz
, but not aboutbaz(...)
being passednull
, because, as that code is written, the expressiont.bar(t.foo())
is@NonNull
locally)Ok, that's a DAG. And I imagine your argument here is that we don't explicitly construct the edges of the DAG currently and that doing so would be costly (i.e. require new calls to the build)? Or, technically, we could construct a spanning tree of the DAG as we go along, but there would be paths missing for the full DAG. If that's the case, we might need to think about how fixes are added to the set, so that if there are any edges forced by errors on the downstream dependencies, then those edges must be included in the generated spanning tree. Alternatively, you have the model you built for the downstream dependencies, so you could query it once you have the root node and rebuild the part of the tree forced only by said root node and by errors reported in downstream dependencies, no? Without any new builds required.
Either way: I think this is an important discussion and a potential bug on this PR, but for the sake of getting something running end-to-end internally this week, I'd vote on landing this version. I still think we need an issue to track this discussion (possibly #71 itself).
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.
@msridhar sorry for the wrong example, Please find the updated version. I replaced
f0
withf2
.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.
Thanks @nimakarimipour I'd still like to understand why the fix-at-a-time config is important for the scenario of downstream modules, as opposed to just using tree-at-a-time.
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 we decided, a long time ago, to use fix-at-a-time because any tradeoff of human effort for tool runtime within reason is worth it for us here, and there is some evidence that fix-at-a-time converges to slightly better answers than tree-at-a-time in some cases. That said, at this point, if fix-at-a-time is broken and tree-at-a-time isn't, I'd be fine with switching the default internally, cutting a
-LOCAL
release here and landing the internal diff by evening tomorrow (some changes are needed on the diff/python wrapper independent of this, but I am on it right now).