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

Loading data with user-defined types fails

Open PetrKryslUCSD opened this issue 8 years ago • 3 comments
trafficstars

julia> include("examples/deformation_linear\\statics\\3-d\\compute_errors.jl")
error parsing type string FinEtools.FEMMDeforLinearModule.FEMMDeforLinear{FinEtools.DeforModelRedModule.DeforModelRed3D,FinEtools.FESetModule.FESetT10,FinEtools.GeoDModule.#otherdimensionunity,FinEtools.MatDeforElastIsoModule.MatDeforElastIso{FinEtools.DeforModelRedModule.DeforModelRed3D,FinEtools.MatDeforElastIsoModule.#tangentmoduli3d!,FinEtools.MatDeforElastIsoModule.#update3d!,FinEtools.MatDeforElastIsoModule.#thermalstrain3d!}}
ERROR: LoadError: syntax: incomplete: premature end of input
Stacktrace:
 [1] _julia_type(::String) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:980
 [2] julia_type(::String) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:27
 [3] jldatatype(::JLD.JldFile, ::HDF5.HDF5Datatype) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\jld_types.jl:694
 [4] read(::JLD.JldDataset) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:368
 [5] read_ref(::JLD.JldFile, ::HDF5.HDF5ReferenceObj) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:500
 [6] read_refs(::JLD.JldDataset, ::Type{Any}, ::Int32, ::Int32, ::Tuple{Int64}) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:473
 [7] read_array(::JLD.JldDataset, ::HDF5.HDF5Datatype, ::Int32, ::Int32, ::Tuple{Int64}) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:407
 [8] read_array(::JLD.JldDataset, ::HDF5.HDF5Datatype, ::Int32, ::Int32) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:406
 [9] read(::JLD.JldDataset) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:370
 [10] read_ref(::JLD.JldFile, ::HDF5.HDF5ReferenceObj) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:500
 [11] @generated body at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\jld_types.jl:427 [inlined]
 [12] jlconvert(::Type{JLD.AssociativeWrapper{String,Any,Dict{String,Any}}}, ::JLD.JldFile, ::Ptr{UInt8}) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\jld_types.jl:553
 [13] read_scalar(::JLD.JldDataset, ::HDF5.HDF5Datatype, ::Type{T} where T) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:396
 [14] read(::JLD.JldDataset) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:368
 [15] read_ref(::JLD.JldFile, ::HDF5.HDF5ReferenceObj) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:500
 [16] read_refs(::JLD.JldDataset, ::Type{Dict{String,Any}}, ::Int32, ::Int32, ::Tuple{Int64}) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:473
 [17] read_array(::JLD.JldDataset, ::HDF5.HDF5Datatype, ::Int32, ::Int32, ::Tuple{Int64}) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:407
 [18] read_array(::JLD.JldDataset, ::HDF5.HDF5Datatype, ::Int32, ::Int32) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:406
 [19] read(::JLD.JldDataset) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:370
 [20] read(::JLD.JldFile, ::String) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:344
 [21] (::getfield(Main, Symbol("##105#106")))(::JLD.JldFile) at C:\Users\PetrKrysl\.julia\v0.7\FinEtools\examples\deformation_linear\statics\3-d\compute_errors.jl:98
 [22] #jldopen#11(::Array{Any,1}, ::Function, ::getfield(Main, Symbol("##105#106")), ::String, ::Vararg{String,N} where N) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:243
 [23] jldopen(::Function, ::String, ::String) at C:\Users\PetrKrysl\.julia\v0.7\JLD\src\JLD.jl:241
 [24] include_relative(::Module, ::String) at .\loading.jl:464
 [25] include(::Module, ::String) at .\sysimg.jl:14
 [26] include(::String) at .\sysimg.jl:47
while loading C:\Users\PetrKrysl\.julia\v0.7\FinEtools\examples\deformation_linear\statics\3-d\compute_errors.jl, in expression starting on line 97

In particular I believe it is one data structure that breaks the loading (from the error message above). An array of dictionaries is created

push!(convergencestudy, FDataDict(
        "elementsize"=> 1.0 / n,
        "fens"=>fens,
        "fes"=>fes,
        "geom"=>geom,
        "u"=>u,
        "femm"=>region["femm"],
        "integrationrule"=>region["femm"].geod.integration_rule,
        "stressfields"=>stressfields,
        "tolerance"=>tolerance)
        )

and if I leave out "femm", the JLD file is loaded without a hitch.

Obtained with:

Julia Version 0.7.0-DEV.1816
Commit 1af1f5275c* (2017-09-17 15:48 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-6650U CPU @ 2.20GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, skylake)
Environment:

PetrKryslUCSD avatar Sep 28 '17 14:09 PetrKryslUCSD

It should work fine for most user-defined types. I'd guess the object you're saving has one or more functions (not supported) buried inside. See the # characters in the string it's reporting an error with.

timholy avatar Sep 28 '17 18:09 timholy

OK. So I think you are saying that JLD does not support saving when a field is a function?

PetrKryslUCSD avatar Sep 28 '17 19:09 PetrKryslUCSD

Heads up that I was hitting this issue, but had success using https://github.com/invenia/JLSO.jl instead.

ianfiske avatar Mar 25 '20 15:03 ianfiske