diff --git a/src/parallelism.jl b/src/parallelism.jl index f5e495c..5dac1e0 100644 --- a/src/parallelism.jl +++ b/src/parallelism.jl @@ -57,7 +57,8 @@ end """ exec(x) -If `x` is a FileTree, computes any uncomputed `Thunk`s stored as values in it. Returns a new tree with the computed values. +If `x` is a `FileTree`, computes any uncomputed `Thunk`s stored as values in it. Returns a new tree with the computed values. +If `x` is a `File`, computes the value if it is a `Thunk`. Returns a new `File` with the computed value. If `x` is a `Thunk` (such as the result of a `reducevalues`), then exec will compute the result. If `x` is anything else, `exec` just returns the same value. """ @@ -71,5 +72,6 @@ Same as `exec(x)` with a ctx being passed to `Dagger` when computing any `Thunks exec(ctx, x) = x exec(ctx, d::FileTree) = mapexec(ctx, d, map=(f,t) -> mapvalues(f, t; lazy=false)) +exec(ctx, f::File) = setvalue(f, exec(ctx, f[])) exec(ctx, d::Union{Thunk, Chunk}) = collect(ctx, compute(ctx, d)) diff --git a/test/basics.jl b/test/basics.jl index f473136..7be1c35 100644 --- a/test/basics.jl +++ b/test/basics.jl @@ -200,6 +200,8 @@ end @test get(t1["a/b/a"]) isa Thunk @test get(exec(t1)["a/b/a"]) == string(p"."/"A"/"B"/"A") + # Exec a single File + @test get(exec(t1["a/b/a"])) == string(p"."/"A"/"B"/"A") @test exec(reducevalues(*, mapvalues(lowercase, t1))) == lowercase(exec(reducevalues(*, t1)))