StatisticalRethinkingJulia / StatisticalRethinking.jl

Julia package with selected functions in the R package `rethinking`. Used in the SR2... projects.
MIT License
386 stars 32 forks source link

Error requiring `Turing` from `StatisticalRethinking` #164

Open dimsinel opened 2 weeks ago

dimsinel commented 2 weeks ago

Hello everyone.

Well, the title says it all.

If I run this a second time it does not give an error at all.

Pls see below the full error message. The order in which using Turring and using StatisticalRethinking appear is irrelevant. After the error message pls find a status report.

Cheers!

julia> using StatisticalRethinking

julia> using StatisticalRethinking: link

julia> using StatisticalRethinkingPlots

julia> using Turing
┌ Warning: Error requiring `Turing` from `StatisticalRethinking`
│   exception =
│    LoadError: UndefVarError: `TuringOptimExt` not defined
│    Stacktrace:
│      [1] include(mod::Module, _path::String)
│        @ Base ./Base.jl:495
│      [2] include(x::String)
│        @ StatisticalRethinking ~/.julia/packages/StatisticalRethinking/Bzph1/src/StatisticalRethinking.jl:1
│      [3] top-level scope
│        @ ~/.julia/packages/StatisticalRethinking/Bzph1/src/require/turing/turing.jl:7
│      [4] include(mod::Module, _path::String)
│        @ Base ./Base.jl:495
│      [5] include(x::String)
│        @ StatisticalRethinking ~/.julia/packages/StatisticalRethinking/Bzph1/src/StatisticalRethinking.jl:1
│      [6] top-level scope
│        @ ~/.julia/packages/Requires/Z8rfN/src/Requires.jl:40
│      [7] eval
│        @ ./boot.jl:385 [inlined]
│      [8] eval
│        @ ~/.julia/packages/StatisticalRethinking/Bzph1/src/StatisticalRethinking.jl:1 [inlined]
│      [9] (::StatisticalRethinking.var"#3#12")()
│        @ StatisticalRethinking ~/.julia/packages/Requires/Z8rfN/src/require.jl:101
│     [10] macro expansion
│        @ timing.jl:395 [inlined]
│     [11] err(f::Any, listener::Module, modname::String, file::String, line::Any)
│        @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:47
│     [12] (::StatisticalRethinking.var"#2#11")()
│        @ StatisticalRethinking ~/.julia/packages/Requires/Z8rfN/src/require.jl:100
│     [13] withpath(f::Any, path::String)
│        @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:37
│     [14] (::StatisticalRethinking.var"#1#10")()
│        @ StatisticalRethinking ~/.julia/packages/Requires/Z8rfN/src/require.jl:99
│     [15] #invokelatest#2
│        @ ./essentials.jl:892 [inlined]
│     [16] invokelatest
│        @ ./essentials.jl:889 [inlined]
│     [17] foreach(f::typeof(invokelatest), itr::Vector{Function})
│        @ Base ./abstractarray.jl:3097
│     [18] loadpkg(pkg::Base.PkgId)
│        @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:27
│     [19] #invokelatest#2
│        @ ./essentials.jl:892 [inlined]
│     [20] invokelatest
│        @ ./essentials.jl:889 [inlined]
│     [21] run_package_callbacks(modkey::Base.PkgId)
│        @ Base ./loading.jl:1169
│     [22] __require_prelocked(uuidkey::Base.PkgId, env::String)
│        @ Base ./loading.jl:1819
│     [23] #invoke_in_world#3
│        @ ./essentials.jl:926 [inlined]
│     [24] invoke_in_world
│        @ ./essentials.jl:923 [inlined]
│     [25] _require_prelocked(uuidkey::Base.PkgId, env::String)
│        @ Base ./loading.jl:1803
│     [26] macro expansion
│        @ ./loading.jl:1790 [inlined]
│     [27] macro expansion
│        @ ./lock.jl:267 [inlined]
│     [28] __require(into::Module, mod::Symbol)
│        @ Base ./loading.jl:1753
│     [29] #invoke_in_world#3
│        @ ./essentials.jl:926 [inlined]
│     [30] invoke_in_world
│        @ ./essentials.jl:923 [inlined]
│     [31] require(into::Module, mod::Symbol)
│        @ Base ./loading.jl:1746
│     [32] eval
│        @ ./boot.jl:385 [inlined]
│     [33] eval_user_input(ast::Any, backend::REPL.REPLBackend, mod::Module)
│        @ REPL ~/.julia/juliaup/julia-1.10.5+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:150
│     [34] repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
│        @ REPL ~/.julia/juliaup/julia-1.10.5+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:246
│     [35] start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
│        @ REPL ~/.julia/juliaup/julia-1.10.5+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:231
│     [36] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
│        @ REPL ~/.julia/juliaup/julia-1.10.5+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:389
│     [37] run_repl(repl::REPL.AbstractREPL, consumer::Any)
│        @ REPL ~/.julia/juliaup/julia-1.10.5+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:375
│     [38] (::Base.var"#1013#1015"{Bool, Bool, Bool})(REPL::Module)
│        @ Base ./client.jl:432
│     [39] #invokelatest#2
│        @ ./essentials.jl:892 [inlined]
│     [40] invokelatest
│        @ ./essentials.jl:889 [inlined]
│     [41] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
│        @ Base ./client.jl:416
│     [42] exec_options(opts::Base.JLOptions)
│        @ Base ./client.jl:333
│     [43] _start()
│        @ Base ./client.jl:552
│    in expression starting at ~/.julia/packages/StatisticalRethinking/Bzph1/src/require/turing/turing_optim_sample.jl:3
│    in expression starting at  ~/.julia/packages/StatisticalRethinking/Bzph1/src/require/turing/turing.jl:7
└ @ Requires ~/.julia/packages/Requires/Z8rfN/src/require.jl:51

Julia version 1.10.5

Status:


Status `~/Work/julia/rethinking/Project.toml`
  [cbdf2221] AlgebraOfGraphics v0.8.11
  [336ed68f] CSV v0.10.14
  [13f3f980] CairoMakie v0.12.11
  [324d7699] CategoricalArrays v0.10.8
  [8be319e6] Chain v0.6.0
  [a93c6f00] DataFrames v1.7.0
  [1313f7d8] DataFramesMeta v0.15.3
  [c9661210] DataSets v0.2.11
  [31c24e10] Distributions v0.25.112
  [634d3b9d] DrWatson v2.17.0
⌅ [366bfd00] DynamicPPL v0.24.11
  [1a297f60] FillArrays v1.13.0
  [da1fdf0e] FreqTables v0.4.6
  [38e38edf] GLM v1.9.0
  [cd3eb016] HTTP v1.10.8
  [682c06a0] JSON v0.21.4
  [5078a376] LazyArrays v2.2.1
  [c7f686f2] MCMCChains v6.0.6
  [f0e99cf1] MLBase v0.9.2
  [cc2ba9b6] MLDataUtils v0.5.4
  [90014a1f] PDMats v0.11.31
  [a68b5a21] ParetoSmooth v0.7.11
  [91a5bcdd] Plots v1.40.8
  [6f49c342] RCall v0.14.6
  [ce6b1742] RDatasets v0.7.7
  [860ef19b] StableRNGs v1.0.2
  [c1514b29] StanSample v7.10.1
⌅ [2913bbd2] StatsBase v0.33.21
  [4c63d2b9] StatsFuns v1.3.2
  [3eaba693] StatsModels v0.7.4
  [f3b207a7] StatsPlots v0.15.7
⌅ [fce5fe82] Turing v0.30.9
  [0004c1f4] TuringGLM v2.11.0
  [56ddb016] Logging```
goedman commented 1 week ago

Hi @dimsinel I think you need to include using Optim to activate the extension TuringOptimExt.

dimsinel commented 1 week ago

Hi @goedman .

No, this isn't enough to solve it. Maybe it also needs some other package too? (I will repeat that this is only a minor annoyance, going through it a second time seems to work.)

D