Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BLD: Build scikit-learn nightlies using NumPy nightlies #27735

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

Merged
merged 4 commits into from
Nov 20, 2023

Conversation

seberg
Copy link
Contributor

@seberg seberg commented Nov 6, 2023

There are two commits here:

  1. Adapt the requirements to use >=1.25, except on Python <3.9 because NumPy 1.25 isn't compatible with that. (For new releases prior to NumPy 2.0, it would be good to add <2.0 probably.)
  2. Build the wheels with all pre-releases. This lives on the edge, and it is perfectly reasonable if you don't like it (matplotlib opted for that, but I am not sure it is generally liked). Living on the edge, also requires the change in 1. (unlike build isolation), but is the smaller change.
    (one could also make use <=2.0.0.dev0 as a requirement. That is odd, but explicitly allows the nightlies, while rejecting a 2.0 release if it came up in an actual released version.)

I moved the "$CIRRUS_CRON" == "nightly" logic to avoid additional duplication. I tested it locally (in parts), and it build with 2.0 nightlies (failing, since my other PR is needed).

This requires gh-27041 to be merged, or the build will fail!

Copy link

github-actions bot commented Nov 6, 2023

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 5bf7301. Link to the linter CI: here

@betatim
Copy link
Member

betatim commented Nov 7, 2023

The idea here is that in the future you can use Numpy 2.0 to build a wheel that works with Numpy 1.x (1.25? lower? higher?) and that we can simulate this/start preparing for this by today using the Numpy nightly as a stand in for Numpy 2.0?

@seberg
Copy link
Contributor Author

seberg commented Nov 7, 2023

that works with Numpy 1.x (1.25? lower? higher?)

The lower bound won't really change (well, we should bump it slowly probably).

and that we can simulate this/start preparing for this by today using the Numpy nightly as a stand in for Numpy 2.0?

More importantly, NumPy can actually start using that fact. Which allows certain ABI breaks, mainly through forcing some API changes (not that I would expect this to matter in practice for sklearn, but we will see).

@betatim
Copy link
Member

betatim commented Nov 7, 2023

The lower bound won't really change (well, we should bump it slowly probably).

Currently the minimum required version of Numpy is 1.17.3 for users of scikit-learn. So for now we need the wheel to work with quite an old version.

More importantly, NumPy can actually start using that fact. Which allows certain ABI breaks, mainly through forcing some API changes (not that I would expect this to matter in practice for sklearn, but we will see).

Ok, this is a good reason to get this merged then!

@seberg
Copy link
Contributor Author

seberg commented Nov 7, 2023

The backcompat in NumPy defaults to as far back as is plausible; as long you don't build stable API wheels (a single wheel for all Python 3.x versions).
(I.e. if you build on 3.9, the oldest NumPy version that supports 3.9 is acceptable; in practice it is even further.)

If you ever need to, you can override the default, but more likely, if things break, NumPy got it wrong.

@lesteve
Copy link
Member

lesteve commented Nov 8, 2023

Do I understand correctly that the main goal of this PR is to build wheels against numpy development version and to test the wheels against the numpy latest release?

@seberg
Copy link
Contributor Author

seberg commented Nov 8, 2023

is to build wheels against numpy development version and to test the the wheels against the numpy latest release?

The first, but it is important. We don't even want to test the wheels against the NumPy dev version. This shouldn't, and that is good! You are already testing against fully NumPy dev in the normal tests.

@ogrisel
Copy link
Member

ogrisel commented Nov 13, 2023

it would be good to add <2.0 probably.

Is there a way to do that by default (for users who build scikit-learn from source or for our cibuildwheel CI when we do releases) but remove that upper bound in our nightly builds?

@ogrisel
Copy link
Member

ogrisel commented Nov 13, 2023

is to build wheels against numpy development version and to test the the wheels against the numpy latest release?

The first, but it is important. We don't even want to test the wheels against the NumPy dev version. This shouldn't, and that is good! You are already testing against fully NumPy dev in the normal tests.

I don't understand this. We are testing against NumPy dev only in our "scipy-dev" CI entry. All other CI configs (e.g. the "normal" ones that run to check PRs and the ones that run when building the wheels run against released versions of NumPy).

@seberg
Copy link
Contributor Author

seberg commented Nov 13, 2023

Is there a way to do that by default (for users who build scikit-learn from source

Yes, but it will it make users life easier? Users won't use NumPy 2 pre-releases anyway, unless they opt-in explicitly in some form. And if they want it, you are making it harder for them.

Now release versions are probably better off with the upper pin, so if you prefer it to make sure that the release version has it then I can do that. It needs a bunch of extra branching to use no-build-isolation (or the weird hack of using <=2.0.0.dev0, although there may be some odd corners where it isn't ideal).

We are testing against NumPy dev only in our "scipy-dev" CI entry

Yeah, and I think it both builds and tests with our nightly wheels. OTOH, the nightly wheels are build with 2.0dev now but I think also tested before upload. And that test does not use our nightlies here.

@ogrisel
Copy link
Member

ogrisel commented Nov 13, 2023

I did a review of #27041. Once merged, please update this PR and trigger the cibuildwheel CI into this PR by pushing a commit with [cd build] in the commit message.

For those Python versions, just using NumPy defaults to the same
backwards compatibility constraints as oldest-support-numpy.
NumPy 2.0 needs building with NumPy 2.0 (very soon) to allow some
larger changes (technically, this is already necessary).

Thus, nightlies must be build with NumPy 2.0 (it is better to not
test them with it, which this does).

This takes the simplified route of just using any pre-releases during
nightly builds.  If that fails (say cython is broken for a bit) then
this could be adapted to explicitly install numpy and using
`--no-build-isolation` instead.
(Might require a bit of care to not use the same env when testing, not sure)
@seberg seberg force-pushed the build-numpy-nightly branch from 8b1b73f to d1b29c1 Compare November 17, 2023 08:59
@seberg
Copy link
Contributor Author

seberg commented Nov 17, 2023

please update this PR and trigger the cibuildwheel CI into this PR by pushing a commit with [cd build] in the commit message

Done, I am not sure what [cd build] actually runs. With the current setup, I think it might run the normal wheel build, not the nightly one? (and only on cirrus)

@lesteve
Copy link
Member

lesteve commented Nov 17, 2023

The wheel did not get built in the previous commit, it looks like you need [cd build] in the first line of the commit message. I just pushed a new [cd build] commit.

@seberg
Copy link
Contributor Author

seberg commented Nov 17, 2023

FWIW, I did try on my fork in main to build the nightlies and chron trigger and it seemed OK.

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM

@thomasjpfan thomasjpfan added the Waiting for Second Reviewer First reviewer is done, need a second one! label Nov 19, 2023
@lesteve lesteve merged commit 7ceb4d8 into scikit-learn:main Nov 20, 2023
@seberg seberg deleted the build-numpy-nightly branch November 20, 2023 10:14
@lesteve
Copy link
Member

lesteve commented Nov 20, 2023

Merging this one, thanks!

In the future, if we realise that installing the development all our dependencies when building the wheels fails too often, we can always look at installing only the development Numpy development version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No Changelog Needed Waiting for Second Reviewer First reviewer is done, need a second one!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants