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 mac tests with conda #4946

Merged
merged 6 commits into from
Nov 22, 2024
Merged

Conversation

duncanmmacleod
Copy link
Member

@duncanmmacleod duncanmmacleod commented Nov 18, 2024

Standard information about the request

This is a: bug fix

This change affects: continuous integration

This change changes: continuous integration

This change: has appropriate unit tests, follows style guidelines (See e.g. PEP8), has been proposed using the contribution guidelines

This change will: n/a

Motivation

Fixes #4939

Contents

This PR fixes #4939 by updating the CI/tox configuration for macOS.

Links to any issues or associated PRs

Fixes #4939
Closes #4944

Testing performed

Additional notes

  • The author of this pull request confirms they will adhere to the code of conduct

@duncanmmacleod duncanmmacleod force-pushed the fix-macos-tests-conda branch 3 times, most recently from 326549a to 6257a5a Compare November 18, 2024 10:43
@duncanmmacleod duncanmmacleod marked this pull request as ready for review November 18, 2024 10:43
@duncanmmacleod
Copy link
Member Author

@titodalcanton @ahnitz, I think this fixes the test configuration, but exposes a real-world test failure:

E       AttributeError: module 'numpy' has no attribute 'float128'. Did you mean: 'float16'?

I don't think this object is available on arm64. Can/should the calling code be patched to use numpy.longdouble?

@duncanmmacleod duncanmmacleod force-pushed the fix-macos-tests-conda branch 5 times, most recently from 6bbf624 to 220f171 Compare November 18, 2024 11:55
@spxiwh
Copy link
Contributor

spxiwh commented Nov 18, 2024

The lapack pinned version was important ...

@duncanmmacleod
Copy link
Member Author

The lapack pinned version was important ...

Why? It is (I think) precisely the reason why the build is failing, that old version of lapack has not been, and will not be, built for macOS on ARM64.

@spxiwh
Copy link
Contributor

spxiwh commented Nov 18, 2024

@duncanmmacleod I think lapack stopped shipping the headers after this release, making it very hard to build codes from source that compile against it. There's also this weirdness about liblapacke, which I think also isn't in the new releases.

https://github.com/mikekatz04/BBHx?tab=readme-ov-file#prerequisites (because PyCBC does not use lapack directly, we use it via numpy like most).

I have built a BBHx env on my ARM mac though using this version of lapack ... Though it does cause an issue on the IGWN envs (where lapack, or the lapack headers, are not present), which is a discussion I'd been meaning to have with you at some point.

@spxiwh
Copy link
Contributor

spxiwh commented Nov 18, 2024

Although I now see that my mac env has lapack=3.9.0 installed, so I'm not sure how that worked/is working.

tox.ini Outdated
; Tell the linker to look for shared libs inside the temporary Conda env.
; Needed to build BBHx's wheel, whick links to LAPACK.
LIBRARY_PATH={envdir}/lib:{env:LIBRARY_PATH:}
ligo-segments
Copy link
Member

Choose a reason for hiding this comment

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

@duncanmmacleod Thanks for looking into this!

A couple of these are python packages that we should be picking up through the requirements. At least

ligo-segments and python-ligo-lw should probably be removed from conda_deps, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ahnitz, these two packages are specifically called out in the conda requirements because PyPI only has a source distribution and these projects don't build cleanly with newer Python versions and newer versions of Clang. This means that pip install python-ligo-lw fails.

The conda packages include the necessary patches to build, but that hasn't (yet) been backported into the source distribution.

Copy link
Member

Choose a reason for hiding this comment

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

@duncanmmacleod Ok, that's fair enough. In which case, I'd just request a comment explaining this. In principle these lines should be removed once those changes have been included in the upstream code.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ahnitz, I have separated things out so that there is a unique commit that adds these packages to the tox.ini file (with a comment) that can be simply reverted when appropriate.

@duncanmmacleod
Copy link
Member Author

Although I now see that my mac env has lapack=3.9.0 installed, so I'm not sure how that worked/is working.

This is the difference between the packages that provided the headers, and those that provide the libraries. The headers do seem to be a little muddled, it took me a while to find that we need the packages liblapacke to get lapacke.h and openblas to get lapack.h.

@spxiwh
Copy link
Contributor

spxiwh commented Nov 20, 2024

@titodalcanton @ahnitz, I think this fixes the test configuration, but exposes a real-world test failure:

E       AttributeError: module 'numpy' has no attribute 'float128'. Did you mean: 'float16'?

I don't think this object is available on arm64. Can/should the calling code be patched to use numpy.longdouble?

@duncanmmacleod The failure related to this that I see above is in a test case that is really designed to test "have we broken anything in PyCBC Live". It compares to an old version of PyCBC Live which wouldn't run on a mac (though the test may now run on a mac with this change), so this comparison may not make sense on a mac ... But all other places have changed float128 to numpy.longdouble ... I'm confused how this didn't break before??

So in short, I would be happy with just changing this. If the test still fails, disable it on mac.

@duncanmmacleod
Copy link
Member Author

So in short, I would be happy with just changing this. If the test still fails, disable it on mac.

@spxiwh, I took the liberty of adding that change, and it fixes the tests, so I'm happy.

There are other uses of numpy.float128, e.g.

from numpy import sqrt, log, float128
, but I am making no attempt to address those.

@spxiwh
Copy link
Contributor

spxiwh commented Nov 20, 2024

Interesting! I hadn't been aware that module even existed. Something to be removed, I think!

tox.ini Outdated Show resolved Hide resolved
@titodalcanton
Copy link
Contributor

I think this also cleans up a bit the problem mentioned in #4857. Thanks @duncanmmacleod.

use setup-miniconda github action and specify more packages in conda_deps for each testenv
these packages don't install cleanly with pypi, but the conda packages have patches
float128 isn't available on macOS ARM64
conda install \
pip \
setuptools \
"tox<4.0.0"
Copy link
Member Author

Choose a reason for hiding this comment

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

Is this restriction understood?

Copy link
Contributor

Choose a reason for hiding this comment

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

The reason was discussed here #4208 ... It may no longer apply.

@titodalcanton
Copy link
Contributor

We list the same conda-deps twice now, is it possible to deduplicate that with something like {[base-conda-deps]}?

@duncanmmacleod
Copy link
Member Author

We list the same conda-deps twice now, is it possible to deduplicate that with something like {[base-conda-deps]}?

@titodalcanton I have attempted to clean this up by moving the conda_deps into [base] and creating a new [bbhx] section with the options specific to that extra project.

I am not very familiar with tox and tox.ini syntax, so I could easily have done something bad.

Copy link
Contributor

@titodalcanton titodalcanton left a comment

Choose a reason for hiding this comment

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

As far as I can tell the tests now work for Mac as well, they pass, and the CI configuration has been simplified.

@spxiwh
Copy link
Contributor

spxiwh commented Nov 22, 2024

Thanks @duncanmmacleod ... I see no further comments on this, and the tests are passing, so merging now.

@spxiwh spxiwh merged commit 7e4ca12 into gwastro:master Nov 22, 2024
29 checks passed
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.

macOS tests seem broken
4 participants