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

Updated cimport for numpy to maintain cimport consistency #4346

Merged
merged 3 commits into from
Dec 11, 2023
Merged

Updated cimport for numpy to maintain cimport consistency #4346

merged 3 commits into from
Dec 11, 2023

Conversation

Sumit112192
Copy link
Contributor

@Sumit112192 Sumit112192 commented Nov 15, 2023

Fixes #3908

Changes made in this Pull Request:

  • Have updated all cimport numpy from np to cnp

PR Checklist

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

Developers certificate of origin


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

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hello there first time contributor! Welcome to the MDAnalysis community! We ask that all contributors abide by our Code of Conduct and that first time contributors introduce themselves on the developer mailing list so we can get to know you. You can learn more about participating here. Please also add yourself to package/AUTHORS as part of this PR.

Copy link

github-actions bot commented Nov 15, 2023

Linter Bot Results:

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

There are currently no issues detected! 🎉

Copy link

codecov bot commented Nov 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (37d8fee) 93.37% compared to head (491a041) 93.37%.

Additional details and impacted files
@@            Coverage Diff             @@
##           develop    #4346     +/-   ##
==========================================
  Coverage    93.37%   93.37%             
==========================================
  Files          170      184     +14     
  Lines        22340    23453   +1113     
  Branches      4085     4085             
==========================================
+ Hits         20859    21899   +1040     
- Misses         963     1036     +73     
  Partials       518      518             

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

@RMeli
Copy link
Member

RMeli commented Nov 16, 2023

Thanks for the PR @Sumit112192. Looks like a few tests timed out, I'll restart them before having a deeper look.

@RMeli
Copy link
Member

RMeli commented Nov 16, 2023

In the meantime, please add yourself to the AUTHORS file.

@IAlibay
Copy link
Member

IAlibay commented Nov 16, 2023

I believe part of the work that needs doing is checking (maybe adding) benchmarks to ensure that performance isn't affected? If I remember correctly that was an ask from @hmacdope last time someone started a PR on this.

@RMeli
Copy link
Member

RMeli commented Nov 16, 2023

Indeed: #3978 (comment)

@hmacdope
Copy link
Member

@Sumit112192 @IAlibay @RMeli Yes, thanks for taking an intial look here. The issue is that there is a difference in speed calling the C vs normal numpy api, and there are some cases where the C API is less appropriate. Previously we used aliasing which was unclear, but we just need to run the benchmarks to make sure there are no major performance regressions. The way to do this is https://github.com/MDAnalysis/mdanalysis/blob/develop/benchmarks/README.rst. Something like asv continuous <commit on main> <commit at HEAD of this PR >

@hmacdope
Copy link
Member

I imagine if anything performance will improve but we should check

@Sumit112192
Copy link
Contributor Author

Sumit112192 commented Nov 17, 2023

@hmacdope, I am getting an issue with asv.conf.json. In that file, it mentions using python 3.8 version. But in env/09b6664d368df460776d8e73bd3171a0/project/package/pyproject.toml it mentions to use python 3.9+

I ran the command asv continuous 433603 f4005d -e --verbose and got some error regarding python versions and I believe the error was related to the above discrepancy in python versions.

The error

