BSON.jl icon indicating copy to clipboard operation
BSON.jl copied to clipboard

BSON doesn't seem to work with Pluto.jl and DataFrames.jl

Open BoZenKhaa opened this issue 4 years ago • 4 comments

The following code

begin
	using BSON
	using DataFrames
	using DrWatson
	
	b = DataFrame(v = [1,2],l = ["a", "b"])
	DrWatson.save("./test.bson", Dict(:b=>b))
	
	BSON.load("./test.bson")
end

fails in Pluto notebook with

UndefVarError: DataFrames not defined

    (::BSON.var"#29#30")(::Module, ::String)@extensions.jl:20
    [email protected]:81[inlined]
    _foldl_impl(::Base.BottomRF{BSON.var"#29#30"}, ::Module, ::Vector{Any})@reduce.jl:58
    [email protected]:48[inlined]
    [email protected]:44[inlined]
    [email protected]:315[inlined]
    #mapreduce#[email protected]:310[inlined]
    #reduce#[email protected]:359[inlined]
    resolve(::Vector{Any})@extensions.jl:20
    (::BSON.var"#33#34")(::BSON.BSONDict)@extensions.jl:53
    _raise_recursive(::BSON.BSONDict, ::IdDict{Any, Any})@read.jl:79
    raise_recursive(::BSON.BSONDict, ::IdDict{Any, Any})@read.jl:89
    (::BSON.var"#43#44")(::BSON.BSONDict, ::IdDict{Any, Any})@extensions.jl:138
    raise_recursive(::BSON.BSONDict, ::IdDict{Any, Any})@read.jl:88
    (::BSON.var"#18#20"{IdDict{Any, Any}})(::BSON.BSONDict)@read.jl:82
    applychildren!(::BSON.var"#18#20"{IdDict{Any, Any}}, ::BSON.BSONDict)@BSON.jl:34
    _raise_recursive(::BSON.BSONDict, ::IdDict{Any, Any})@read.jl:82
    raise_recursive(::BSON.BSONDict, ::IdDict{Any, Any})@read.jl:89
    [email protected]:99[inlined]
    load(::String)@read.jl:104
    top-level scope@Local: 9

This code runs fine in REPL. When using JLD2, there is no problem in loading saved files, which makes me think this may be a BSON issue and not Pluto or DataFrames issue.

BoZenKhaa avatar Apr 01 '21 15:04 BoZenKhaa

This seems to be a duplicate of https://github.com/JuliaIO/BSON.jl/issues/25. Please use BSON.load("./test.bson", @__MODULE__)

haozhangphd avatar Apr 02 '21 20:04 haozhangphd

Thanks a lot for the tip! However, #25 seems to be closed?

BoZenKhaa avatar Apr 03 '21 20:04 BoZenKhaa

Yes it is closed by #91, but the default value of load(x, init=Main) can still cause confusions...

haozhangphd avatar Apr 04 '21 02:04 haozhangphd

Ok, thank you for clarification. I think it could be worthwhile to keep this issue open since the error message seems very cryptic, at least to me. Or should I close this?

BoZenKhaa avatar Apr 07 '21 10:04 BoZenKhaa