Problem loading old JLD files with "Bool" properties

#1

Hi,

I’m trying to load some old JLD files that were created in Julia 0.6 for use in Julia 1.1, however there seems to be issue with loading the Bool .

I have a small sample to demonstrate

Created in 0.6

using JLD

mutable struct foo
    is_true::Bool
    name::String
end

a= foo(true, "Test true")

file_path =  "c:\\temp\\foo.jld"
file_dir, file_name = splitdir(file_path)
file_prefix, file_ext = splitext(file_name)

JLD.save(file_path, file_prefix, a, compress=false)

Load in Julia 1.1

obj = JLD.load(file_path, file_prefix)

stored type Core.Bool does not match currently loaded type

Stacktrace:
 [1] macro expansion at .\logging.jl:320 [inlined]
 [2] jldatatype(::JLD.JldFile, ::HDF5.HDF5Datatype) at C:\Program Files\ReSolver.DistributedJulia\depot\packages\JLD\1BoSz\src\jld_types.jl:703
 [3] macro expansion at .\logging.jl:316 [inlined]
 [4] jldatatype(::JLD.JldFile, ::HDF5.HDF5Datatype) at C:\Program Files\ReSolver.DistributedJulia\depot\packages\JLD\1BoSz\src\jld_types.jl:703
 [5] read(::JLD.JldDataset) at C:\Program Files\ReSolver.DistributedJulia\depot\packages\JLD\1BoSz\src\JLD.jl:370
 [6] read(::JLD.JldFile, ::String) at C:\Program Files\ReSolver.DistributedJulia\depot\packages\JLD\1BoSz\src\JLD.jl:346
 [7] #42 at C:\Program Files\ReSolver.DistributedJulia\depot\packages\JLD\1BoSz\src\JLD.jl:1240 [inlined]
 [8] #jldopen#14(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::getfield(JLD, Symbol("##42#43")){String}, ::String, ::Vararg{String,N} where N) at C:\Program Files\ReSolver.DistributedJulia\depot\packages\JLD\1BoSz\src\JLD.jl:246
 [9] jldopen at C:\Program Files\ReSolver.DistributedJulia\depot\packages\JLD\1BoSz\src\JLD.jl:244 [inlined]
 [10] load at C:\Program Files\ReSolver.DistributedJulia\depot\packages\JLD\1BoSz\src\JLD.jl:1239 [inlined]
 [11] #load#13(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::String, ::String) at C:\Program Files\ReSolver.DistributedJulia\depot\packages\FileIO\YJO7Z\src\loadsave.jl:118
 [12] load(::String, ::String) at C:\Program Files\ReSolver.DistributedJulia\depot\packages\FileIO\YJO7Z\src\loadsave.jl:118
 [13] top-level scope at In[18]:1

Thanks,
Adrian.

#2

Your example is incomplete.

Variable a doesn’t get assigned a value (I would assume it’s a foo struct).

There must be more in the Julia 1.1 code (at least setting file_path and file_prefix, presumably as in v0,7, and probably defining the foo struct).

However, filling in my assumptions works for me (using JLD 0.9.1 on both Julia versions and with the file location amended to a valid location for me).

Julia 0.7

       mutable struct foo
           is_true::Bool
           name::String
       end
       file_path=raw"c:\Users\simon\Temp\test.jld"
       file_dir, file_name = splitdir(file_path)
       file_prefix, file_ext = splitext(file_name)
       a=foo(true,"test true")
       JLD.save(file_path, file_prefix, a, compress=false)

Julia 1.1

       mutable struct foo
           is_true::Bool
           name::String
       end
       file_path=raw"c:\Users\simon\Temp\test.jld"
       file_dir, file_name = splitdir(file_path)
       file_prefix, file_ext = splitext(file_name)
       obj = JLD.load(file_path, file_prefix)

gives me

foo(true, "test true")

I’ve checked it also works for false

#3

Simon,

Thanks for the response, and my apologies I was indeed missing a single line of the example which was assigning a value to foo - I’ve updated the example

I’ve done some more investigating and I believe that the original JLD file may have been written out using Julia 0.6 rather than 0.7 as I’ve stated.

Thanks.

#4

Have you resolved the JLD / Core.Bool problem?

#5

Somewhat, I believe there was a bug fix to the JLD library seems to have worked, so I downloaded these code files directly and overwrote the existing JLD library source files.

However I still seem to have issues with some of my old JLD files. So trying to figure which versions of julia / JLD I need to read the old JLD’s with and write them back out so they work fully with 1.1.

#6

JLD.translate("Core.Bool", "crazybool")

resolves the problem. it forces JLD to reconstruct the type from the file.