Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pickle protocol version 5? #32

Closed
tp2750 opened this issue Jul 6, 2022 · 3 comments
Closed

Support pickle protocol version 5? #32

tp2750 opened this issue Jul 6, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@tp2750
Copy link

tp2750 commented Jul 6, 2022

I have a pickle file, that fails to load with the following error:

using Pickle
Pickle.load(open("/tmp/genomedict.pickle"))
ERROR: AssertionError: imcompatible protocol version: require version >= 5
Stacktrace:
 [1] execute!(p::Pickler{4}, #unused#::Val{Pickle.OpCodes.PROTO}, arg::UInt8)
   @ Pickle ~/.julia/packages/Pickle/ZuyWC/src/deserializer.jl:178
 [2] run!(p::Pickler{4}, op::Pickle.OpCodes.OpCode, io::IOStream)
   @ Pickle ~/.julia/packages/Pickle/ZuyWC/src/deserializer.jl:25
 [3] load(p::Pickler{4}, io::IOStream)
   @ Pickle ~/.julia/packages/Pickle/ZuyWC/src/deserializer.jl:15
 [4] load(io::IOStream; proto::Int64)
   @ Pickle ~/.julia/packages/Pickle/ZuyWC/src/deserializer.jl:10
 [5] load(io::IOStream)
   @ Pickle ~/.julia/packages/Pickle/ZuyWC/src/deserializer.jl:10
 [6] top-level scope
   @ ./timing.jl:220 [inlined]
 [7] top-level scope
   @ ./REPL[4]:0

The error appears to happen in deserializer.jl L178

execute!(p::AbstractPickle, ::Val{OpCodes.PROTO}, arg) = @assert protocol(p) >= arg "imcompatible protocol version: require version >= $arg"

If I just remove the assert, Pickle.jl actually loads the file, and as far as I can see, the result is correct.

Pickle version: [fbb45041] Pickle v0.3.1

@chengchingwen chengchingwen added the enhancement New feature or request label Jul 6, 2022
@chengchingwen
Copy link
Owner

I haven't read the protocol 5, so I'm not sure whether it could work correctly. But since the op code rarely change the behavior, I think I can turn the error into a warning and let people try if it works.

@chengchingwen
Copy link
Owner

@tp2750 Actually, can you try load("/tmp/genomedict.pickle"); proto = 5)? It should try to load the pickle file with version 5 (and error out if there are unknown codes.

@tp2750
Copy link
Author

tp2750 commented Jul 7, 2022

Thank you for pointing out the proto keyword arg @chengchingwen. This works fine:

julia> @time genomeDictfromfile = Pickle.load(open(genomedictfile); proto=5)
  0.976258 seconds (3.02 M allocations: 123.461 MiB, 3.14% gc time, 71.09% compilation time)
DataStructures.DefaultDict{Any, Any, UnionAll} with 11 entries:

@tp2750 tp2750 closed this as completed Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants