-
Notifications
You must be signed in to change notification settings - Fork 41
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
Proposal: use entrypoints to make array-api submodules discoverable #244
Comments
Thanks @Zac-HD! Discoverability sounds like a great idea.
|
https://packaging.python.org/specifications/entry-points/ says:
So I think we're set there, though I can't speak to how well other tools support the standard or how to use them. |
CC also @asmeurer - programatic discovery of implementations seems useful for the test suite 😉 |
Cool, thanks. If there are other tools that can do it but need some fixes, or even if we can write a tiny package that does exactly this job and nothing else, then that's fine imho. |
We already have |
Early last month in the consortium meeting, this was discussed and there seemed to of been consensus that entrypoints would be a good optional feature for this years spec release. The two immediate use-cases:
And as @Zac-HD originally stated, other tools that end up supporting the Array API might find entrypoints useful. As @rgommers stated, entrypoints only uses features in the 3.8+ standard library. They are already used for NumPy and PyTorch. I made a PR to NumPy which demonstrates how simple this is to support in numpy/numpy#19800, as well as how to test it. So this should be fine to add to the spec, although I'm not sure where. Being optional saves us from any unforeseen consequences, and down the line folk (i.e. me) can ask array module authors which don't initially adopt it to see if they're interested/even knew about it. |
Over in HypothesisWorks/hypothesis#3065, we're working on test tooling that takes an array-api implementation (e.g.
numpy.array_api
, etc) and returns test helpers which use that implementation. For ergonomics we'd also like to automatically find the array-api implementation, if there is one, for a given module - but as I understand it there's no way to discover that mapping. Yet!I therefore propose that as part of the Array API standard, packages implementing the API should register an entry point declaring which (sub)module contains the implementation. For example, Numpy would register:
Implementations can then be found using
importlib.metadata
(see here for < py3.7) as follows:This allows us to avoid hard-coded lists of known libraries and locations, which will inevitably be both incomplete and out of date as the ecosystem evolves. It also makes it easy to find all installed array-api implementations, supporting a much wider range of purposes than testing 🎉
The text was updated successfully, but these errors were encountered: