-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[WIP] Fix for timeout in graph_model #3460
Conversation
This PR is almost right, I think, but somehow by changing the ancestor computation, I have changed the computation of the dimensions in graph rendering. |
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.
Given that you observed a change in the computed dimensions, could you add a new test to the test suite that checks if the computed dimensions match with what should be returned?
pymc3/model_graph.py
Outdated
# this contains all of the variables in the model EXCEPT var... | ||
vars: List[var] = set(self.var_list) | ||
vars.remove(var) | ||
|
||
upstream = self._ancestors(var, func) |
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 would completely remove self._ancestors
and replace it with the stack_search
that you did
@lucianopaz actually the dimension change was not an issue in the breadth first search -- it revealed an error in the code I used to debug the search! That's a relief. I will see if I can propose some tests, but I don't understand the test suite very well. |
@lucianopaz I have just looked over the existing tests for the model grapher, and they check the structure, including the identification of plates. So I think they are sufficient in their present form. There is no obvious test to add based on the fix, because the old version didn't compute the wrong thing; it simply didn't complete. But I am open to suggestions. Note: if this PR looks good, I should squash it before it's merged. |
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.
Everything looks fine to me. No other tests should be needed. Once _ancestors
is removed, just add a line to the release notes under maintenance and the PR should be ready to merge
pymc3/model_graph.py
Outdated
@@ -40,24 +47,32 @@ def _ancestors(self, var, func, blockers=None): | |||
return set([j for j in ancestors([func], blockers=blockers) if j in self.var_list and j != var]) |
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.
_ancestors
now seems to be unused, right? If so, it should be removed.
Previously, `get_ancestors()` used a powerset computation, which would fail on large models. Replaced with breadth-first search.
Per @lucianopaz. remove the initial special case/
@lucianopaz OK, I think this is done now. |
Great! Thanks a lot @rpgoldman! Once the tests pass, I'll merge |
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.
Oh, I had forgotten that you still need to add a line to RELEASE-NOTES.md under the maintenance section referencing the fixed issue
New Breadth-first search version of _get_ancestors no longer uses it. Also added some type annotations to clarify.
@lucianopaz Pushed the documentation and removed an unused import causing the check failure. |
Thanks again @rpgoldman! |
@lucianopaz No problem! I'm glad to be able to give even a little something back in exchange for all I've gotten from the community! |
Thanks @rpgoldman! |
See #3458