temp scripts draft
authorDustin J. Mitchell <dustin@mozilla.com>
Mon, 08 May 2017 22:53:34 +0000
changeset 583735 63bf4fbe6633376d3b64d8263dd3d6372a33d384
parent 583734 6b8e90669aa8cb2ba791dd7502116a49c4898862
child 630177 c93194c8ff82307c498632cd94cf48af8f613ee7
push id60519
push userdmitchell@mozilla.com
push dateWed, 24 May 2017 14:40:11 +0000
milestone55.0a1
temp scripts MozReview-Commit-ID: Gg516lxJfYq
gather.sh
graphdiff.py
new file mode 100644
--- /dev/null
+++ b/gather.sh
@@ -0,0 +1,9 @@
+time=$1
+if [ -z "$time" ]; then
+    echo no time;
+    exit 1
+fi
+
+set -e
+
+./mach taskgraph tasks -p parameters.yml -J > $time.json
new file mode 100644
--- /dev/null
+++ b/graphdiff.py
@@ -0,0 +1,83 @@
+import json
+import difflib
+import sys
+import os
+
+def relabel(graph):
+    'restore the original labels, based on task.metadata.name'
+    newgraph = {}
+    changes = {}
+    for old, t in graph.iteritems():
+        new = t['task']['metadata']['name']
+        if new in newgraph:
+            raise Exception("duplicate label %s for %s / %s" % (new, t['label'], newgraph[new]['label']))
+        changes[old] = new
+        newgraph[new] = t
+    return newgraph, changes
+
+def remove_stuff(graph):
+    for t in graph.itervalues():
+        del t['attributes']
+        try:
+            del t['task']['payload']['properties']['upload_to_task_id']
+        except KeyError:
+            pass
+        try:
+            del t['task']['routes']
+        except KeyError:
+            pass
+        try:
+            del t['optimizations']
+        except KeyError:
+            pass
+    return graph
+
+def compare():
+    graph1 = json.load(open("before.json"))
+    graph2 = json.load(open("after.json"))
+
+    graph1 = remove_stuff(graph1)
+    graph2 = remove_stuff(graph2)
+
+    print("comparing {} tasks".format(len(graph1)))
+
+    diff = False
+
+    only1 = set(graph1) - set(graph2)
+    only2 = set(graph2) - set(graph1)
+    for task in sorted(only1 | only2):
+        if task in only1:
+            print "-" + task
+            del graph1[task]
+            diff = True
+        else:
+            print "+" + task
+            del graph2[task]
+            diff = True
+
+    graph1 = json.dumps(graph1, indent=4, sort_keys=True)
+    graph2 = json.dumps(graph2, indent=4, sort_keys=True)
+
+    graph1 = graph1.split('\n')
+    graph2 = graph2.split('\n')
+
+    if graph1 != graph2:
+        difflines = 0
+        for line in difflib.unified_diff(graph1, graph2, fromfile="before", tofile="after", lineterm='', n=4):
+            diff = True
+            difflines += 1
+            print line
+            # give up after a while..
+            if difflines > 100:
+                break
+
+    if not diff:
+        print("no diff")
+    else:
+        sys.exit(1)
+
+def main():
+    compare()
+
+main()
+