-
Notifications
You must be signed in to change notification settings - Fork 670
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
No need to redirect to the original frame explicitly during deserialization #3722
Conversation
Hello @yuxuanzhuang! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2024-07-04 01:38:51 UTC |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3722 +/- ##
===========================================
- Coverage 93.60% 93.59% -0.02%
===========================================
Files 171 183 +12
Lines 21235 22309 +1074
Branches 3933 3934 +1
===========================================
+ Hits 19876 20879 +1003
- Misses 899 971 +72
+ Partials 460 459 -1 ☔ View full report in Codecov by Sentry. |
Once you need someone to review, feel free to ping/request reviewers. I'd also suggest using the "convert to draft" in GitHub instead of just adding "WIP" to the issue title as it shows more intentionally if you currently want reviews or not. |
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.
This is probably an improvement, but I think it'll be a change in behaviour so we'll need to raise warnings etc.
The behaviour change is how the reading location |
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.
@yuxuanzhuang sorry for leaving this for a while. So is the behaviour now that serialising/deserialising a Reader preserves the Timestep correctly? I.e. if I'd modified the coordinates somehow, this data will be preserved?
@richardjgowers Okay, I never thought about preserving the modification of coordinates (before). But the behavior does change after this PR, i.e. now the modification is preserved (because no data reloading from the file is performed after this line is removed) which is more "correct". u = mda.Universe(XYZ)
print('Orig pos:,', u.trajectory.ts.positions[0])
u.trajectory.ts.positions[0] = np.array([1, 2, 3])
print('New pos:,', u.trajectory.ts.positions[0])
u_new = pickle.loads(pickle.dumps(u))
print('After serializing pos:,', u_new.trajectory.ts.positions[0])
# original output
Orig pos:, [ 0.931 17.318 16.423]
New pos:, [1. 2. 3.]
After serializing pos:, [ 0.931 17.318 16.423]
# new output after #PR 3722
Orig pos:, [ 0.931 17.318 16.423]
New pos:, [1. 2. 3.]
After serializing pos:, [1. 2. 3.] |
@yuxuanzhuang thanks for adding the test - it looks like it found that h5md format has a custom serialisation mechanism |
Should work now! (too many formats to keep track of :) ) |
@yuxuanzhuang could you resolve the conflicts please? |
@yuxuanzhuang and @richardjgowers this PR still looks relevant. Why did it stall? What needs to be done to complete it? |
Linter Bot Results:Hi @yuxuanzhuang! Thanks for making this PR. We linted your code and found the following: Some issues were found with the formatting of your code.
Please have a look at the Please note: The |
Done! Should I worry about the linter bot? |
Unless it outlines a flake8 failure it's ok to ignore. Just checked - no flake8 so you're good to go. |
I understand why TNGReader needs to re-read the current frame during serialization; however, due to this, the modification of
Do you think it's reasonable to only make sure
|
Just checking my understanding @yuxuanzhuang, this means that the coordinate data will be re-read, but that any additional data in Sorry about this mess, tbh this is being caused by my lazyness from way back where I didn't make the cython level classes pickleable in |
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.
Tiny cosmetic things :)
package/CHANGELOG
Outdated
@@ -48,6 +49,8 @@ Enhancements | |||
(Issue #3994, PR #4281) | |||
* Add support for reading chainID info from Autodock PDBQT files (Issue #4207, | |||
PR #4284) | |||
* Improve performance in Universe serialization by no explicit redirection to |
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.
Newest first :)
package/CHANGELOG
Outdated
@@ -198,6 +201,10 @@ Fixes | |||
* Fix MSD docs to use the correct error metric in example (Issue #3991) | |||
* Add 'PairIJ Coeffs' to the list of sections in LAMMPSParser.py | |||
(Issue #3336) | |||
* Fix failure in double-serialization of TextIOPicklable file reader. |
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.
Same here.
package/CHANGELOG
Outdated
@@ -364,6 +371,8 @@ Changes | |||
use `pip install ./package[extra_formats]` instead (PR #3810) | |||
* `Universe.empty` emmits less warnings (PR #3814) | |||
* adding element attribute to TXYZParser if all atom names are valid element symbols (PR #3826) | |||
* TextIOPicklable serializes the raw class instance instead of class name. |
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.
Same here.
@hmacdope and @richardjgowers can you please check if your raised concerns have been addressed? If yes, can we merge? Otherwise, are there bigger issues that we cannot solve? |
Forgot to move entries from 2.7 to 2.8 in merge
moved an entry from 2.4.1(!) to 2.8.0
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.
update versionchanged to 2.8.0
Note that I had to find the CHANGELOG entries from different sections to correctly merge. Please double check the CHANGELOG @yuxuanzhuang
I mean modification of e.g. coordinates.
Previously, during unpickling, Now, only |
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.
LGTM @yuxuanzhuang, thanks for pushing through on this. 👍
@richardjgowers is your review still pertinent or should I just dismiss it? |
8d43037
to
6b03f6f
Compare
package/CHANGELOG
Outdated
@@ -22,6 +22,10 @@ The rules for this file: | |||
* 2.8.0 | |||
|
|||
Fixes | |||
* Fix failure in double-serialization of TextIOPicklable file reader. | |||
(Issue #3723, PR #3722) | |||
* Fix failure to preserve modification of coordinates after serialization. |
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.
There's a change in behaviour here where pickling then unpickling no longer resets a frame to the data held in that frame. E.g. if I load frame 10, then unwrap these coordinates (modifying them from the file held state), then serialise/deserialise that (e.g. in a multiprocessing situation) the frame is now unwrapped on deserialisation. This is probably a good thing (tm). This should probably get explained in an issue and/or changelog entry
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.
Thanks! I have added an issue regarding it #4633
Fixes #3723
Fixes #4633
Partial fix: #3721
Changes made in this Pull Request:
PR Checklist