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
JLD2 Integration #505
JLD2 Integration #505
Conversation
Looking at https://github.com/JuliaGraphs/MetaGraphs.jl/blob/master/src/persistence.jl and from some testing I did, it appears as though Additionally, reimplementing all schedulers as function-like objects would make serialization significantly simpler. Currently, since This issue also then crops up with
|
I wonder if using accessors.jl would be good for this. I've had success with it setting model.rng to a new RandomDevice(). Will be a good discussion for tomorrow. |
- Added JLD2 to dependencies - Reworked serialization to use custom conversion methods before sending to JLD2 - Reworkd deserialization to use custom conversion methods
- Use of undefined variable in AStar constructor
- Also removed @info about GraphSpace
I'll cover what I've written in tests before moving on to tackling OSMSpace. I think the |
Is it an acceptable pattern to encapsulate repetitive tests in a function, or does that reduce traceability in the case that those tests fail? For example, function check_model_properties(model, other)
@test model.scheduler == other.scheduler
@test model.rng == other.rng
@test model.maxid.x == other.maxid.x
end |
- Tests for no, grid and continuous space models
There's some weird behaviour with comparing |
I propose to do this in a different PR. OSMSpace is a bit "special" so to speak |
From my end this is fine, I do something similar in DynamicalSystems.jl |
- Added tests for GraphSpace - Order within space.s isn't maintained during (de)serialization, so tests don't assume it - GraphSpace deserialization fix
Codecov Report
@@ Coverage Diff @@
## master #505 +/- ##
==========================================
+ Coverage 93.04% 93.55% +0.51%
==========================================
Files 20 21 +1
Lines 1265 1304 +39
==========================================
+ Hits 1177 1220 +43
+ Misses 88 84 -4
Continue to review full report at Codecov.
|
- Type parameter fix for GridSpace serialization due to pathfinders
All that's left to test now is serialization of multi-agent models. 325 tests racked up already just for JLD2 (was ~3k at one point, while I was testing |
- Multi agent uses daisyworld - Daisyworld scheduler moved outside of initialization function - dump_to_jld2 @asserts that model.space isn't OSMSpace - OSMSpace test checks for error
I moved daisyworld's scheduler outside of the initialization function, so it's accessible while deserializing during tests. Is this fine, or should it remain local? |
Sure, that's not a requirement to be internal as far as I remember. |
- Added docstrings for dump_to_jld2 and load_from_jld2 - to_serializable doesn't require keyword arguments - dump_to_jld2 doesn't require keyword arguments
I'm not fully happy with how |
- Docstrings added for to_serializable and from_serializable - Changes to docstrings for dump_to_jld2 and load_from_jld2 - model.properties now goes through to_serializable and from_serializable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No real issues with implementation at all—looking good!!
There are a few suggestions to improve documentation and user interactions, but most are minor. We can perhaps work through some of the doc fixes tomorrow in the meeting.
- Give possible scenarios when defining those methods is required - Specify possible consequences of not defining those methods when required
It seems ../path wasn't the issue. Now it can't see the file. |
OK, so that's a bit more complicated. Is this a problem only in CI, only when building documentation, or is it the same locally? |
It's a problem when building docs, both in CI and locally |
I should add, I tried creating a file with a submodule, defining an agent and model, and save/loading it within the module. Didn't create any issues. For some reason it's only when building docs |
Alright. That'll take some investigation. I'll be out for the afternoon so don't know when I'll be able to focus on it. |
Following our weekly meeting, the decision has been made to drop the additions to the Schelling Example from this PR and merge the rest once the documentation is up to scratch. A new PR will be opened with the Schelling Example additions as-is, and we'll investigate the Documenter/JLD2 issue as time permits. We've also decided to support OSM space by saving agent lat/long coordinates and expecting the user to know the map path to deserialize their model: we will rebuild the mapspace on-load. |
- (De)Serialization section of API renamed to Save/Load - Added description for Save/Load section, removed AgentsIO doc - Moved to_serializable and from_serializable to devdocs - Updated AgentsIO docstring
These doc changes look good. So the only outstanding thing is OSMSpace from my perspective. |
I'm removing |
- Also tested warn keyword during deserialization
yes go ahead and merge when tests pass but do not tag a new release. New releases should be tagged only when documentation exists. Feel free to open a tracking issue with the docs code pasted there. |
Ah. I just missed your comment. |
98e9ae8
to
d5bd7c5
Compare
I think this branch can be kept for now? Since OSMSpace is coming up, along with the fix to schelling |
#496
Uses JLD2's custom serialization functionality (https://juliaio.github.io/JLD2.jl/dev/customserialization/)