shashi / FileTrees.jl

Parallel computing with a tree of files metaphor
http://shashi.biz/FileTrees.jl
Other
88 stars 6 forks source link

compute throws out of bounds error if values are not thunks #21

Closed DrChainsaw closed 4 years ago

DrChainsaw commented 4 years ago
julia> maketree("a" => [(name = "b", value=1)]) |> exec
ERROR: BoundsError: attempt to access 0-element Array{Any,1} at index [1]
Stacktrace:
 [1] getindex(::Array{Any,1}, ::Int64) at .\array.jl:809
 [2] (::FileTrees.var"#85#88"{Array{Any,1}})(::Int64) at ...julia\packages\FileTrees\2lYLo\src\parallelism.jl:30
 [3] (::FileTrees.var"#66#67"{Bool,FileTrees.var"#85#88"{Array{Any,1}}})(::File) at ...julia\packages\FileTrees\2lYLo\src\values.jl:48
 [4] #60 at ...julia\packages\FileTrees\2lYLo\src\values.jl:9 [inlined]
 [5] #postwalk#20 at ...julia\packages\FileTrees\2lYLo\src\datastructure.jl:322 [inlined]
 [6] #18 at ...julia\packages\FileTrees\2lYLo\src\datastructure.jl:318 [inlined]
 [7] iterate at .\generator.jl:47 [inlined]
 [8] _collect(::Array{File,1}, ::Base.Generator{Array{File,1},FileTrees.var"#18#19"{typeof(identity),FileTrees.var"#60#61"{FileTrees.var"#66#67"{Bool,FileTrees.var"#85#88"{Array{Any,1}}}}}}, ::Base.EltypeUnknown, ::Base.HasShape{1}) at .\array.jl:699
 [9] collect_similar(::Array{File,1}, ::Base.Generator{Array{File,1},FileTrees.var"#18#19"{typeof(identity),FileTrees.var"#60#61"{FileTrees.var"#66#67"{Bool,FileTrees.var"#85#88"{Array{Any,1}}}}}}) at .\array.jl:628
 [10] map(::Function, ::Array{File,1}) at .\abstractarray.jl:2162
 [11] postwalk(::FileTrees.var"#60#61"{FileTrees.var"#66#67"{Bool,FileTrees.var"#85#88"{Array{Any,1}}}}, ::FileTree; collect_children::typeof(identity)) at ...julia\packages\FileTrees\2lYLo\src\datastructure.jl:318
 [12] postwalk(::Function, ::FileTree) at ...julia\packages\FileTrees\2lYLo\src\datastructure.jl:318
 [13] #mapvalued#59 at ...julia\packages\FileTrees\2lYLo\src\values.jl:9 [inlined]
 [14] #mapvalues#65 at ...julia\packages\FileTrees\2lYLo\src\values.jl:48 [inlined]
 [15] compute(::Dagger.Context, ::FileTree; cache::Bool, kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at ...julia\packages\FileTrees\2lYLo\src\parallelism.jl:28
 [16] #compute#81 at ...julia\packages\FileTrees\2lYLo\src\parallelism.jl:13 [inlined]
 [17] exec(::FileTree) at ...julia\packages\FileTrees\2lYLo\src\parallelism.jl:34
 [18] |>(::FileTree, ::typeof(exec)) at .\operators.jl:834
 [19] top-level scope at REPL[150]:1
 [20] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1088

The problem seems to be that compute first ignores non-Thunks when pushing to vals, but then assumes that each value was put in vals. Should the same if x isa Thunk check not be made in the second mapvalues?