produce_or_load fails with custom filename
Closed this issue · 5 comments
aquaresima commented
When there is a filename
keyword argument in produce_or_load
, the function returns a MethodError.
This is the MWE:
using DrWatson
data = @strdict feats=2 labels=2
rm("test.jld2", force=true)
mydata, file = produce_or_load(data, filename="test.jld2") do data
sleep(3)
return data
end
@show file
This is the MethodError
ERROR: LoadError: MethodError: no method matching savename(::String, ::Dict{String, Int64}, ::String; filename="test.jld2")
Closest candidates are:
savename(::String, ::Any, ::String; allowedtypes, accesses, ignores, digits, connector, expand, sigdigits, val_to_string, sort, equals) at ~/.julia/packages/DrWatson/OgRKj/src/naming.jl:85 got unsupported keyword argument "filename"
Stacktrace:
[1] kwerr(::NamedTuple{(:filename,), Tuple{String}}, ::Function, ::String, ::Dict{String, Int64}, ::String)
@ Base ./error.jl:165
[2] produce_or_load(path::String, c::Dict{String, Int64}, f::var"#1#2"; suffix::String, prefix::String, tag::Bool, gitpath::String, loadfile::Bool, force::Bool, verbose::Bool, storepatch::Bool, wsave_kwargs::Dict{Any, Any}, kwargs::Base.Pairs{Symbol, String, Tuple{Symbol}, NamedTuple{(:filename,), Tuple{String}}})
@ DrWatson ~/.julia/packages/DrWatson/OgRKj/src/saving_files.jl:48
[3] produce_or_load(c::Dict{String, Int64}, f::Function; kwargs::Base.Pairs{Symbol, String, Tuple{Symbol}, NamedTuple{(:filename,), Tuple{String}}})
@ DrWatson ~/.julia/packages/DrWatson/OgRKj/src/saving_files.jl:40
[4] produce_or_load(f::Function, c::Dict{String, Int64}; kwargs::Base.Pairs{Symbol, String, Tuple{Symbol}, NamedTuple{(:filename,), Tuple{String}}})
@ DrWatson ~/.julia/packages/DrWatson/OgRKj/src/saving_files.jl:41
[5] top-level scope
@ ~/Documents/Research/phd_project/simulations/spiking/Tripod/_research/produce_or_load.jl:6
[6] include(fname::String)
@ Base.MainInclude ./client.jl:476
[7] top-level scope
@ REPL[2]:1
in expression starting at /home/alequa/Documents/Research/phd_project/simulations/spiking/Tripod/_research/produce_or_load.jl:6
The error is produced with:
Julia Version 1.8.2
Commit 36034abf260 (2022-09-29 15:21 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-13.0.1 (ORCJIT, skylake)
Threads: 4 on 8 virtual cores
Environment:
JULIA_DEPOT_PATH = /home/alequa/.julia
JULIA_NUM_THREADS = 4
[634d3b9d] DrWatson v2.5.0
aquaresima commented
Following the documentation, in the presence of the filename keyword argument, savename
should not be invoked at all.
Datseris commented
oh wow, I'm shocked the tests didn't catch this. Well this seems like a super easy bugfix if you are interested for a PR!
aquaresima commented
Yes, I think I can do this.
I'll try within the week and write here.
Datseris commented
(notice taht produce_or_load
has a second method with function as first argument that is used in the do-blocks. It's this method that we have to fix)
aquaresima commented
Ok, Using the present version (2.10) was enough to make the issue disappear ;)
Thanks