Stream: helpdesk (published)

Topic: Precompile functions behind `@requires`


view this post on Zulip Simon Christ (Mar 08 2022 at 14:20):

I try to add code to a module to have faster TTFX, but it seems I cannot do this for methods defined in a @required block.

module A
    using Plots
    plotlyjs()
    let
        Plots.plotlyjs_syncplot(plot(1:5))
    end
end

This gets me the error message

ERROR: LoadError: UndefVarError: plotlyjs_syncplot not defined
Stacktrace:
 [1] getproperty(x::Module, f::Symbol)
   @ Base ./Base.jl:35
 [2] top-level scope
   @ ~/.julia/dev/OCTOPOS/web/src/OCTOPOS_DASH.jl:310
 [3] include
   @ ./Base.jl:418 [inlined]
 [4] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
   @ Base ./loading.jl:1318
 [5] top-level scope
   @ none:1
 [6] eval
   @ ./boot.jl:373 [inlined]
 [7] eval(x::Expr)
   @ Base.MainInclude ./client.jl:453
 [8] top-level scope
   @ none:1

I get that this is most likely due to the worldage, but also using Base.invokelatest won't work for this purpose.
Is there any other way around it?


Last updated: Dec 28 2024 at 04:38 UTC