-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add bst graph command #1949
base: master
Are you sure you want to change the base?
Add bst graph command #1949
Conversation
Adds a new command to bst called 'graph' which reimplements the same API and functionality as contrib/bst-graph. The implementation details are within _stream.py as another function called 'graph'. Part of apache#1915.
24179c8
to
9faeca8
Compare
It can already be difficult to tell what's going on in large graphs. This commit helps make the graphs clearer and smaller. However this is no longer the same functionality as in the original contrib/bst-graph. Part of apache#1915.
This is no longer needed when reimplemented into buildstream itself. Part of apache#1915.
@ion232 is there anything else pending to mark this a non-draft? |
I'm not really in favor of having bst-graph at all. I think we should either:
Either of these approaches don't add a first class graphing feature but allow users to do more powerful things without requiring special buildstream features to do so... specifically this should be interesting if we add APIs for EDIT: It looks like this script already gets the work done with a single I find the output to be particularly horrible to look at for sufficiently big graphs (I've finally looked at one today, after all these years), I suspect that whatever useful things one might want to achieve by looking at this, could be better achieved with some scripting (e.g. perhaps a combination of Side note, the script does not work with junctions, it seems to be a simple quoting error that shouldn't be hard to fix.. That said I think we made the right choice keeping this in |
Not really. I was possibly going add some other features but didn't get around to it. I was waiting for feedback. |
Thanks for this script! I hit a small issue when using it on a complex buildstream project containing junctions. The generated graphviz ends up containing colons in the wrong place making it invalid. See small patch below that fixes the script base on a recommendation I found here https://graphviz.readthedocs.io/en/stable/manual.html#node-ports-compass diff --git a/contrib/bst-graph b/contrib/bst-graph
index 3fe93e1ff..5c05c6b4b 100755
--- a/contrib/bst-graph
+++ b/contrib/bst-graph
@@ -29,6 +29,7 @@ installed.
import argparse
import subprocess
import re
+import urllib.parse
from graphviz import Digraph
from ruamel.yaml import YAML
@@ -55,6 +56,10 @@ def parse_args():
return parser.parse_args()
+def escape(s):
+ return urllib.parse.quote_plus(s.encode())
+
+
def parse_graph(lines):
'''Return nodes and edges of the parsed grpah.
@@ -80,12 +85,13 @@ def parse_graph(lines):
build_dep = parser.load(build_dep)
runtime_dep = parser.load(runtime_dep)
- nodes.add(name)
- [build_deps.add((name, dep)) for dep in build_dep if dep]
- [runtime_deps.add((name, dep)) for dep in runtime_dep if dep]
+ safe_name = escape(name)
- return nodes, build_deps, runtime_deps
+ nodes.add((safe_name, name))
+ [build_deps.add((safe_name, escape(dep))) for dep in build_dep if dep]
+ [runtime_deps.add((safe_name, escape(dep))) for dep in runtime_dep if dep]
+ return nodes, build_deps, runtime_deps
def generate_graph(nodes, build_deps, runtime_deps):
'''Generate graph from given nodes and edges.
@@ -99,8 +105,8 @@ def generate_graph(nodes, build_deps, runtime_deps):
A graphviz.Digraph object
'''
graph = Digraph()
- for node in nodes:
- graph.node(node)
+ for tag, name in nodes:
+ graph.node(tag, label=name)
for source, target in build_deps:
graph.edge(source, target, label='build-dep')
for source, target in runtime_deps: |
@harrysarson This PR is about integrating the bst-graph script into buildstream proper. For fixes to the existing |
Closes #1915
EDIT: I've added another commit that changes the functionality to makes two separate graphs for buildtime and runtime, as this is clearer imo.