Skip to content

Commit f55e5f2

Browse files
authored
Merge pull request #3287 from starhel/fix-graph
Fixed visualization of SVG graph for tasks directly dependent on each…
2 parents b87e686 + c7964b8 commit f55e5f2

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

luigi/static/visualiser/js/graph.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ Graph = (function() {
146146
$.each(n.deps, function(i, dep) {
147147
if (nodeIndex[dep]) {
148148
var next_node = nodes[nodeIndex[dep]]
149-
var depth = (selfDependencies ? depth + 1 : classDepths[next_node.name])
150-
placeNodes(next_node, depth);
149+
var next_depth = (selfDependencies ? depth + 1 : classDepths[next_node.name])
150+
placeNodes(next_node, next_depth);
151151
}
152152
});
153153
}

luigi/static/visualiser/js/test/graph_test.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,27 @@ module("graph.js");
22

33
test("nodeFromTask", function() {
44
var task = {
5-
deps: ["B","C"],
6-
taskId: "A",
7-
status: "DONE"
5+
deps: ["B1","C1"],
6+
taskId: "A1",
7+
status: "DONE",
8+
name: "A",
9+
params: {},
10+
priority: 0,
811
};
912
var expected = {
10-
taskId: "A",
13+
taskId: "A1",
1114
status: "DONE",
12-
trackingUrl: "#A",
13-
deps: ["B","C"],
14-
depth: -1
15+
trackingUrl: "#A1",
16+
deps: ["B1","C1"],
17+
depth: -1,
18+
name: "A",
19+
params: {},
20+
priority: 0,
1521
};
16-
deepEqual(Graph.testableMethods.nodeFromTask(task), expected);
22+
let graph = {
23+
hashBase: "#"
24+
}
25+
deepEqual(Graph.testableMethods.nodeFromTask.bind(graph)(task), expected);
1726
});
1827

1928
test("uniqueIndexByProperty", function() {
@@ -70,7 +79,7 @@ test("computeRowsSelfDeps", function () {
7079
var rowSizes = Graph.testableMethods.computeRows(nodes, nodeIndex)
7180
equal(A1.depth, 0)
7281
equal(A2.depth, 1)
73-
equal(rowSizes, [1, 1])
82+
deepEqual(rowSizes, [1, 1])
7483
});
7584

7685
test("computeRowsGrouped", function() {
@@ -83,6 +92,8 @@ test("computeRowsGrouped", function() {
8392
var D2 = {name: "D", taskId: "D2", deps: [], depth: -1}
8493
var E1 = {name: "E", taskId: "E1", deps: [], depth: -1}
8594
var E2 = {name: "E", taskId: "E2", deps: [], depth: -1}
95+
var nodes = [A0, B0, C1, C2, D0, D1, D2, E1, E2]
96+
var nodeIndex = {"A0": 0, "B0": 1, "C1": 2, "C2": 3, "D0": 4, "D1": 5, "D2": 6, "E1": 7, "E2": 8}
8697
var rowSizes = Graph.testableMethods.computeRows(nodes, nodeIndex)
8798
equal(A0.depth, 0)
8899
equal(B0.depth, 1)
@@ -93,7 +104,7 @@ test("computeRowsGrouped", function() {
93104
equal(D2.depth, 3)
94105
equal(E1.depth, 4)
95106
equal(E2.depth, 4)
96-
equal(rowSizes, [1, 1, 2, 3, 2])
107+
deepEqual(rowSizes, [1, 1, 2, 3, 2])
97108
});
98109

99110
test("createGraph", function() {

0 commit comments

Comments
 (0)