Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exec for Files #70

Merged
merged 2 commits into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/parallelism.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand All @@ -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))
2 changes: 2 additions & 0 deletions test/basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down