Precompile error with PlotlyJS and DataFrames

jekyllstein
Sat, 05 Aug 2023 20:45:22 +0000
General Usage

I have a package that won’t successfully precompile because one of the plot methods in PlotlyBase that is extended to DataFrames isn’t recognized during precompilation. The package has the following Project.toml

name = "PlotlyDFTest"
uuid = "cb693c1a-2323-4e7d-a59f-d847e178de62"
authors = *********
version = "0.1.0"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"

and the module source file is:

module PlotlyDFTest

using PrecompileTools, Reexport

@reexport using DataFrames, PlotlyJS

@setup_workload begin
        df = DataFrame(x = rand(10), y = rand(10))
        @compile_workload begin
                t = scatter(df; x = :x, y = :y, mode = "markers")
                plot(t)
        end
end

end # module PlotlyDFTest

When I try using this package I get the following error:

julia> using PlotlyDFTest
Precompiling PlotlyDFTest
  ✗ PlotlyDFTest
  0 dependencies successfully precompiled in 3 seconds. 73 already precompiled.

ERROR: The following 1 direct dependency failed to precompile:

PlotlyDFTest [cb693c1a-2323-4e7d-a59f-d847e178de62]

Failed to precompile PlotlyDFTest [cb693c1a-2323-4e7d-a59f-d847e178de62] to "/home/jason/.julia/compiled/v1.10/PlotlyDFTest/jl_qA0kg9".
ERROR: LoadError: MethodError: no method matching scatter(::DataFrames.DataFrame; x::Symbol, y::Symbol, mode::String)

Closest candidates are:
  scatter(; kwargs...)
   @ PlotlyBase ~/.julia/packages/PlotlyBase/4NWbR/src/api.jl:39
  scatter(::AbstractDict; kwargs...)
   @ PlotlyBase ~/.julia/packages/PlotlyBase/4NWbR/src/api.jl:40

Stacktrace:
...

However if I just do the following in the REPL there’s no problem:

julia> using DataFrames, PlotlyJS

julia> df = DataFrame(x = rand(10), y = rand(10))
10×2 DataFrame
 Row │ x         y
     │ Float64   Float64
─────┼─────────────────────
   1 │ 0.403774  0.450094
   2 │ 0.761454  0.538544
   3 │ 0.978787  0.0586694
   4 │ 0.309115  0.496085
   5 │ 0.715171  0.0809236
   6 │ 0.317805  0.349516
   7 │ 0.873211  0.597669
   8 │ 0.942189  0.194476
   9 │ 0.616944  0.435223
  10 │ 0.157878  0.870819

julia> t = scatter(df; x = :x, y = :y, mode = "markers")
scatter with fields mode, type, x, and y

This as well:

julia> let
       using DataFrames, PlotlyJS
       df = DataFrame(x = rand(10), y = rand(10))
       t = scatter(df; x = :x, y = :y, mode = "markers")
       plot(t)
       end
[ Info: Listening on: 127.0.0.1:6319, thread id: 1

I’m testing this in v"1.10.0-beta1" on x86_64 but I also experienced the same error on v1.9

1 post - 1 participant