Skip to content
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

Easier visualisation of dependency graph? #786

Closed
maxalbert opened this issue May 15, 2019 · 2 comments · Fixed by #791
Closed

Easier visualisation of dependency graph? #786

maxalbert opened this issue May 15, 2019 · 2 comments · Fixed by #791
Labels
discussion FlowMachine Issues related to FlowMachine

Comments

@maxalbert
Copy link
Contributor

When looking at #784, I realised that calculate_dependency_graph produces a networkx graph of query dependencies but doesn't help much with actually visualising it. The docstring demonstrates how to export a .dot file, but this needs the external graphviz tool to actually visualise it (e.g. by converting to pdf).

It would be helpful to be able to draw dependency graph directly in a Jupyter notebook. Here is a useful snippet to export a dependency graph to a SVG, which can be rendered directly in the notebook:

import flowmachine
import networkx as nx
from flowmachine.features import daily_location
from flowmachine.utils import calculate_dependency_graph
from io import BytesIO
from IPython.display import SVG

flowmachine.connect(flowdb_user="flowdb", flowdb_password="flowflow", redis_password="fm_redis")

dl = daily_location(date="2016-01-01")

G = calculate_dependency_graph(dl)
A = nx.nx_agraph.to_agraph(G)
svg_str = BytesIO()
A.draw(svg_str, format="svg", prog="dot")
svg_str = svg_str.getvalue().decode("utf8")
svg = SVG(svg_str)

Would this be useful to provide as a helper in flowmachine? We probably want to avoid getting too fancy with dependency graph visualisation, but this seems like a useful addition. Thoughts?

@maxalbert maxalbert added FlowMachine Issues related to FlowMachine discussion labels May 15, 2019
@greenape
Copy link
Member

Could just update the example usage with this?

@maxalbert
Copy link
Contributor Author

Yeah, good point. If it turns out useful and we end up copying & pasting a lot we can still wrap it up in a helper function or class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion FlowMachine Issues related to FlowMachine
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants