-
Notifications
You must be signed in to change notification settings - Fork 135
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
[issue-558] add visualization feature #562
Conversation
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 for this! :)
I've left a few change requests and comments below.
Ehmmm... a more general question: why did you choose to use I mean, it's nice to have everything inside your code, but you then will have to eventually expose all functions somehow (e.g., produce SVG, produce PDF, scale factor, use different layout engine, etc., etc.) The alternative would be: import graphviz
g = graphviz.Digraph('SPDX diagram', filename=fname_out)
for e in element_list:
g.node(e.id, label=e.name)
for r in relationship_list:
g.edge(r.from, r.to)
g.save()
# g.view() if you want |
We also want to expose functions to convert to networkx. This is helpful to work with the complex data. |
Ah, ok. Then this is not about "visualization", the requirement is to have the graph in networkx. |
According to the comments I restructured and renamed the methods and the description in the markdown. This PR now adds functionality to create a relationship graph from the document which can be rendered to a picture for visualization but doesn't have to be. I hope this fits the comments. |
9e01519
to
aafb5e7
Compare
f04cbce
to
e3228a5
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.
Just a few more comments regarding wording.
One "advantage" of the current approach is that you can do both conversion and graph generation in one. I'm not sure, though, if this is actually something to be avoided. I don't have strong feelings either way. |
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! :)
My vote is for
It's better to be consistent with treating Addiotnally, please rethink the Ehhmmm, wait a minute: is it an option or a subcommand? Apologies for not checking, but is the rest of functionality invoked as |
The rest is invoked as options, e.g. |
related_spdx_element_id = str(relationship.related_spdx_element_id) | ||
|
||
if related_spdx_element_id not in graph.nodes(): |
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.
What is the intended behavior of NOASSERTION/NONE Nodes? The way I understand this, there will be only a single one in the whole graph that all relationships that have NOASSERTION/NONE in them will point to. Is that the way it should be?
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.
Your interpretation for the current implementation is correct. I don't have an opinion on how it should be. In the current use case we would transform the generated graph to a tree, so I didn't worry about it. But probably it would be better (clearer, in relation to a picture) to have individual NOASSERTION nodes for each relationship.
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 good to me now, only a minor remark
|
||
elif graph: | ||
try: | ||
export_graph_from_document(document, outfile) |
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.
Maybe insert a catch that outfile
must be set, i.e. not None
, and inform the user about it?
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.
sounds like a nice to have. Would merge it now
d596d5b
to
e34d047
Compare
Signed-off-by: Meret Behrens <meret.behrens@tngtech.com>
e34d047
to
02175bb
Compare
This PR adds some functionality to visualize the structure of a SPDX document. The visualization includes the SPDXIDs of all elements in the document (
Package
,File
,Snippet
and any external SPDXIDs) and their connection based on the provided relationships. The new logic converts aDocument
to apygraphviz
AGraph
which can either be stored in a.dot
file or rendered to an image e.g. a.png
.