Skip to content

Graph inspection ​

Use visualize to inspect dependencies and the recipes selected by a plan. Print code_expr when the question concerns the emitted Julia program.

Plan view ​

The graph below contains a value and its square. Selecting only the square retains the dependency on the value.

julia
using ReactiveKernels
using Main.Tutorials

@kernel shifted_square(x, shift) = begin
    value = x + shift
    squared = value^2
    return squared
end

selected = plan(shifted_square)
Tutorials.html(visualize(selected))

The visualization is generated from the current plan, so it changes whenever the plan does. A supplied intermediate input changes the plan boundary, so its producing recipe is no longer needed for that selection.

Generated expression ​

Print the actual expression returned by the prepared callable. Removing line annotations from a copy improves readability without changing the displayed operations.

julia
prepared = prepare(shifted_square; have=:value, want=:squared)
Tutorials.generated(prepared)
function (__constants__, __callables__, value::Any)
    squared = let var"#value#op1" = value
            var"#value#op1" ^ 2
        end
    return squared
end

The callable's output checks that the selected boundary consumes the supplied intermediate directly.

julia
prepared(4.0)

16.0

dot_source and save_visualization support exported graph views; see the reference for formats and keyword arguments. A saved view describes the plan that produced it and does not update when a different plan is prepared.

The bound-regression example places a generated dependency view beside its source, runtime outputs and numerical checks.