-
Notifications
You must be signed in to change notification settings - Fork 11
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
Support using only a subset of modules #89
Comments
Hi Eric, Glad you find the package useful! The namespace issue has been in a thorn in my side for a while. I would love to have the flat namespace (i.e. importing modules in pymaid/init.py to make them available at the package level) while also being able to import modules individually. AFAIK there is no way to have the cake and eat it too but if you have a suggestion, please let me know. Currently, I think the flat namespace is more important for most users. There are a few things I can try to help though:
If this is urgent, you could also fork the repository and simply delete the contents of pymaid/init.py. This would allow you to skip a few submodules when importing With
With empty
So this seems to cut the import time almost in half. Maybe I can squeeze out a bit more by improving imports. I'll keep you posted. |
I see nearly identical import time
With empty
The times were a lot worse due to an issue with matplotlib and my font cache, but I seem to have that resolved. All of your suggestions sound good. I have not dug in enough to figure out which bit of code triggers the "app launch" (OS X). It has to be more than a simple |
Nice. Re the GUI being initialised: The only vispy-related things that happen at import time are these (across two different modules):
Does any of this spawn a GUI on your system? |
None of those do it. But Hmm. |
Maybe it's matplotlib then? Try these import statements:
|
Yes, it's matplotlib. I feel bad for trying to place the blame on VisPy. Specifically, it's ``matplotlib.pyplot'', and is where 0m0.647s of the startup time goes. :-) |
In that case this should do the trick for you: If you don't need plotting simply import matplotlib in headless mode before importing pymaid: import matplotlib as mpl
mpl.use('template')
import pymaid To change the default backend permanently, have a look at your matplotlibrc file. |
Thanks! While the startup is still a bit slow, I'm quite content to no longer see the gui launcher. 👍 |
I tried optimizing imports in c7cd847. Unfortunately, there wasn't much to optimize in the first place, so I think any difference will be hardly noticeable. There are two more options:
The first one option would obviously be easier in the short term, the other one might (a) make the package more interesting for a general audience and (b) be easier to maintain in the long run. I'll have a think.... |
Came across lazy-import package. Might be worth using this for e.g. vispy and matplotlib Edit: demand-import also looks good |
Thanks for this great library for interfacing with CATMAID.
It would be great if I could include a single module (e.g. pymaid.fetch) without the other modules. This is currently not possible due to pymaid/__init__.py automatically importing all of the submodules.
The full set of modules can take a while to load on my machine, and the initialization of VisPy leads to the spawning of a GUI application even if no visualization routine is called.
The text was updated successfully, but these errors were encountered: