Chain.jl error

@chain throws an error that I cannot understand. Please help. Thanks!
Code and error below:

julia> a = DataFrame(x=1:10, y=2:11)
10×2 DataFrame
 Row │ x      y     
     │ Int64  Int64 
─────┼──────────────
   1 │     1      2
   2 │     2      3
   3 │     3      4
   4 │     4      5
   5 │     5      6
   6 │     6      7
   7 │     7      8
   8 │     8      9
   9 │     9     10
  10 │    10     11

julia> @chain a begin
           _
       end
ERROR: LoadError: LoadError: MethodError: findall(::Chain.var"#1#2", ::Vector{Any}) is ambiguous. Candidates:
  findall(el::T, cont::Array{T, N} where N; returnTuple) where T in BetaML.Utils at /Users/rgoyal/.julia/packages/BetaML/cpTAz/src/Utils/Processing.jl:137
  findall(testf::Function, A) in Base at array.jl:2153
Possible fix, define
  findall(::T, ::Array{T, N} where N) where T<:Function
Stacktrace:
  [1] reconvert_docstrings!(args::Vector{Any})
    @ Chain ~/.julia/packages/Chain/h1xOi/src/Chain.jl:210
  [2] rewrite_chain_block(block::Expr)
    @ Chain ~/.julia/packages/Chain/h1xOi/src/Chain.jl:178
  [3] rewrite_chain_block(firstpart::Symbol, block::Expr)
    @ Chain ~/.julia/packages/Chain/h1xOi/src/Chain.jl:117
  [4] var"@chain"(__source__::LineNumberNode, __module__::Module, initial_value::Any, block::Expr)
    @ Chain ~/.julia/packages/Chain/h1xOi/src/Chain.jl:147
  [5] eval
    @ ./boot.jl:360 [inlined]
  [6] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:1116
  [7] invokelatest(::Any, ::Any, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./essentials.jl:708
  [8] invokelatest(::Any, ::Any, ::Vararg{Any, N} where N)
    @ Base ./essentials.jl:706
  [9] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.10/scripts/packages/VSCodeServer/src/eval.jl:211
 [10] (::VSCodeServer.var"#58#62"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.10/scripts/packages/VSCodeServer/src/eval.jl:155
 [11] withpath(f::VSCodeServer.var"#58#62"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.10/scripts/packages/VSCodeServer/src/repl.jl:185
 [12] (::VSCodeServer.var"#57#61"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.10/scripts/packages/VSCodeServer/src/eval.jl:153
 [13] hideprompt(f::VSCodeServer.var"#57#61"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.10/scripts/packages/VSCodeServer/src/repl.jl:36
 [14] (::VSCodeServer.var"#56#60"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.10/scripts/packages/VSCodeServer/src/eval.jl:124
 [15] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:491
 [16] with_logger
    @ ./logging.jl:603 [inlined]
 [17] (::VSCodeServer.var"#55#59"{VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.10/scripts/packages/VSCodeServer/src/eval.jl:201
 [18] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
 [19] invokelatest(::Any)
    @ Base ./essentials.jl:706
 [20] macro expansion
    @ ~/.vscode/extensions/julialang.language-julia-1.5.10/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
 [21] (::VSCodeServer.var"#53#54")()
    @ VSCodeServer ./task.jl:411

Very interesting. I cannot replicate. What version of Chain.jl are you using? Post the output of import Pkg; Pkg.status()

Thank you for your quick response. Package status is as follows:

import Pkg; Pkg.status()
      Status `~/.julia/environments/v1.6/Project.toml`
  [1520ce14] AbstractTrees v0.3.4
  [cbdf2221] AlgebraOfGraphics v0.6.3
  [024491cd] BetaML v0.5.6
  [336ed68f] CSV v0.10.2
  [13f3f980] CairoMakie v0.7.2
  [324d7699] CategoricalArrays v0.10.2
  [8be319e6] Chain v0.4.10
  [aaaa29a8] Clustering v0.14.2
  [35d6a980] ColorSchemes v3.16.0
  [5ae59095] Colors v0.12.8
  [a93c6f00] DataFrames v1.3.2
  [1313f7d8] DataFramesMeta v0.10.0
  [7806a523] DecisionTree v0.10.11
  [b4f34e82] Distances v0.10.7
  [31c24e10] Distributions v0.25.46
  [aaaaaaaa] DynamicAxisWarping v0.4.10
  [f6006082] EvoTrees v0.9.4
  [587475ba] Flux v0.12.9
  [c91e804a] Gadfly v1.3.4
  [7073ff75] IJulia v1.23.2
  [f7bf1975] Impute v0.6.8
  [b1bec4e5] LIBSVM v0.6.0
  [7acf609c] LightGBM v0.5.2
  [4345ca2d] Loess v0.5.4
  [add582a8] MLJ v0.17.1
  [a7f614a8] MLJBase v0.19.6
  [c6f25543] MLJDecisionTreeInterface v0.1.3
  [61c7150f] MLJLIBSVMInterface v0.1.4
  [d491faf4] MLJModels v0.15.2
  [5ae90465] MLJScikitLearnInterface v0.1.10
  [54119dfa] MLJXGBoostInterface v0.1.5
  [91a5bcdd] Plots v1.25.7
  [8162dcfd] PrettyPrint v0.2.0
  [d330b81b] PyPlot v2.10.0
  [ce6b1742] RDatasets v0.7.7
  [3646fa90] ScikitLearn v0.6.4
  [8523bd24] ShapML v0.3.1
  [2913bbd2] StatsBase v0.33.14
  [f3b207a7] StatsPlots v0.14.33
  [84d833dd] TransformVariables v0.5.0
  [44d3d7a6] Weave v0.10.10
  [009559a3] XGBoost v1.1.1
  [5b351978] Zalgo v1.2.0
  [10745b16] Statistics

I restarted julia and the error went away!

1 Like

It just happened to me. It happened when I loaded BetaML (indirectly via MLJ), eg,
Tree = @load DecisionTreeClassifier pkg = BetaML

It must overwrite some important method for Chain.jl when imported.

1 Like

Looks like BetaML is creating a method for findall that overlaps with the default from Base

findall(el::T, cont::Array{T, N} where N; returnTuple) where T in BetaML.Utils

Looks like type piracy

3 Likes