JLD2: ERROR: type DataType has no field mutable

Hello,

Following this, I want to save a policy.

The code is:

solver = ValueIterationSolver(max_iterations = 70)
policy = solve(solver, mdp)

using JLD2, FileIO
save("my_policy.jld2", "policy", policy)

With:
ERROR: type DataType has no field mutable version

JLD2 is installed, any recommendation?

Thanks for reporting the error. Could you show more of the stack trace to us?

1 Like

save("test.jld2","test",rand(10))

produces:

Error encountered while save FileIO.File{FileIO.DataFormat{:JLD2}, String}("test.jld2").

Fatal error:
type DataType has no field mutable
Stacktrace:
  [1] getproperty
    @ ./Base.jl:37 [inlined]
  [2] hasfielddata(T::Any, encounteredtypes::Vector{DataType})
    @ JLD2 ~/.julia/packages/JLD2/qncOK/src/data/writing_datatypes.jl:24
  [3] hasfielddata(T::Any)
    @ JLD2 ~/.julia/packages/JLD2/qncOK/src/data/writing_datatypes.jl:19
  [4] #s140#25
    @ ~/.julia/packages/JLD2/qncOK/src/data/writing_datatypes.jl:65 [inlined]
  [5] var"#s140#25"(T::Any, ::Any, #unused#::Any, initialized::Any)
    @ JLD2 ./none:0
  [6] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
    @ Core ./boot.jl:580
  [7] odr
    @ ~/.julia/packages/JLD2/qncOK/src/data/specialcased_types.jl:120 [inlined]
  [8] objodr
    @ ~/.julia/packages/JLD2/qncOK/src/data/writing_datatypes.jl:109 [inlined]
  [9] write_dataset(f::JLD2.JLDFile{JLD2.MmapIO}, x::Vector{Float64}, wsession::JLD2.JLDWriteSession{Dict{UInt64, JLD2.RelOffset}})
    @ JLD2 ~/.julia/packages/JLD2/qncOK/src/inlineunion.jl:43
 [10] write(g::JLD2.Group{JLD2.JLDFile{JLD2.MmapIO}}, name::String, obj::Vector{Float64}, wsession::JLD2.JLDWriteSession{Dict{UInt64, JLD2.RelOffset}})
    @ JLD2 ~/.julia/packages/JLD2/qncOK/src/groups.jl:119
 [11] write(f::JLD2.JLDFile{JLD2.MmapIO}, name::String, obj::Vector{Float64}, wsession::JLD2.JLDWriteSession{Dict{UInt64, JLD2.RelOffset}})
    @ JLD2 ~/.julia/packages/JLD2/qncOK/src/JLD2.jl:347
 [12] #62
    @ ~/.julia/packages/JLD2/qncOK/src/fileio.jl:23 [inlined]
 [13] jldopen(::JLD2.var"#62#63"{String, Vector{Float64}, Tuple{}}, ::String, ::Vararg{String}; kws::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JLD2 ~/.julia/packages/JLD2/qncOK/src/loadsave.jl:4
 [14] jldopen
    @ ~/.julia/packages/JLD2/qncOK/src/loadsave.jl:2 [inlined]
 [15] #save#61
    @ ~/.julia/packages/JLD2/qncOK/src/fileio.jl:21 [inlined]
 [16] save(::FileIO.File{FileIO.DataFormat{:JLD2}, String}, ::String, ::Vector{Float64})
    @ JLD2 ~/.julia/packages/JLD2/qncOK/src/fileio.jl:18
 [17] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./essentials.jl:716
 [18] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base ./essentials.jl:714
 [19] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::FileIO.Formatted, ::String, ::Vararg{Any}; options::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ FileIO ~/.julia/packages/FileIO/Nl9Lh/src/loadsave.jl:219
 [20] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::FileIO.Formatted, ::String, ::Vector{Float64})
    @ FileIO ~/.julia/packages/FileIO/Nl9Lh/src/loadsave.jl:197
 [21] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::Symbol, ::String, ::String, ::Vararg{Any}; options::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ FileIO ~/.julia/packages/FileIO/Nl9Lh/src/loadsave.jl:185
 [22] action
    @ ~/.julia/packages/FileIO/Nl9Lh/src/loadsave.jl:185 [inlined]
 [23] #save#20
    @ ~/.julia/packages/FileIO/Nl9Lh/src/loadsave.jl:129 [inlined]
 [24] save(::String, ::String, ::Vector{Float64})
    @ FileIO ~/.julia/packages/FileIO/Nl9Lh/src/loadsave.jl:126
 [25] top-level scope
    @ In[5]:1

Stacktrace:
  [1] handle_error(e::ErrorException, q::Base.PkgId, bt::Vector{Union{Ptr{Nothing}, Base.InterpreterIP}})
    @ FileIO ~/.julia/packages/FileIO/Nl9Lh/src/error_handling.jl:61
  [2] handle_exceptions(exceptions::Vector{Tuple{Any, Union{Base.PkgId, Module}, Vector}}, action::String)
    @ FileIO ~/.julia/packages/FileIO/Nl9Lh/src/error_handling.jl:56
  [3] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::FileIO.Formatted, ::String, ::Vararg{Any}; options::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ FileIO ~/.julia/packages/FileIO/Nl9Lh/src/loadsave.jl:228
  [4] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::FileIO.Formatted, ::String, ::Vector{Float64})
    @ FileIO ~/.julia/packages/FileIO/Nl9Lh/src/loadsave.jl:197
  [5] action(::Symbol, ::Vector{Union{Base.PkgId, Module}}, ::Symbol, ::String, ::String, ::Vararg{Any}; options::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ FileIO ~/.julia/packages/FileIO/Nl9Lh/src/loadsave.jl:185
  [6] action
    @ ~/.julia/packages/FileIO/Nl9Lh/src/loadsave.jl:185 [inlined]
  [7] #save#20
    @ ~/.julia/packages/FileIO/Nl9Lh/src/loadsave.jl:129 [inlined]
  [8] save(::String, ::String, ::Vector{Float64})
    @ FileIO ~/.julia/packages/FileIO/Nl9Lh/src/loadsave.jl:126
  [9] top-level scope
    @ In[5]:1
 [10] eval
    @ ./boot.jl:373 [inlined]
 [11] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:1196

Thanks.

What version of JLD2 are you using?

I use JLD2 without issue. I would write that as jldsave("filename.jld2"; varname)

Hi @azraq27 ,
this is a known issue that was fixed quite some time ago.
Please make sure to use the latest version of JLD2.

1 Like