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

distopia 0.4.0 compatibility changes #4734

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

Conversation

hmacdope
Copy link
Member

@hmacdope hmacdope commented Oct 15, 2024

Test implementation of distopia-0.3.0 distances API.

Changes made in this Pull Request:

  • Adds support for distopia 0.3.0 API

PR Checklist

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

Developers certificate of origin


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

@pep8speaks
Copy link

pep8speaks commented Oct 15, 2024

Hello @hmacdope! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 64:80: E501 line too long (82 > 79 characters)
Line 90:80: E501 line too long (86 > 79 characters)
Line 96:80: E501 line too long (103 > 79 characters)
Line 98:80: E501 line too long (83 > 79 characters)
Line 102:80: E501 line too long (103 > 79 characters)
Line 105:80: E501 line too long (83 > 79 characters)
Line 109:80: E501 line too long (107 > 79 characters)
Line 111:80: E501 line too long (87 > 79 characters)
Line 113:1: E302 expected 2 blank lines, found 1
Line 114:80: E501 line too long (124 > 79 characters)
Line 116:80: E501 line too long (95 > 79 characters)
Line 118:1: E302 expected 2 blank lines, found 1
Line 119:80: E501 line too long (124 > 79 characters)
Line 121:80: E501 line too long (95 > 79 characters)
Line 123:1: E302 expected 2 blank lines, found 1
Line 130:80: E501 line too long (82 > 79 characters)
Line 132:80: E501 line too long (82 > 79 characters)
Line 134:1: E302 expected 2 blank lines, found 1
Line 135:80: E501 line too long (82 > 79 characters)
Line 137:80: E501 line too long (82 > 79 characters)
Line 139:1: E302 expected 2 blank lines, found 1
Line 144:1: E302 expected 2 blank lines, found 1
Line 149:1: E302 expected 2 blank lines, found 1
Line 153:1: W391 blank line at end of file

Line 77:53: W291 trailing whitespace
Line 344:1: W293 blank line contains whitespace
Line 348:44: W291 trailing whitespace
Line 374:80: E501 line too long (80 > 79 characters)
Line 457:44: W291 trailing whitespace
Line 483:80: E501 line too long (80 > 79 characters)
Line 1677:44: W291 trailing whitespace
Line 1703:80: E501 line too long (80 > 79 characters)
Line 1800:44: W291 trailing whitespace
Line 1827:80: E501 line too long (80 > 79 characters)
Line 1939:44: W291 trailing whitespace
Line 1963:80: E501 line too long (80 > 79 characters)

Line 1095:32: E222 multiple spaces after operator
Line 1099:5: E303 too many blank lines (2)
Line 1106:32: E222 multiple spaces after operator

Comment last updated at 2025-01-06 18:00:18 UTC

Copy link

Linter Bot Results:

Hi @hmacdope! Thanks for making this PR. We linted your code and found the following:

Some issues were found with the formatting of your code.

Code Location Outcome
main package ⚠️ Possible failure
testsuite ✅ Passed

Please have a look at the darker-main-code and darker-test-code steps here for more details: https://github.com/MDAnalysis/mdanalysis/actions/runs/11344140762/job/31548247192


Please note: The black linter is purely informational, you can safely ignore these outcomes if there are no flake8 failures!

Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 97.05882% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.64%. Comparing base (975486e) to head (19f0efc).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
package/MDAnalysis/lib/_distopia.py 94.28% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4734      +/-   ##
===========================================
- Coverage    93.65%   93.64%   -0.02%     
===========================================
  Files          177      189      +12     
  Lines        21795    22916    +1121     
  Branches      3067     3079      +12     
===========================================
+ Hits         20413    21459    +1046     
- Misses         931     1006      +75     
  Partials       451      451              

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

@hmacdope hmacdope marked this pull request as ready for review October 17, 2024 03:26
@hmacdope
Copy link
Member Author

@orbeckst @richardjgowers this is ready for a first look over. The failing tests are for a 180 degree dihedral where numpy returns np.pi and distopia returns -np.pi (equivalent in polar coordinates). Are we ok to change the test to account for this? There are also options for changing in distopia but at the cost of a lot of performance improvement.

@orbeckst
Copy link
Member

I'd be ok with changing tests but adding a note to docs.

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 am not sure if the tests are actually run — if we can confirm that they run then I have no blockers.

ALso updated CHANGELOG, please.

package/MDAnalysis/lib/distances.py Outdated Show resolved Hide resolved
package/MDAnalysis/lib/_distopia.py Outdated Show resolved Hide resolved
@orbeckst
Copy link
Member

FYI, upstream distopia 0.3.0 release is currently breaking all tests, see #4739 .

@orbeckst orbeckst mentioned this pull request Oct 18, 2024
5 tasks
@orbeckst orbeckst mentioned this pull request Oct 18, 2024
8 tasks
@hmacdope hmacdope requested a review from orbeckst January 2, 2025 07:43
@hmacdope
Copy link
Member Author

hmacdope commented Jan 2, 2025