`(my-project-env) sam@sam-Latitude-5480:~/mdanalysis/benchmarks$ asv continuous 433603 f4005d -e --verbose
· Running '/usr/bin/git config init.defaultBranch'
· Running '/usr/bin/git config --global init.defaultBranch'
· Running '/usr/bin/git config --system init.defaultBranch'
· Running '/usr/bin/git rev-parse f4005d^{commit}'
  OUTPUT -------->
  f4005db383f3f4c446433fb32156236f29f251ba
· Running '/usr/bin/git rev-parse 433603^{commit}'
  OUTPUT -------->
  43360341b56823ccc2459a0cf9cc709c2b30283f
· Running '/usr/bin/git config init.defaultBranch'
· Running '/usr/bin/git config --global init.defaultBranch'
· Running '/usr/bin/git config --system init.defaultBranch'
· Creating environments
·· Running '/home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/bin/python -c pass'
· Discovering benchmarks
·· Running '/usr/bin/git rev-parse develop^{commit}'
   OUTPUT -------->
   f4005db383f3f4c446433fb32156236f29f251ba
·· Running '/usr/bin/git -c protocol.file.allow=always submodule deinit -f .'
·· Running '/usr/bin/git checkout -f f4005db383f3f4c446433fb32156236f29f251ba'
   OUTPUT -------->
   Previous HEAD position was 43360341b Updated cimport for numpy to maintain cimport consistency
   HEAD is now at f4005db38 Expose C distance backend in libmdanalysis.pxd (#4342)
·· Running '/usr/bin/git clean -fdx'
·· Running '/usr/bin/git -c protocol.file.allow=always submodule update --init --recursive'
·· Uninstalling from conda-py3.8-Cython-MDAnalysisTests-mock-nose-numpy-pytest-scipy-six
·· Running '/home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/bin/python -mpip uninstall -y mdanalysis'
   OUTPUT -------->
   WARNING: Skipping mdanalysis as it is not installed.
·· Running '/usr/bin/git name-rev --name-only --exclude=remotes/* --no-undefined f4005db383f3f4c446433fb32156236f29f251ba'
   OUTPUT -------->
   develop
·· Building f4005db3 <develop> for conda-py3.8-Cython-MDAnalysisTests-mock-nose-numpy-pytest-scipy-six
·· Running '/home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/bin/python -mpip wheel --no-deps --no-index -w /home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/asv-build-cache/f4005db383f3f4c446433fb32156236f29f251ba /home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/project/package'
   OUTPUT -------->
   Processing /home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/project/package
     Preparing metadata (pyproject.toml): started
     Preparing metadata (pyproject.toml): finished with status 'error'
     error: subprocess-exited-with-error
     
     × Preparing metadata (pyproject.toml) did not run successfully.
     │ exit code: 255
     ╰─> [2 lines of output]
         MDAnalysis requires Python 3.9+. Python 3.8 detected
         Please upgrade your version of Python.
         [end of output]
   
     note: This error originates from a subprocess, and is likely not a problem with pip.
   error: metadata-generation-failed

   
   × Encountered error while generating package metadata.
   ╰─> See above for output.
   
   note: This is an issue with the package mentioned above, not pip.
   hint: See above for details.

·· Error running /home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/bin/python -mpip wheel --no-deps --no-index -w /home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/asv-build-cache/f4005db383f3f4c446433fb32156236f29f251ba /home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/project/package (exit status 1)
·· Failed: trying different commit/environment
·· Running '/usr/bin/git -c protocol.file.allow=always submodule deinit -f .'
·· Running '/usr/bin/git checkout -f 43360341b56823ccc2459a0cf9cc709c2b30283f'
   OUTPUT -------->
   Previous HEAD position was f4005db38 Expose C distance backend in libmdanalysis.pxd (#4342)
   HEAD is now at 43360341b Updated cimport for numpy to maintain cimport consistency
·· Running '/usr/bin/git clean -fdx'
·· Running '/usr/bin/git -c protocol.file.allow=always submodule update --init --recursive'
·· Uninstalling from conda-py3.8-Cython-MDAnalysisTests-mock-nose-numpy-pytest-scipy-six
·· Running '/home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/bin/python -mpip uninstall -y mdanalysis'
   OUTPUT -------->
   WARNING: Skipping mdanalysis as it is not installed.
·· Running '/usr/bin/git name-rev --name-only --exclude=remotes/* --no-undefined 43360341b56823ccc2459a0cf9cc709c2b30283f'
   OUTPUT -------->
   shiny-new-fix
·· Building 43360341 <shiny-new-fix> for conda-py3.8-Cython-MDAnalysisTests-mock-nose-numpy-pytest-scipy-six
·· Running '/home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/bin/python -mpip wheel --no-deps --no-index -w /home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/asv-build-cache/43360341b56823ccc2459a0cf9cc709c2b30283f /home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/project/package'
   OUTPUT -------->
   Processing /home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/project/package
     Preparing metadata (pyproject.toml): started
     Preparing metadata (pyproject.toml): finished with status 'error'
     error: subprocess-exited-with-error
     
     × Preparing metadata (pyproject.toml) did not run successfully.
     │ exit code: 255
     ╰─> [2 lines of output]
         MDAnalysis requires Python 3.9+. Python 3.8 detected
         Please upgrade your version of Python.
         [end of output]
   
     note: This error originates from a subprocess, and is likely not a problem with pip.
   error: metadata-generation-failed

   
   × Encountered error while generating package metadata.
   ╰─> See above for output.
   
   note: This is an issue with the package mentioned above, not pip.
   hint: See above for details.

·· Error running /home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/bin/python -mpip wheel --no-deps --no-index -w /home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/asv-build-cache/43360341b56823ccc2459a0cf9cc709c2b30283f /home/sam/mdanalysis/benchmarks/env/09b6664d368df460776d8e73bd3171a0/project/package (exit status 1)
·· Failed to build the project and import the benchmark suite.`

