Add first saving functions in local simulation run #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Partially save the state history in local simulation.
I implemented 5 new methods in the simulator.py file :
start_recording()
: setsrecording
to true, instantiates a list calledrecords
, and creates a directory inside a 'Results/' folder to save recorded frames (with an optional name, else create something with experiment_{current date and time})record()
: add the desired data torecords
, called in the step function whenrecording
is Truesave_records()
: save therecords
in the created saving_dirstop_recording()
: setrecording
to False, callsave_records
, and setrecords
to [].load()
: load the records list from the desired saving_dirI also modified the
run
and_run
functions to acceptsave
andsaving_name
as arguments, to enable saving simulations launched in standalone mode (without the interface)If this logic is ok, we can add
recording
attribute to the simulator state so we can trigger it from the GUI.At the moment I only save the nve_state, there is an error when trying to save the whole State with pickle (due to the gettatr method, I tried to see if we can remove it but it is used in other parts of the code). It is not very important because the data structure we use might change in the future.
Also added a test for this new feature. The saving and loading works but I saw that the values saved and loaded differ a bit (with a small numerical error on the positions for example). It is also something that could change with the way we save the data (we might save the entire state, maybe without pickle ...). That's why I keep the test that doesn't pass at the moment, we will modify it later.
What would you like to modify from the PR atm @clement-moulin-frier ?
Related Issue (if applicable)
#30
How to Test
Launch the server