You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SciPy has offloaded its functions of this sort to array-api-extra, which it now vendors via a git submodule. The main purpose of scikit-learn doing the same is to share the work which has been done with any other consumer library via a clear API Reference, rather than them having to dig through the source code and copy & paste (or reinvent the wheel). There are other benefits too, as the functions in array-api-extra get proper documentation, tests, and static type hints.
The question is then how to adopt array-api-extra in scikit-learn. From the discussion with @betatim we concluded that array-api-extra is not best suited as an optional dependency, as boilerplate would need to be added to catch the case that it isn't installed and either error or replicate the functions with NumPy.
Does scikit-learn have an established process for vendoring code from other repos? In gh-30340 I tried to wrangle CI to get a git submodule to work, but there may be alternatives to that.
A sidenote is that scikit-learn may want to look into vendoring array-api-compat itself rather than having an optional dependency. In the meeting, it wasn't clear why it was done this way in the first place.
A sidenote is that scikit-learn may want to look into vendoring array-api-compat itself rather than having an optional dependency. In the meeting, it wasn't clear why it was done this way in the first place.
At the time, Array API support was experimental and array-api-compat was iterating quickly. Given that scikit-learn has a slower release cycle, we did not want to have users wait for a scikit-learn release to get any fixes from array-api-compat.
Does scikit-learn have an established process for vendoring code from other repos?
There is no set process. Historically, we just copy over the code with it's license. When I was looking to vendor lazy_loader, I added a script to do it:
I think the question that we should answer first is: do we want to use array-api-extra? It has the advantages that Lucas listed. A downside is that when we need a new function we need to first add it to array-api-extra, then update the vendored code, then work on the feature. Or have a way to have functions in sklearn.utils._array_api as well as use functions from array-api-extra, which brings some complexity with it.
I am a -0.5 on having to go through the three step process in order to have new functions available. Not because it is super complicated, but it adds a lot of extra steps and delays to the process. Which I think will make it significantly harder for "random people off the internet highway" to contribute to the array-api'fication of scikit-learn. So I think we need some way to have a mixture, that isn't too complex to maintain.
What do y'all think?
I am -1 on git submodules. They seem to mostly cause trouble and complexity. A script that helps update the code sounds better.
A downside is that when we need a new function we need to first add it to array-api-extra, then update the vendored code, then work on the feature. Or have a way to have functions in sklearn.utils._array_api as well as use functions from array-api-extra, which brings some complexity with it.
See my answer to Omar in the PR:
It doesn't have to be instead of utils. I would suggest you keep your current workflow the exact same - you can still put private helpers in utils to start off with. But in addition, every now and then, you can offload them to array-api-extra so that others can use them. That's what we're doing in SciPy.
Making use of both does not seem to add significant complexity IMO.
Activity
thomasjpfan commentedon Nov 28, 2024
At the time, Array API support was experimental and
array-api-compatwas iterating quickly. Given that scikit-learn has a slower release cycle, we did not want to have users wait for a scikit-learn release to get any fixes fromarray-api-compat.There is no set process. Historically, we just copy over the code with it's license. When I was looking to vendor
lazy_loader, I added a script to do it:https://github.com/thomasjpfan/scikit-learn/blob/lazy_import/maint_tools/vendor_lazy_loader.sh
It's basically git submodule without actually using it.
betatim commentedon Dec 2, 2024
I think the question that we should answer first is: do we want to use array-api-extra? It has the advantages that Lucas listed. A downside is that when we need a new function we need to first add it to array-api-extra, then update the vendored code, then work on the feature. Or have a way to have functions in
sklearn.utils._array_apias well as use functions from array-api-extra, which brings some complexity with it.I am a -0.5 on having to go through the three step process in order to have new functions available. Not because it is super complicated, but it adds a lot of extra steps and delays to the process. Which I think will make it significantly harder for "random people off the internet highway" to contribute to the array-api'fication of scikit-learn. So I think we need some way to have a mixture, that isn't too complex to maintain.
What do y'all think?
I am -1 on git submodules. They seem to mostly cause trouble and complexity. A script that helps update the code sounds better.
lucascolley commentedon Dec 2, 2024
See my answer to Omar in the PR:
Making use of both does not seem to add significant complexity IMO.