First steps with Dagger

I am moving my first steps with Dagger.jl and I need some help.
The following code works fine

using Dagger
using Distributed
addprocs(4)
@everywhere using Dagger
@everywhere function f(x) 
	println(x)
	x
end

a = delayed(f)(1)
b = delayed(f)(2)
p = delayed(+)(a,b)
r = delayed(f)(3)
s = delayed(f)(4)
t = delayed(+)(p,r,s)

collect(t)
> From worker 4:    3
> From worker 5:    4
> From worker 3:    2
> From worker 2:    1
10

However I want to run the different tasks without aggregation function - e.g. in the previous scenario, I want t to be fired whenever p, r & s are completed, regardless of their results.

Also, when I try to use compute rather than collect I get this error:

compute(Context, t)
ERROR: type DataType has no field log_sink
Stacktrace:
 [1] getproperty at .\sysimg.jl:15 [inlined]
 [2] timespan_start(::Type, ::Symbol, ::Int64, ::OSProc) at C:\depot\packages\Dagger\sdZXi\src\lib\logging.jl:121
 [3] compute_dag(::Type, ::Thunk) at C:\depot\packages\Dagger\sdZXi\src\scheduler.jl:24
 [4] compute(::Type, ::Thunk) at C:\depot\packages\Dagger\sdZXi\src\compute.jl:25
 [5] top-level scope at none:0

What am I doing wrong?

Thanks

It’s Context(), not Context :slight_smile: You should also just be able to call compute(t), as Context() will be added in automatically via dispatch. Note that compute only returns a Chunk or Thunk, and you’ll eventually need to call collect() on the result to get your actual result.

2 Likes

Of course it was something silly :man_facepalming: thanks for your help :slight_smile: