Skip to content
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

import in __init__.py #92

Open
JNmpi opened this issue Oct 8, 2024 · 0 comments
Open

import in __init__.py #92

JNmpi opened this issue Oct 8, 2024 · 0 comments

Comments

@JNmpi
Copy link
Contributor

JNmpi commented Oct 8, 2024

When merging @Tara-Lakshmipathy's additions to the pyiron_nodes library without installing all necessary Python modules (in this case fenics), all nodes failed. The reason is that although only one module needs this library, all modules are imported via the import statements in the init.py files. A simple fix would be to remove these imports, but then autocompletion in Jupyter notebooks will not work. The GUI is not affected (since I used lazy loading there), but for the code input this is not acceptable.

An obvious solution would be to put all heavy modules into the node functions. However, this only works to a certain extent, since type hinting often requires such modules to be loaded (e.g. ase for the atom type). This difficulty in combining autocompletion and lazy import seems to be a fundamental problem in Python, and there are long discussions about it without a good solution. Suggestions/ideas are welcome. We should also address this issue in our strategy meeting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant