@@ -38,6 +38,30 @@ tab20_colors = [
3838]
3939_default_colors = tab20_colors
4040
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+
4165"""
4266 Dagger.render_logs(logs::Dict, ::Val{:graphviz}; disconnected=false,
4367 color_by=:fn, layout_engine="dot",
@@ -50,14 +74,26 @@ Requires the `all_task_deps` event enabled in `enable_logging!`
5074Options:
5175- `disconnected`: If `true`, render disconnected vertices (tasks or arguments without upstream/downstream dependencies)
5276- `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
5478- `times`: If `true`, annotate each task with its start and finish times
5579- `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
5682"""
5783function Dagger. render_logs (logs:: Dict , :: Val{:graphviz} ; disconnected= false ,
5884 color_by= :fn , layout_engine= " dot" ,
5985 times:: Bool = true , times_digits:: Integer = 3 ,
6086 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)
6197 # Lookup all relevant task/argument dependencies and values in logs
6298 g = SimpleDiGraph ()
6399
@@ -397,10 +433,7 @@ function Dagger.render_logs(logs::Dict, ::Val{:graphviz}; disconnected=false,
397433
398434 # Generate the final graph
399435 str *= " }\n "
400- gv = GraphViz. Graph (str)
401- GraphViz. layout! (gv; engine= layout_engine)
402-
403- return gv
436+ return str
404437end
405438
406439end
0 commit comments