-
Notifications
You must be signed in to change notification settings - Fork 92
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
Explicit Type Remapping & Anonymous Functions #316
Conversation
Codecov Report
@@ Coverage Diff @@
## master #316 +/- ##
==========================================
+ Coverage 89.88% 90.18% +0.29%
==========================================
Files 27 28 +1
Lines 2720 2813 +93
==========================================
+ Hits 2445 2537 +92
- Misses 275 276 +1
Continue to review full report at Codecov.
|
what is missing from this PR? AFAIK after this JLD2 would be a better candidate than BSON for serializing Flux's models in basically any situation |
There are two things that are missing:
The issue with #37 is this:
This works well for data but for datatypes JLD2 is hardcoded to use the datatype signature as content. The fix:
|
is this branch workable for anonymous functions now? i tried current release version, it saves and loads correctly a dataset containing anonymous functions within a single Julia session, but when i restart a new Julia session and after using the same packages, it loads everything except anonymous functions. I also tried BSON, JLD, and JLSO, BSON failed saving probably because my dataset contains namedtuples of different types. JLD could save, but failed load. The JLSO is like the JLD2, could save and load in a single session, but can not load in a new session. |
Hi @babaq , |
This PR finally implements what is needed to store anonymous functions using JLD2.
Most of the julia side of things is borrowed from
BSON
but additional trickerywas needed to integrate all this with
JLD2
.AFAICT the memory layout of functions / typenames / methods have changed from julia 1.5 to 1.6
and this PR only supports 1.6.
As a side effect of this, this PR also implements explicit type remapping to allow renaming types on load.
This can be useful when working with multiple versions of the same struct. (e.g. old one in the file)
Explicit Type Remapping
Sometimes you store data using
struct
s that you defined yourself or areshipped with some package and weeks later, when you want to
load the data, the structs have changed.
This results in warnings and sometimes even errors when trying to load the
file as demonstrated here.
As of JLD2 version
v0.4.5
there is a fix. TheJLDFile
struct contains atype_map
dictionary that allows for explicit type remapping. Now you can define a struct
that matches the old definition and load your data.
closes #208
closes #191
closes #175
closes #288
todo
storing
typeof(anonfun)
#37