@@ -38,6 +38,30 @@ tab20_colors = [
38
38
]
39
39
_default_colors = tab20_colors
40
40
41
+ """
42
+ Dagger.show_logs(io::IO, logs::Dict, ::Val{:graphviz}; disconnected=false,
43
+ color_by=:fn, times::Bool=true, times_digits::Integer=3)
44
+
45
+ Write a graph of the task dependencies and data dependencies in `logs` to dot format
46
+
47
+ Requires the following events enabled in `enable_logging!`: `taskdeps`, `tasknames`, `taskargs`, `taskargmoves`
48
+
49
+ Options:
50
+ - `disconnected`: If `true`, render disconnected vertices (tasks or arguments without upstream/downstream dependencies)
51
+ - `color_by`: How to color tasks; if `:fn`, then color by unique function name, if `:proc`, then color by unique processor
52
+ - `times`: If `true`, annotate each task with its start and finish times
53
+ - `times_digits`: Number of digits to display in the time annotations
54
+ - `colors`: A list of colors to use for coloring tasks
55
+ - `name_to_color`: A function that maps task names to colors
56
+ """
57
+ function Dagger. show_logs (io:: IO , logs:: Dict , :: Val{:graphviz} ; disconnected= false ,
58
+ color_by= :fn , times:: Bool = true , times_digits:: Integer = 3 ,
59
+ colors= _default_colors, name_to_color= _name_to_color)
60
+ dot = logs_to_dot (logs; disconnected, times, times_digits,
61
+ color_by, colors, name_to_color)
62
+ println (io, dot)
63
+ end
64
+
41
65
"""
42
66
Dagger.render_logs(logs::Dict, ::Val{:graphviz}; disconnected=false,
43
67
color_by=:fn, layout_engine="dot",
@@ -50,14 +74,26 @@ Requires the `all_task_deps` event enabled in `enable_logging!`
50
74
Options:
51
75
- `disconnected`: If `true`, render disconnected vertices (tasks or arguments without upstream/downstream dependencies)
52
76
- `color_by`: How to color tasks; if `:fn`, then color by unique function name, if `:proc`, then color by unique processor
53
- - `layout_engine`: The layout engine to use for GraphViz
77
+ - `layout_engine`: The layout engine to use for GraphViz rendering
54
78
- `times`: If `true`, annotate each task with its start and finish times
55
79
- `times_digits`: Number of digits to display in the time annotations
80
+ - `colors`: A list of colors to use for coloring tasks
81
+ - `name_to_color`: A function that maps task names to colors
56
82
"""
57
83
function Dagger. render_logs (logs:: Dict , :: Val{:graphviz} ; disconnected= false ,
58
84
color_by= :fn , layout_engine= " dot" ,
59
85
times:: Bool = true , times_digits:: Integer = 3 ,
60
86
colors= _default_colors, name_to_color= _name_to_color)
87
+ dot = logs_to_dot (logs; disconnected, times, times_digits,
88
+ color_by, colors, name_to_color)
89
+ gv = GraphViz. Graph (dot)
90
+ GraphViz. layout! (gv; engine= layout_engine)
91
+ return gv
92
+ end
93
+
94
+ function logs_to_dot (logs:: Dict ; disconnected= false , color_by= :fn ,
95
+ times:: Bool = true , times_digits:: Integer = 3 ,
96
+ colors= _default_colors, name_to_color= _name_to_color)
61
97
# Lookup all relevant task/argument dependencies and values in logs
62
98
g = SimpleDiGraph ()
63
99
@@ -397,10 +433,7 @@ function Dagger.render_logs(logs::Dict, ::Val{:graphviz}; disconnected=false,
397
433
398
434
# Generate the final graph
399
435
str *= " }\n "
400
- gv = GraphViz. Graph (str)
401
- GraphViz. layout! (gv; engine= layout_engine)
402
-
403
- return gv
436
+ return str
404
437
end
405
438
406
439
end
0 commit comments