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

FileIO Stream Interface not supported #64

Open
goretkin opened this issue Jan 28, 2020 · 1 comment · May be fixed by #65
Open

FileIO Stream Interface not supported #64

goretkin opened this issue Jan 28, 2020 · 1 comment · May be fixed by #65

Comments

@goretkin
Copy link

julia> import FileIO

julia> FileIO.save(FileIO.Stream(FileIO.format"BSON", IOBuffer()), Dict(:hey=>3))
Error encountered while saving nothing.

Fatal error:
ERROR: MethodError: no method matching bson(::Nothing, ::Dict{Symbol,Int64})
Closest candidates are:
  bson(::IO, ::AbstractDict) at /Users/goretkin/.julia/dev/BSON/src/write.jl:81
  bson(::String, ::AbstractDict) at /Users/goretkin/.julia/dev/BSON/src/write.jl:83
Stacktrace:
 [1] handle_error(::MethodError, ::Stream{DataFormat{:BSON},Base.GenericIOBuffer{Array{UInt8,1}}}) at /Users/goretkin/.julia/dev/FileIO/src/error_handling.jl:82
 [2] handle_exceptions(::Array{Any,1}, ::String) at /Users/goretkin/.julia/dev/FileIO/src/error_handling.jl:77
 [3] #save#30(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(save), ::Formatted, ::Any) at /Users/goretkin/.julia/dev/FileIO/src/loadsave.jl:211
 [4] save(::Formatted, ::Any) at /Users/goretkin/.julia/dev/FileIO/src/loadsave.jl:194
 [5] top-level scope at none:0
@goretkin goretkin linked a pull request Jan 28, 2020 that will close this issue
@dehann
Copy link

dehann commented Oct 10, 2020

Not sure if this helps but if you looking to avoid a physical file:

d = Dict(:hi =>3)
io_ = IOBuffer()
BSON.@save io_ d

bd = take!(io)

EDIT:

io__ = PipeBuffer(take!(io_))

BSON.@load io__ d2

For completeness also see String safe Base64: https://docs.julialang.org/en/v1/stdlib/Base64/#Base64.Base64EncodePipe

Search keywords: BSON with IOBuffer no file


I'm was having trouble going the other way:

BSON.@load io_ d
ERROR: EOFError: read end of file
Stacktrace:
 [1] peek at ./iobuffer.jl:180 [inlined]
 [2] read at ./iobuffer.jl:190 [inlined]
 [3] parse_doc(::Base.GenericIOBuffer{Array{UInt8,1}}) at /home/dehann/.julia/packages/BSON/XAts7/src/read.jl:48
 [4] parse at /home/dehann/.julia/packages/BSON/XAts7/src/read.jl:101 [inlined]
 [5] load(::Base.GenericIOBuffer{Array{UInt8,1}}) at /home/dehann/.julia/packages/BSON/XAts7/src/read.jl:104
 [6] top-level scope at /home/dehann/.julia/packages/BSON/XAts7/src/BSON.jl:52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants