JuliaIO / JLD2.jl

HDF5-compatible file format in pure Julia
Other
547 stars 85 forks source link

`JLD2.InvalidDataException("Did not find a Superblock.")` error from "straightforward" save and load #445

Closed Datseris closed 1 year ago

Datseris commented 1 year ago

Hi, I am saving some data so that I store them on GitHub and later load them to build some docs so that I don't compute for 30 minutes to produce said data. My approach is very simple. I do:

julia> dict
Dict{String, Vector} with 2 entries:
  "fractions_curves" => [Dict(2=>0.322, 3=>0.334, 1=>0.344), Dict(2=>0.345962, 3=>0.333998, 1=>0.32004)…
  "attractors_info"  => Dict{Int32, Dataset{2, Float64}}[Dict(2=>2-dimensional Dataset{Float64} with 1 …

julia> JLD2.save("multispecies_competition_fractions_curves.jld2", dict)

I then upload the above .jld2 file on GitHub, download it and load it:

import Downloads, JLD2
link = "https://github.com/JuliaDynamics/JuliaDynamics/blob/master/examples_data/multispecies_competition_fractions_curves.jld2"
file = Downloads.download(link, tempname()*".jld2")
data = JLD2.load(file)

but I get the error:

julia> data = JLD2.load(file)
Error encountered while load FileIO.File{FileIO.DataFormat{:JLD2}, String}("C:\\Users\\datse\\AppData\\Local\\Temp\\jl_MnEhCbU9GX.jld2").

Fatal error:
ERROR: JLD2.InvalidDataException("Did not find a Superblock.")
Stacktrace:
  [1] find_superblock(f::JLD2.JLDFile{JLD2.MmapIO})
    @ JLD2 C:\Users\datse\.julia\packages\JLD2\1YVED\src\superblock.jl:102
  [2] load_file_metadata!(f::JLD2.JLDFile{JLD2.MmapIO})
    @ JLD2 C:\Users\datse\.julia\packages\JLD2\1YVED\src\JLD2.jl:371
  [3] jldopen(fname::String, wr::Bool, create::Bool, truncate::Bool, iotype::Type{JLD2.MmapIO}; fallback::Type{IOStream}, compress::Bool, mmaparrays::Bool, typemap::Dict{String, Any})
    @ JLD2 C:\Users\datse\.julia\packages\JLD2\1YVED\src\JLD2.jl:364
  [4] jldopen(fname::String, wr::Bool, create::Bool, truncate::Bool, iotype::Type{JLD2.MmapIO})
    @ JLD2 C:\Users\datse\.julia\packages\JLD2\1YVED\src\JLD2.jl:300
  [5] jldopen(fname::String, mode::String; iotype::Type, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JLD2 C:\Users\datse\.julia\packages\JLD2\1YVED\src\JLD2.jl:423
  [6] jldopen(fname::String, mode::String)
    @ JLD2 C:\Users\datse\.julia\packages\JLD2\1YVED\src\JLD2.jl:417
  [7] jldopen(::Function, ::String, ::Vararg{String}; kws::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JLD2 C:\Users\datse\.julia\packages\JLD2\1YVED\src\loadsave.jl:2
  [8] jldopen
    @ C:\Users\datse\.julia\packages\JLD2\1YVED\src\loadsave.jl:1 [inlined]
  [9] #fileio_load#99
    @ C:\Users\datse\.julia\packages\JLD2\1YVED\src\fileio.jl:38 [inlined]
 [10] fileio_load(f::FileIO.File{FileIO.DataFormat{:JLD2}, String})
    @ JLD2 C:\Users\datse\.julia\packages\JLD2\1YVED\src\fileio.jl:37

I admit I am not sure what the error means or what went wrong.

Datseris commented 1 year ago

Oh yeah, sorry, i was being stupid. that is not the correct way to download from github... you need the rawusercontent website instead...