From 44633e59207500a068f86534e4173bd1df0fc3af Mon Sep 17 00:00:00 2001 From: Michael Dales Date: Wed, 24 Apr 2024 19:43:16 +0100 Subject: [PATCH] Hide nodes in dot that have no side effects for now --- src/lib/block.ml | 4 +--- src/lib/dotrenderer.ml | 12 +++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lib/block.ml b/src/lib/block.ml index 088918db..c2ca24f7 100644 --- a/src/lib/block.ml +++ b/src/lib/block.ml @@ -72,9 +72,7 @@ let alias = function | `Publish _ -> invalid_arg "Expected body or run" | `Run b | `Build b -> b.alias -let hash = function - | `Publish _ -> None - | `Run b | `Build b -> b.hash +let hash = function `Publish _ -> None | `Run b | `Build b -> b.hash let kind = function | `Build _ -> `Build diff --git a/src/lib/dotrenderer.ml b/src/lib/dotrenderer.ml index fb8b407f..3115b08c 100644 --- a/src/lib/dotrenderer.ml +++ b/src/lib/dotrenderer.ml @@ -71,13 +71,23 @@ let render_ast_to_dot ppf hyperblocks : unit = Format.fprintf ppf "\tstyle = %s\n" style; Format.fprintf ppf "\tlabel = \"%s\"\n" name; + (* if commands have no obvious I/O remove them from the dot graph for now *) + let filtered_commands = + List.filter + (fun l -> + let ic = List.length (Leaf.inputs l) + and oc = List.length (Leaf.outputs l) in + ic + oc > 0) + commands + in + let renderer = match kind with | `Run -> render_command_to_dot | `Publish -> render_publish_to_dot | _ -> fun _a _b -> () in - List.iter (renderer ppf) commands; + List.iter (renderer ppf) filtered_commands; Format.fprintf ppf "}\n") hyperblocks;