-
Notifications
You must be signed in to change notification settings - Fork 12
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
Proposing xarray
upstream entry-points
#271
Comments
this idea has come up before, see pydata/xarray#7348. You could imagine loading the entrypoint library whenever this particular attribute is accessed, but For now, I'm simply adding |
I was considering a different interface: whenever the module is loaded (e.g. |
that could work, with the downside that now the import time has increased simply by the presence of the library. Given that people have repeatedly complained about long import times (with |
If I understand this correctly it basically involves the new entry point silently running completely arbitrary code at import time. This doesn't seem like a good idea to me. Our existing entry points in Xarray plug into some well-defined interface, and only run in the context of some specific ABC. What you're suggesting here seems a lot more general and prone to abuse. |
What about making the import mylibrary
nc = xr.open_dataset('foo.nc')
nc.mylibrary.myfunc() It's not so much saving a 1-line import as it is avoiding the oddity that you need to do an import but then avoid using the thing you imported directly. |
Rewriting the accessors to use entrypoints instead is an interesting idea... I'm still not quite sure I understand what this would look like but perhaps @dopplershift you could raise this upstream in Xarray for further discussion? |
Abuse wise it is equivalent if it points to a module or an attribute since the same But in the end it does not matter as long as some process of automatically load the extensions is in place. Sure the |
Having to use
import pint_xarray
is a bit clunky especially since it does not have explicit usage and can be deleted by some linters. How about proposing xarray upstream to expose a newentry-points
to whichpint-xarray
can hook. They already havexarray.backends
, but this feels like it doesn't fit there.I am opening an issue here because I am not sure about the naming convention to propose, or how to give an example of how the hook should look like, e.g. at which stage should these entry-points be imported at.
The text was updated successfully, but these errors were encountered: