Skip to content

CI: add pinning for scipy-openblas wheels#25697

Merged
rgommers merged 4 commits intonumpy:mainfrom
mattip:pin-openblas-wheels
Jan 30, 2024
Merged

CI: add pinning for scipy-openblas wheels#25697
rgommers merged 4 commits intonumpy:mainfrom
mattip:pin-openblas-wheels

Conversation

@mattip
Copy link
Member

@mattip mattip commented Jan 26, 2024

Upgrading OpnBLAS should be done in a controlled fashion. Using the scipy-openblas wheels without pinning could cause problems when the wheel version is updated and pip installs a new version.

This PR adds a ci_requirements.txt file to pin the version. In order to only use one file, it will install both scipy-openblas64 and scipy-openblas32 wheels. While wasteful in terms of bandwidth/time, this will not cause problems since the subsequent use of the wheel is variant-specific.

Thoughts?

@github-actions github-actions bot added the 36 - Build Build related PR label Jan 26, 2024
@mattip
Copy link
Member Author

mattip commented Jan 26, 2024

Hmm. The ci_requirements.txt has both 64- and 32-bit scipy-openblas, which won't work on 32-bit windows. So it seems my quest for "single source of truth" is doomed?

@mattip
Copy link
Member Author

mattip commented Jan 26, 2024

Ahh, I can add a selector It seems there is no selector for sys.maxsize > 2**32

@rgommers
Copy link
Member

Ahh, I can add a selector It seems there is no selector for sys.maxsize > 2**32

That is a known issue indeed, you cannot distinguish between 32-bit/64-bit Windows (or, more likely, 32-bit CPython on 64-bit Windows).

So it seems my quest for "single source of truth" is doomed?

You could add separate requirements files for these specific packages. Although I'm not sure that that is any cleaner than direct pins where they are used in CI config files.

Related comment: these *_requirements.txt files are making ever more of a mess in the top-level directory. I'm not a fan of that. How about we move them all to a requirements/ directory?

@rgommers rgommers changed the title BLD: add pinning for scipy-openblas wheels CI: add pinning for scipy-openblas wheels Jan 26, 2024
@rgommers rgommers removed the 36 - Build Build related PR label Jan 26, 2024
@mattip
Copy link
Member Author

mattip commented Jan 26, 2024

Although I'm not sure that that is any cleaner than direct pins where they are used in CI config files.

It is 9 pins across 7 files. Updating that correctly will be painful.

How about we move them all to a requirements/ directory?

Makes sense

Comment on lines +1 to +3
spin
scipy-openblas64<0.3.26
scipy-openblas32<0.3.26
Copy link
Member

Choose a reason for hiding this comment

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

Another aspect to consider here is third-party packages being used to sneak into CI and inherit any permissions of CI. For instance, if we install a wheel that's unpinned and without hash validation, there is the chance of an attacker being able to publish a package, which is then loaded into a CI job with permission to publish a NumPy wheel. This may seem a bit farfetched, but I've been involved in security incidents involving Bitcoin miners being installed into systems this way 😸 In the past, this was one of the motivators for poetry and lock files.

In this case, it's a remote possibility, given we also publish the scipy-openblas wheels, but given we can fix the versions, would it be worth adding a hash for best practice anyway?

Copy link
Member

Choose a reason for hiding this comment

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

which is then loaded into a CI job with permission to publish a NumPy wheel.

This is not possible, our CI doesn't have any permissions beyond those needed to run CI jobs. And we should keep it that way - the potential security issues you point out here being a main reason.

PyPI upload permissions are limited to a know small set of maintainers, who must do so themselves while using 2FA.

would it be worth adding a hash for best practice anyway?

Our current stance on hashes is:

  • no for Actions that are built into GitHub, yes for others from random publishers
  • dependencies: no, this is too much churn and overhead, for no real-world gain.

Running CI jobs with everything pinned does have other advantages - primarily better reproducibility, so some new version of a random dependency being released not being able to break our CI. However, it would be a big overhaul. And at that point we should follow scikit-learn/pandas and move it all to conda envs.

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 is a bit beyond this PR. If you feel deeply about hashes, could you open an issue about pinning hashes of all dependencies? I am against, I think it is overkill, but am willing to discuss.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, if I feel enthusiastic I will, but I'm happy with the stance from @rgommers 😸

@mattip mattip force-pushed the pin-openblas-wheels branch from a4193bc to ab60d6d Compare January 30, 2024 15:50
@mattip
Copy link
Member Author

mattip commented Jan 30, 2024

I moved all the requirements files to a requirements directory, and updated the documentation via looking at all the results of git grep _requirements.

I also added a ci32_requirements.txt file for 32-bit builds, the 64-bit ones still install both scipy-openblas32 and scipy-openblas64 wheels, and choose the proper one via spin --with-scipy-openblas=X

@mattip mattip requested a review from rgommers January 30, 2024 16:10
Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

Thanks @mattip. Overall this LGTM. Only one suggestion: all_requirements.txt should probably be modified to include ci_requirements.txt?

@mattip
Copy link
Member Author

mattip commented Jan 30, 2024

I added ci_requirements to all_requirements in c9139e and checked locally that it works

python3.11 -m venv /tmp/throwaway
source /tmp/throwaway/bin/activate
pip install -r requirements/all_requirements.txt

Since this is a convenience file and not used in CI, I skipped all testing.

@rgommers rgommers merged commit 418cd1b into numpy:main Jan 30, 2024
@rgommers
Copy link
Member

Good to go then, thanks Matti!

@mattip mattip deleted the pin-openblas-wheels branch May 5, 2025 11:21
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.

3 participants