JuliaParallel / Dagger.jl

A framework for out-of-core and parallel execution
Other
629 stars 67 forks source link

function show_plan not working #433

Closed JieRen98 closed 4 months ago

JieRen98 commented 11 months ago

Tested environment: Ubuntu22.04 and macOS 13.5.2

Julia version: 1.9.3

Error string:

ERROR: LoadError: MethodError: no method matching show_plan(::IOStream, ::Vector{TimespanLogging.Timespan}, ::Thunk)
Stacktrace:
 [1] (::Dagger.var"#140#141"{Thunk, Vector{TimespanLogging.Timespan}})(io::IOStream)
   @ Dagger ~/.julia/packages/Dagger/xGAvM/src/compute.jl:28
 [2] open(::Dagger.var"#140#141"{Thunk, Vector{TimespanLogging.Timespan}}, ::String, ::Vararg{String}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Base ./io.jl:395
 [3] open(::Function, ::String, ::String)
   @ Base ./io.jl:392
 [4] compute(ctx::Context, d::Thunk; options::Nothing)
   @ Dagger ~/.julia/packages/Dagger/xGAvM/src/compute.jl:27
 [5] compute(ctx::Context, d::Thunk)
   @ Dagger ~/.julia/packages/Dagger/xGAvM/src/compute.jl:22
 [6] top-level scope
   @ ~/JuliaProjects/show_plan/run.jl:39

Code:

using Pkg
Pkg.add("Dagger")
Pkg.add("TimespanLogging")

using Dagger
using TimespanLogging

ctx = Dagger.Sch.eager_context()
log = TimespanLogging.LocalEventLog()
ctx.log_sink = log

function taskA()
    println("In taskA")
    return "Executed A"
end

function taskB(x)
    println("In taskB")
    return "Executed B after " * x
end

function taskC(x)
    println("In taskC")
    return "Executed C after " * x
end

function taskD(x, y)
    println("In taskD")
    return "Executed D after " * x * " and " * y
end

a = Dagger.delayed(taskA)()
b = Dagger.delayed(taskB)(a)
c = Dagger.delayed(taskC)(a)
d = Dagger.delayed(taskD)(b, c)

# Execute the task graph
ctx.log_file = "out.svg"
result = Dagger.compute(ctx, d)
jpsamaroo commented 11 months ago

This probably needs to be documented better, but you now need to make sure you load Colors.jl manually (via using Colors) to get access to the show_plan implementation.

jpsamaroo commented 4 months ago

Now that #468 is merged, we have Dagger.show_logs and Dagger.render_logs - see the documentation (https://juliaparallel.org/Dagger.jl/dev/logging-visualization/#Logs-Visualization) for how to use these.