-
Notifications
You must be signed in to change notification settings - Fork 189
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
Enhanced graphviz functionality #2596
Conversation
Oh and I've just noticed the actual name of the file would need to be change |
and if you were to get really fancy; |
@chrisjsewell very cool! |
Very nice! Indeed let's discuss in person - I'd also like to brainstorm if we can unify in a single place the routines to describe a node (e.g. we now have I.e., we should probably have a "visualiser" class that for every class know what an how to visualise it (and I see some possibilities to merge with @chrisjsewell idea of 'style' entry points). |
@ltalirz @sphuber @giovannipizzi I have updated this module to be compatible with the current
The default mapping functions can also be overridden by the user, on instantiation of the Below, I attach a notebook and screenshot, replicating your |
Yeh as I've mentioned, I added the functionality, for it to be fairly easy to change styles, at the user level. So I'm not necessarily to bothered what the defaults are, as I may choose not to use them :)
You could maybe mix them (using different background/font colors), but that gets a bit messy. Perhaps I should add an easy way of switching? |
Ok, in b0c2be0, I have applied @ltalirz's style format. I have also merged From
and obviously, you can just copy one of these functions, and make your own style very easily. |
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.
Dear @chrisjsewell, thank you so much for implementing all these changes!
Here come my final comments, after this I'm happy to merge:
- I'm now getting the following warnings - not quite sure why?
verdi graph generate 31317b2e-d126-4fdc-a2a8-80f1a9aa773b
Info: Initiating graphviz engine: dot
Info: Recursing ancestors, max depth=None
Info: Recursing descendants, max depth=None
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Warning: gvrender_set_style: unsupported style rectangle - ignoring
Success: Output file: 32.dot.pdf
- Please add a uuid/pk switch at the command line as well. I would personally even vote to make uuid the default but that is not an issue as long as one can easily switch (something like
--id-label
) - Could we move to a color different from white for workfunctions? Something that looks related to the color of the WorkChain?
- My style, by default, removed the borders of the shapes because I feel they are just adding lines that aren't really needed (?)
- Do we still want to add the hint on the status of process nodes by adding a red/yellow/green border for those?
Thanks @ltalirz
Oops, there was a typo in specifying styles for
It was white because of the above error, should be the same color as WorkChains now
added in 9076f2b
fixed in a8f6009
I leave that up to you, @giovannipizzi and @sphuber? |
@chrisjsewell Thanks, for me it's good to merge I would simply "squash & merge" if that's OK with you. |
Yep "squash & merge" will be fine thanks @ltalirz |
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.
Just some minor comments/questions. Other than that I'd be happy to merge this. Great work @chrisjsewell and thanks a lot for all the reviewing @ltalirz ! 👍
def generate(root_node, link_types, id_label, ancestor_depth, descendant_depth, process_out, process_in, engine, | ||
verbose, output_format, show): | ||
""" | ||
Generate a graph from a ROOT_NODE (specified by pk or uuid). |
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 technically the node label could also be used. Granted it won't be that common. I think it would maybe be better to use the term "identifier". This is used across the CLI to mean one of PK, UUID, or label.
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.
fixed in 6e599e9
aiida/cmdline/commands/cmd_devel.py
Outdated
'aiida.transports', | ||
'aiida.tools.dbimporters.plugins', | ||
'aiida.cmdline.utils', 'aiida.cmdline.params.types', 'aiida.cmdline.params.options', 'aiida.common', | ||
'aiida.schedulers', 'aiida.transports', 'aiida.tools.dbimporters.plugins', 'aiida.tools.visualization' |
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 all the tests are actually in the module aiida.backends
correct? And I don't see any in aiida.tools.visualization
, so it is not necessary to add it here
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.
fixed in 6e599e9
aiida/tools/visualization/graph.py
Outdated
"process.calculation.calcjob.CalcJobNode.": { | ||
"shape": "ellipse", | ||
"style": "filled", | ||
# "pencolor": "black", |
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 we are not using the pencolor, maybe get rid of the commented out code
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.
fixed in 6e599e9
aiida/tools/visualization/graph.py
Outdated
node_style['fillcolor'] = '#de707fff' # red | ||
elif node.is_finished_ok: | ||
node_style['fillcolor'] = '#8cd499ff' # green | ||
else: # specifically look for waiting state? |
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.
Note that this conditional will hit the states CREATED
and RUNNING
as well. Think that the same color as WAITING
is fine, just thought I'd mention it. Maybe update the comment to include them
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.
fixed in 6e599e9
""" | ||
# pylint: disable=too-many-branches | ||
|
||
class_node_type = node.class_node_type |
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 take it this code can be cleaned up when we address #3087 and we define a node method that will provide this type of descriptor?
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.
Yes indeed. Basically all the node classes should supply their own (default) description, and this function (which is injected into the Graph
class) can just be used by the user, to override any descriptions they wish.
@sphuber Looks to me like your points have been addressed |
Thanks a lot to both ! |
The `python-graphviz` package is employed to simplify the code that can build a visual representation of a sub set of the provenance graph. The main graphing function is rewritten as a class, which: * maintains a cache of the added nodes and graphs (as sets) * splits up the function and allows for multiple additions to the graph * has separate `_style_` functions for different node classes This gives larger control to define the graph that is to be visualized as well as the style to be used. The current style is adapted to resemble that of the documentation for a coherent look.
The `python-graphviz` package is employed to simplify the code that can build a visual representation of a sub set of the provenance graph. The main graphing function is rewritten as a class, which: * maintains a cache of the added nodes and graphs (as sets) * splits up the function and allows for multiple additions to the graph * has separate `_style_` functions for different node classes This gives larger control to define the graph that is to be visualized as well as the style to be used. The current style is adapted to resemble that of the documentation for a coherent look.
fix #2585
So I don't expect this to be merged any time soon,
since all the tests would need to be rewritten (plus style fixes).
But the basic idea is I've:
_repr_svg_()
method for rendering in the notebook._style_
functions for different node classesHere are two examples of using it in the notebook.
The first is a replication of the original function, with some extras.
The second is new functionality, that was the original reason I started writing this.
It visualizes a root node and filtered connecting nodes, without any intermediate connections.