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

Fix nightly NumPy cron job, add numpy 1.25-dev0 fixes #3977

Merged
merged 31 commits into from
Jan 4, 2023

Conversation

IAlibay
Copy link
Member

@IAlibay IAlibay commented Dec 20, 2022

Towards #3980

Changes made in this Pull Request:

  • Fixes cron job against nightly wheels
  • Fixes array comparison in streamlines_3D

PR Checklist

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

@codecov
Copy link

codecov bot commented Dec 20, 2022

Codecov Report

Base: 93.48% // Head: 93.49% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (2f6f577) compared to base (0c4f823).
Patch coverage: 20.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3977   +/-   ##
========================================
  Coverage    93.48%   93.49%           
========================================
  Files          190      190           
  Lines        24951    24963   +12     
  Branches      3527     3527           
========================================
+ Hits         23326    23338   +12     
  Misses        1102     1102           
  Partials       523      523           
Impacted Files Coverage Δ
package/MDAnalysis/visualization/streamlines.py 54.20% <0.00%> (ø)
package/MDAnalysis/visualization/streamlines_3D.py 70.49% <33.33%> (ø)
package/MDAnalysis/core/groups.py 97.51% <0.00%> (+0.02%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@IAlibay
Copy link
Member Author

IAlibay commented Dec 20, 2022

Looks like we were having numpy conflicts between mamba and pip https://github.com/MDAnalysis/mdanalysis/actions/runs/3739353709/jobs/6346461409#step:6:195

@IAlibay IAlibay changed the title [WIP] Investigate why cron job isn't not pick up nightly NumPy changes [WIP] Investigate why cron job isn't picking up nightly NumPy changes Dec 20, 2022
@IAlibay IAlibay mentioned this pull request Dec 27, 2022
2 tasks
@IAlibay
Copy link
Member Author

IAlibay commented Dec 27, 2022

right it's fixed, and we've actually picked up a breaking change with the nightly dev versions!

cube_counter += 1

def update_dictionary_end_frame(array_simulation_particle_coordinates, dictionary_cube_data_this_core):
"""Update the cube dictionary objects again as appropriate for the second and final frame."""
cube_counter = 0
for key, cube in dictionary_cube_data_this_core.items():
# if there were no particles in the cube in the first frame, then set dx,dy,dz each to 0
if cube['centroid_of_particles_first_frame'] == 'empty':
if cube['centroid_of_particles_first_frame'] == None:
Copy link
Member Author

Choose a reason for hiding this comment

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

That took me far too long to narrow down, looks like the issue here was that we are at times doing an array vs str comparison, which until 1.24 led to a scalar return, but now returns an array of bools instead, that in turns messes up this if/else call.

Doing a comparison against None is probably just safer & more pythonic here?

P.S. Weirdly enough I think this should have thrown an error rather than silently failing i.e. it should have complained about the truth of an array being ambiguous.. but it didn't 😕

Copy link
Member Author

Choose a reason for hiding this comment

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

@IAlibay IAlibay changed the title [WIP] Investigate why cron job isn't picking up nightly NumPy changes Investigate why cron job isn't picking up nightly NumPy changes Jan 2, 2023
@IAlibay
Copy link
Member Author

IAlibay commented Jan 2, 2023

@MDAnalysis/coredevs this should be good to go I think. Once it's merged I'll cherry pick the changes here and create a 2.4.2 bugfix release.

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.

Looks fine to me, thank you for tracking down on all the little things to make it work!

(Minor optional comments below.)

.github/workflows/gh-ci-cron.yaml Show resolved Hide resolved
# overwrite installs by picking up nightly wheels
- name: nightly_wheels
run: |
pip install --pre -U -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy numpy h5py matplotlib
Copy link
Member

Choose a reason for hiding this comment

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

comment: there's a lot of .\\agic hidden in these action files... I would have no idea where to look for these wheels.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think one of the next major tasks here will be to a) document the CI actions, b) clean them up (it's grown a lot beyond what I initially planned back at the start of last year when I squashed things into using re-usable actions).

Copy link
Member Author

Choose a reason for hiding this comment

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

Just to add here before I forget - there is a draft SPEC for nightly wheels: https://scientific-python.org/specs/spec-0004/

It needs a lot of fleshing out though...

pip install --pre -U -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy numpy h5py matplotlib


- name: check_deps
Copy link
Member

Choose a reason for hiding this comment

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

probably more accurately named "list deps"

@@ -281,15 +281,15 @@ def update_dictionary_point_in_cube_start_frame(array_simulation_particle_coordi
axis=0)
cube['centroid_of_particles_first_frame'] = centroid_particles_in_cube
else: # empty cube
cube['centroid_of_particles_first_frame'] = 'empty'
cube['centroid_of_particles_first_frame'] = None
Copy link
Member

Choose a reason for hiding this comment

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

apparently not covered by tests... not sure if this is incorrect or if we must or can cover it but I'll mention it

Copy link
Member Author

Choose a reason for hiding this comment

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

O that is a bit problematic, we really must cover this. It also means we're getting 'empty' entries being fed somewhere else 🙀 Could you place a blocking review here?

Copy link
Member

Choose a reason for hiding this comment

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

done

Copy link
Member Author

@IAlibay IAlibay Jan 2, 2023

Choose a reason for hiding this comment

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

aaaaahhh I was wondering why I was getting to print in that branch but CI wasn't picking up forced errors.. we're using multiprocessing 🤦🏽

I'll have a quick look around but it looks like:
a) Errors aren't being propagated from child workers (hence why it didn't raise the relevant "truth of an array" error),
b) Codecov isn't picking up on coverage since it's not being properly logged by the child workers... we do have the multiprocessing thing set in coveragerc, but it's obviously not working

cube_counter += 1

def update_dictionary_end_frame(array_simulation_particle_coordinates, dictionary_cube_data_this_core):
"""Update the cube dictionary objects again as appropriate for the second and final frame."""
cube_counter = 0
for key, cube in dictionary_cube_data_this_core.items():
# if there were no particles in the cube in the first frame, then set dx,dy,dz each to 0
if cube['centroid_of_particles_first_frame'] == 'empty':
if cube['centroid_of_particles_first_frame'] is None:
Copy link
Member

Choose a reason for hiding this comment

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

comment: Looked innocently enough...

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm surprised it's the only failure we have! 1.25 is going to cause a lot of trouble for legacy downstream codes.

Copy link
Member Author

Choose a reason for hiding this comment

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

there's a really similar 'empty' check in

if square_1_centroid == 'empty' or square_2_centroid == 'empty':

Those probably also need to get changed...

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 confirm the same FutureWarning is happening in streamlines :/ the test isn't good enough to pick it up though.

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.

Test assignment of None instead of "empty", please.

@IAlibay
Copy link
Member Author

IAlibay commented Jan 3, 2023

I'm a little bit confused as to why this specific branch doesn't get covered, it's definitely being entered by some of the workers, and both coverage.py and pytest-cov claim that it should work...

I wonder if there's a bad termination happening somewhere else.

@@ -64,7 +76,7 @@ jobs:

- name: run_tests
run: |
pytest -n $numprocs testsuite/MDAnalysisTests --disable-pytest-warnings --durations=50
pytest -n $numprocs testsuite/MDAnalysisTests --durations=50 -W error::FutureWarning
Copy link
Member Author

Choose a reason for hiding this comment

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

Ideally we'd error on DeprecationWarnings too, but we emit too many of them internally for this to be viable. At least this way we can maybe pick up potential issues?

@@ -176,7 +176,7 @@ def produce_list_centroids_this_frame(list_indices_in_polygon):
list_centroids_this_frame = []
for indices in list_indices_in_polygon:
if not indices[0].size > 0: # if there are no particles of interest in this particular square
list_centroids_this_frame.append('empty')
Copy link
Member Author

Choose a reason for hiding this comment

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

Same issue as per streamlines_3D, also can't get coverage over it (even though the new test assigns None to everything (hence the zeroed array return)

@IAlibay IAlibay changed the title Investigate why cron job isn't picking up nightly NumPy changes Fix nightly NumPy cron job, add numpy 1.25-dev0 fixes Jan 4, 2023
@IAlibay
Copy link
Member Author

IAlibay commented Jan 4, 2023

Ok @orbeckst I think I'm at a point here where codecov is just not playing ball and there's not much else I can think of / find in the docs / issues. I don't understand the problem enough to be able to do a proper bug report either.

Short story is that those code branches are being covered, but they aren't being reported for some reason or another.

My suggestion at this point is to go with this knowing the above, and not delay 2.4.2 any further.

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.

Thanks for all the digging.

Perhaps add CHANGELOG entry for the internal fix in streamlines and streamlines2D? At a later point in time, this will be an actual error so I think it qualifies for a mentioning — it's a fix for a future error that would have happened.

@IAlibay
Copy link
Member Author

IAlibay commented Jan 4, 2023

Perhaps add CHANGELOG entry for the internal fix in streamlines and streamlines2D? At a later point in time, this will be an actual error so I think it qualifies for a mentioning — it's a fix for a future error that would have happened.

I might not be following what you mean here @orbeckst, do you mean something else than what has already been added to the 2.4.2 entry for these?

@orbeckst
Copy link
Member

orbeckst commented Jan 4, 2023

Ah, sorry — the CHANGELOG checkmark was missing in the top comment (EDIT: I checked it now) and the first file entry was not CHANGELOG (as I was used to) so I wrongly assumed that there was no CHANGELOG entry. My bad. The one you have is perfect.

@IAlibay IAlibay merged commit 8d43073 into develop Jan 4, 2023
@IAlibay IAlibay deleted the investigate-cron branch January 4, 2023 17:59
@IAlibay
Copy link
Member Author

IAlibay commented Jan 4, 2023

Ok now to cherry pick everything into a 2.4.2 release.

IAlibay added a commit that referenced this pull request Jan 4, 2023
* Fix cron jobs against nightly wheels
* Address incompatibilities with NumPy 1.25 changes in streamlines and streamlines_3d
@IAlibay IAlibay mentioned this pull request Jan 4, 2023
2 tasks
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.

2 participants