@orbeckst this is probably ready for another look.

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.

Quick first look (sorry for brevity), see minor comments and below:

  • Could you please also make PEP8 happy?
  • Coverage?

@orbeckst
Copy link
Member

orbeckst commented Jan 6, 2025

Something is not right with the macos-13 tests — they timed out at 55 mins and they are again taking much longer than all the other runners.

@IAlibay
Copy link
Member

IAlibay commented Jan 7, 2025

Something is not right with the macos-13 tests — they timed out at 55 mins and they are again taking much longer than all the other runners.

This is unrelated to this PR as far as I can tell (we probably should re-open #4781?). It's been a while but iirc the macos13 images had a sudden performance drop at some point in the last year-ish and it never was resolved. We could drop the tests to be "non optional deps only" that might help keep things a bit sane for now.

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Couple things, apparent missing test coverage is the biggest thing, otherwise (assuming @orbeckst's comments are addressed), lgtm.

has_distopia_020 = all([hasattr(distopia, func) for func in needed_funcs])
if not has_distopia_020:
# check for compatibility: currently needs to be >=0.3.1,
# some versions of `distopia` don't have a version attribute
Copy link
Member

Choose a reason for hiding this comment

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

Are these versions known? I.e. if we know that this only affects a certain set of releases and they are all <0.3.1, then can we skip the warning altogther and just assume that this only happens in old versions we don't care about?

(intent: I'm trying to completly bypass the follow-up "there are no tests for line 50" with a blunt solution)

Copy link
Member

Choose a reason for hiding this comment

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

We can (now) just say that if we are not able to determine the version then it's too old.

package/MDAnalysis/lib/_distopia.py Show resolved Hide resolved
package/MDAnalysis/lib/distances.py Outdated Show resolved Hide resolved
package/MDAnalysis/lib/distances.py Show resolved Hide resolved
@orbeckst
Copy link
Member

orbeckst commented Feb 4, 2025

@hmacdope any bandwidth to get this one done soon-ish? It would be really good to have it in to finish one of the performance track items.

@IAlibay
Copy link
Member

IAlibay commented Feb 4, 2025

@hmacdope any bandwidth to get this one done soon-ish? It would be really good to have it in to finish one of the performance track items.

If I can jump in here - it would be great to get this into a hypothetical v2.9.0 release of MDAnalysis (i.e. one that deals with #4899 and allows us to do py3.13).

@hmacdope
Copy link
Member Author

hmacdope commented Feb 4, 2025

@orbeckst @IAlibay yes can bump up the list, IIRC just need to add some coverage.

@hmacdope hmacdope requested a review from orbeckst February 9, 2025 10:19
@hmacdope
Copy link
Member Author

hmacdope commented Feb 9, 2025

@orbeckst this is probably ready for another round of review. I cut a new release of distopia to change some of the function names, should read much nicer now.

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.

Sorry, just quick: there are distopia-related tests that are failing. Can you please check and fix or if necessary skip tests as needed?

@hmacdope hmacdope changed the title distopia 0.3.0 compatibility changes distopia 0.4.0 compatibility changes Feb 9, 2025
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.

Please see small fixes in comments.

package/MDAnalysis/lib/_distopia.py Outdated Show resolved Hide resolved
has_distopia_020 = all([hasattr(distopia, func) for func in needed_funcs])
if not has_distopia_020:
# check for compatibility: currently needs to be >=0.3.1,
# some versions of `distopia` don't have a version attribute
Copy link
Member

Choose a reason for hiding this comment

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

We can (now) just say that if we are not able to determine the version then it's too old.

try:
distopia_version = Version(distopia.__version__)
except AttributeError:
warnings.warn("distopia version cannot be determined, assuming 0.0.0")
Copy link
Member

Choose a reason for hiding this comment

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

Although we don't need to issue the warning, we need to be able to set the fake distopia version.

Is it worthwhile testing this code path with a proper mock? – @IAlibay ?

Copy link
Member

Choose a reason for hiding this comment

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

Test is simple enough through monkeypatch. Adding it would be great, but I'm not sure it needs to be a blocker for this PR. At the end of the day we'll pin the conda-forge recipe to distopia>=0.4 and probably should do the same for pypi (is there a pypi release of distopia?).

TLDR; I'd be ok to see this is as a follow-up PR, but I agree we probably should do it at some point.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we push to seperate issue? Will raise when this is closed.

(is there a pypi release of distopia?).

No there isn't, very hard to ship required libs.

package/MDAnalysis/lib/distances.py Outdated Show resolved Hide resolved
package/MDAnalysis/lib/distances.py Outdated Show resolved Hide resolved
package/MDAnalysis/lib/distances.py Outdated Show resolved Hide resolved
package/MDAnalysis/lib/distances.py Outdated Show resolved Hide resolved
package/MDAnalysis/lib/distances.py Outdated Show resolved Hide resolved
package/MDAnalysis/lib/distances.py Outdated Show resolved Hide resolved
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.

4 participants