-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
Nicer rule graph viz #7024
Nicer rule graph viz #7024
Conversation
This looks a lot more clear. |
The image looks great! Not for this change perhaps, but it would be great to generate an interactive, navigable visualization in HTML, so you can expand and collapse parts of the DAG etc. @TansyArron has been playing with such things in another context. |
I somehow missed @benjyw's comment until just now, and have absolutely been waiting to inject the web into this. It's my impression that graph drawing in things like d3.js and friends has figured out a lot of the things we might be doing here, so I'm going to spend a bit of time looking into how that might be done, which might allow us to supersede this as well. |
Hey @cosmicexplorer, could we try to revive this one please? I see there are a couple more improvements you wanted to make first, but I'd encourage us to merge what you have now (after rebase). Even though there are further ways to go, these changes could be making a meaningful impact today, and we can always have followup PRs. |
c1ba7b0
to
c77aa65
Compare
35b44ee
to
ca7219f
Compare
This should be ready for review assuming it passes CI! |
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.
Very happy with this change. It's gonna be a nice usability win for us when dealing with dot representations of rule graphs. Totally agree with @Eric-Arellano that this is worth merging as-is even if we're considering doing something fancier later.
left the same comment in a few places with a suggestion to enhance readibility by naming colors, but looks good to me overall.
entry_with_deps_str(e), | ||
// Color "singleton" entries (with no params) as a nice olive green! | ||
if e.params().is_empty() { | ||
Some("[color=\"0.2214,0.7179,0.8528\",style=filled]".to_string()) |
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.
Would need to test first, but I think this could be replaced with "olive" as graphviz seems to support the svg color scheme: https://www.graphviz.org/doc/info/colors.html.
This would improve readability imo compared to float based rgb. Alternatively, if you want something very specific, I find hex representation to be a bit more readable.
From reading graphviz's doc (https://www.graphviz.org/pdf/dotguide.pdf), I see that these three floating points represent hue, saturation and brightness; but that seems pretty unusual to me as the hue is generally an int form 0-360 degrees.
Pro-tip for finding what a color looks like from its name from the command line (assuming your terminal supports 256-bit colors, but of course it does, amirite? 😄 )
cargo install pastel
pastel color olive
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.
If this doesn't work out, storing the colors as constants like let olive = "0.576,0,0.6242"
would be great.
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've added a Palette
enum to support named colors. I kept the use of HSV for selecting these particular colors since I liked these colors specifically (in an attempt to compromise between brightness and not blocking out the graph node text), but I've left a comment next to the method that produces the color
string for each Palette
instance that any other color scheme can also be used to specify colors. I've added a link to https://www.graphviz.org/doc/info/colors.html in a comment as well.
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.
(and thank you for all the context!!!!!)
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.
Yay! Thank you so much for picking this back up!
Pardon that the rule graph errors PR causes some serious merge conflicts, here.
--
As discussed over DM, I do not think we want to change any of the output for the rule graph errors, i.e. only change the graph visualization.
For colors, it's tricky to get them right on a terminal where we cannot assume the background, unlike our assumption that the graph has a white background. Also, background colors are generally frowned upon with terminals afaict.
For new lines, this is also not ideal imo because we cannot assume the size of the terminal so it's unclear where we should wrap and where we shouldn't. Python will already soft wrap the rule graph errors for us, which I believe is the correct behavior.
entry_with_deps_str(e), | ||
// Color "singleton" entries (with no params) as a nice olive green! | ||
if e.params().is_empty() { | ||
Some("[color=\"0.2214,0.7179,0.8528\",style=filled]".to_string()) |
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.
If this doesn't work out, storing the colors as constants like let olive = "0.576,0,0.6242"
would be great.
One other thing is this comment: #7509 (comment) ... I think that it would significantly clarify the visualization to label the edges with Get/$Type, with the added bonus that it would shrink each node in the visualization. |
This would be great! However, please continue to render |
b903e47
to
8b940b2
Compare
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 updating this to not change rule graph errors!
6bb1abe
to
9ed3301
Compare
This should be ready for review once it passes CI. |
Would you mind updating the screenshots in the description? Thank you! |
9ed3301
to
854babd
Compare
Done!
I think this is a really good idea! I will see how easy it is to produce edge labels as well -- in a followup if not in this PR! |
854babd
to
4deba10
Compare
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.
fill in the color of root nodes to make them more noticeable! colorize non-inner nodes fix coloration and add some dummy __str__()s for singletons fix rule graph display tests remove last ??? string! clean up add special coloring for intrinsics! add helper methods to fix one out of the many failing tests! TODO: rest! make all test_rules.py tests pass!!! abstract out color selection vastly improve the use of vertical space in graph nodes remove now-unnecessary __str__ overrides add some comments remove is_intrinsic abstraction leak use dedent() in test_rules.py again!! move graph message utils to test_rules.py respond to review comments
6b4e1ec
to
2ddb1f7
Compare
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.
Looks great! Thanks!
Please wait for one more review from someone who can validate the Rust code, e.g. Pierre or Greg.
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.
A few style nitpicks, but definitely happy with the overall change and anxious to see it merged 😄
There's a clippy error in CI that doesn't show up locally, but making the change suggested by the clippy CI run appears to work, so going to push that change now and make sure it passes clippy. |
I recommend pulling master if you haven't recently. I think we upgraded to a new version of Rust recently and Clippy made some changes. |
I'd pulled master recently, just didn't realize I needed to rebase. Doing that now! |
It looks like this might have ended up affecting the "ambiguous rules to compute X" output:
|
Problem
When looking at @benjyw's comment thread with @stuhood on #6993, it seemed like it was difficult to create effective screenshots of the rule graph. This seemed to be for two reasons:
dot
outputs or that the OSX Preview app displays seems to be a bit off compared to other HSV selectors).Solution
{ ... }
in the.dot
file.TODO
Display
impls as noted by @stuhood below, and/or make clear the difference between string representations for diagnostics and errors vs strings for graph drawing.entry_node_str_with_attrs()
in much the same way as is done withentry_str()
andentry_node_str_with_attrs()
here.__str__()
implementations which currently have???
s.height
,width
,fixed-size
-- seedot(1)
.Get
s, as described in Nicer rule graph viz #7024 (comment).Result