@Sumit112192
Copy link
Contributor Author

Sumit112192 commented Nov 17, 2023

I changed the Python version in asv.conf.json to 3.9 to run the benchmark test.
Attached are the benchmark results:
benchmarkOutput.log

Can you explain what the results are? @hmacdope @RMeli
They are in --verbose mode, so the output is too large. Should I run it without verbose, so it might be easier to go through?

@hmacdope
Copy link
Member

There should be a little summary at the end that compares performance of the two runs. Try again without verbose?

@Sumit112192
Copy link
Contributor Author

@hmacdope, I tried without verbose. But it was still without any summary.

@hmacdope
Copy link
Member

hmacdope commented Dec 5, 2023

@Sumit112192 I will run benchmarks for you, sorry for delay.

Copy link
Member

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

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

The diff looks "ok" to me. The benchmark suite is currently broken because of gh-3519 when I check locally, and it looks like several other issues may be present as well.

@tylerjereddy
Copy link
Member

FWIW, I'd probably just vote to merge it. The benchmark suite is a bit of a mess at the moment it seems. I'll see if I can re-run with the failing benchmarks skipped using a regex, but it is annoying to do.

@hmacdope
Copy link
Member

Similar thing to report, no performance regressions observed on my run. Benchmarks not all running at @tylerjereddy observed, but I am also pretty happy with the diff. I will approve.

Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

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

Just changelog.

package/CHANGELOG Outdated Show resolved Hide resolved
@hmacdope
Copy link
Member

Also @Sumit112192 is this your first contribution? If so add yourself to AUTHORS.

@Sumit112192
Copy link
Contributor Author

@hmacdope I force-pushed the latest commit in which I updated the CHANGELOG and AUTHORS files. Is there any issue with the force commit?

@Sumit112192
Copy link
Contributor Author

@hmacdope I read that force pushing can be dangerous as it deletes other commit history. How can I delete my above force push? Or should I create another pull request using normal push?

@hmacdope
Copy link
Member

@hmacdope I read that force pushing can be dangerous as it deletes other commit history. How can I delete my above force push? Or should I create another pull request using normal push?

The diff looks fine to me. no easy way to fix a force push but it's OK, your PR will all be squashed into one commit. No need to stress. We can continue here on this PR

@Sumit112192
Copy link
Contributor Author

Sumit112192 commented Dec 10, 2023

@hmacdope relieved to hear that it is not a big issue. Also, I would like to work on the benchmark issue thing. How to get started on it? Any literature, I can follow to learn more about it?

@Sumit112192
Copy link
Contributor Author

Sumit112192 commented Dec 10, 2023

That closed thing happened by mistake. Sorry for that.

@Sumit112192 Sumit112192 reopened this Dec 10, 2023
Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

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

Just the newest first change, might have got lost in the force push, but if you could just make the change again should be good to go.

package/CHANGELOG Outdated Show resolved Hide resolved
Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

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

Great work @Sumit112192! Super happy that you managed to improve our cimport consistency. Has been needed for a while. :) I will wait for @tylerjereddy to also approve, then good to roll.

@tylerjereddy tylerjereddy merged commit 6179b2b into MDAnalysis:develop Dec 11, 2023
23 checks passed
@tylerjereddy
Copy link
Member

I squash-merged per MDA convention (I think), thanks!

Only two files had changed since my positive review, and they were just author/changelog things.

I doubt there will be any performance surprises, but hopefully our benchmarks are in better shape soon.

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

Successfully merging this pull request may close these issues.

change cimport numpy as np to cimport numpy as cnp for consistency
5 participants