Skip to content
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

Enabling of parallelization of analysis.atomicdistances.AtomicDistances #4822

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from

Conversation

talagayev
Copy link
Member

@talagayev talagayev commented Dec 5, 2024

Changes made in this Pull Request:

  • added self.results and self.results.distances in analysis.atomicdistances.AtomicDistances for the use of Results

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

Developers certificate of origin


📚 Documentation preview 📚: https://mdanalysis--4822.org.readthedocs.build/en/4822/

changed to be applicable with Results
removed unnecessary results
@pep8speaks
Copy link

pep8speaks commented Dec 5, 2024

Hello @talagayev! 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-12-12 23:12:15 UTC

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.66%. Comparing base (a27591c) to head (e7da740).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4822      +/-   ##
===========================================
- Coverage    93.68%   93.66%   -0.03%     
===========================================
  Files          177      189      +12     
  Lines        21743    22813    +1070     
  Branches      3055     3055              
===========================================
+ Hits         20370    21367     +997     
- Misses         927     1000      +73     
  Partials       446      446              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@talagayev talagayev marked this pull request as ready for review December 5, 2024 01:50
package/CHANGELOG Outdated Show resolved Hide resolved

def _conclude(self):
# adjust self.results to self.results.distances
self.results = self.results.distances
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm just confused but it looks to me like the tests haven't actually changed yet (just formatting changes as far as I can tell?) and this just restored the original behavior of self.results storing a NumPy array again?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, first I modified it to have the output would be self.results.distances, but then I thought that for the convenience to not modify the docs, where it uses my_dists.results to my_dists.results.distances I could define self.results as self.results.distances to not have to change the docs and still be able to implement the parallelization of the class.

As for the pytest changes, first I had the self.results.distances output and thus the tests needed to have also the .distances. The Idea to have self.results came after creating the PR 🙈, but yes I will then remove the mention of the pytest modification, was quite late when I finished up the PR, so didn't think about that :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a hack!

If this the way we want to go then you have to write more commentary to say what you're doing and why, with references to issue and a note that this needs to be changed for 3.0.

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was confused because the PR supposedly fixes #4819 but it does not.

Instead it provides a workaround for the problem identified in PR #4808 that we cannot currently parallelize AtomicDistances.

I would be ok with this hack to make parallelization work for 2.9.0 and then make the switch (fix for #4819) before 3.0. I'd like this PR to be clearer about what it does.

I'd also like to hear some other opinions, e.g., @tylerjereddy @marinegor @IAlibay .

@@ -23,6 +24,8 @@ Fixes
Enhancements
* Add check and warning for empty (all zero) coordinates in RDKit converter (PR #4824)
* Added `precision` for XYZWriter (Issue #4775, PR #4771)
* Incorporation of `Results` into `analysis.atomicdistances.AtomicDistances`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a Breaking Change as it breaks code. If we put it in 2.9.0 then it has to go under Fix, though.

For right now, please put under Fixes and state clearly how it breaks existing code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... assuming a breaking change.

If this PR is done without breaking changes (ie keeping self.results as array at the end) then do not reference the issue (which says that we need to have self.results.distances)

Comment on lines 151 to 152
Implementation of `Results` into the class
for application in parallelization.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be clearer about what was done:

Suggested change
Implementation of `Results` into the class
for application in parallelization.
Changed storage of results from :attr:`results` to
:attr:`results.distances`. This fix **breaks old
code** that expects to find the data array in
:attr:`results`.

... assuming a breaking change.

@@ -145,6 +146,10 @@ class AtomicDistances(AnalysisBase):


.. versionadded:: 2.5.0

.. versionchanged:: 2.9.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the docs above!!!!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... assuming a breaking change.


def _conclude(self):
# adjust self.results to self.results.distances
self.results = self.results.distances
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a hack!

If this the way we want to go then you have to write more commentary to say what you're doing and why, with references to issue and a note that this needs to be changed for 3.0.

@orbeckst orbeckst self-assigned this Dec 12, 2024
@talagayev
Copy link
Member Author

I was confused because the PR supposedly fixes #4819 but it does not.

Instead it provides a workaround for the problem identified in PR #4808 that we cannot currently parallelize AtomicDistances.

I would be ok with this hack to make parallelization work for 2.9.0 and then make the switch (fix for #4819) before 3.0. I'd like this PR to be clearer about what it does.

I'd also like to hear some other opinions, e.g., @tylerjereddy @marinegor @IAlibay .

Yes my bad, I thought that it would fix #4819 but I think I missunderstood it, since I thought having it work with parallelization would fix the Issue, since it would have something that the ResultsGroup could use for the parallelization and thus use Results 🙈

@talagayev
Copy link
Member Author

I was confused because the PR supposedly fixes #4819 but it does not.
Instead it provides a workaround for the problem identified in PR #4808 that we cannot currently parallelize AtomicDistances.
I would be ok with this hack to make parallelization work for 2.9.0 and then make the switch (fix for #4819) before 3.0. I'd like this PR to be clearer about what it does.
I'd also like to hear some other opinions, e.g., @tylerjereddy @marinegor @IAlibay .

Yes my bad, I thought that it would fix #4819 but I think I missunderstood it, since I thought having it work with parallelization would fix the Issue, since it would have something that the ResultsGroup could use for the parallelization and thus use Results 🙈

I will then rename the PR more like enabling the parallelization of analysis.atomicdistances.AtomicDistances and also remove the mention of the fix, change the changelog to it and the docs and wait for further instructions how to procede

@talagayev talagayev changed the title Implementation of Results into analysis.atomicdistances.AtomicDistances Enabling of parallelization of analysis.atomicdistances.AtomicDistances Dec 12, 2024
@tylerjereddy
Copy link
Member

I'd also like to hear some other opinions, e.g., @tylerjereddy @marinegor @IAlibay .

Yes, this is why I went silent on my review activity--I couldn't decide if I was just too out of the loop on the parallel business or if this didn't do what the targeted ticket asked for. I couldn't work out how the changes addressed the original problem so figured I may have just not understood.

My original understanding was that there was supposed to be some kind of results-related container object that may contain "slots" for specific results, and it was being incorrectly used to store a specific result itself.

If I understand this correctly, is it really that much more work to do it the "right" way? Or just a compatibility concern?

@orbeckst
Copy link
Member

It would be easy to do it right, just as you say — just not add the line that you commented on (self.results = self.results.distances). The problem is that the fix (for #4819) would break the previous behavior (so it's a "compatibility concern"). There were some concerns by @IAlibay #4819 (comment) to make the change. @talagayev is proposing a workaround that will allow (1) implementing the parallelization of the class (see discussion on #4808 why that would be good), (2) avoid breaking the user-facing code (and then properly fix in 3.0).

My opinion (as stated in #4819 (comment) ) is that I'd rather fix the API ("doing it right") and call the break a fix.

@marinegor
Copy link
Contributor

I second Oliver on this -- I'd rather fix the non-compliant class and add the new functionality later, than add some temporary hacks.

If it's urgent to add the distances parallelization right now (which I doubt), it's always possible to add it as an mdakit which you'll deprecate when the upstream fixes the issue.

@IAlibay
Copy link
Member

IAlibay commented Dec 14, 2024

Just wanted to say that I see the ping here but I haven't read anything and won't until the latter half of next week - apologies it's a busy end of year period.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants