Becksteinlab / MDPOW

Calculation of water/solvent partition coefficients with Gromacs.
https://mdpow.readthedocs.io
GNU General Public License v3.0
25 stars 10 forks source link

Fix import error in workflows base module (develop branch) #245

Closed cadeduckworth closed 1 year ago

cadeduckworth commented 1 year ago
cadeduckworth commented 1 year ago

@orbeckst

This is from when I had problems with the imports recently. This issue is linked to #243.

I believe I tried the from . import registry method and the from mdpow.workflows import registry methods. I vaguely remember that mdpow is/was not allowing imports from mdpow.workflows or mdpow.workflows.dihedrals, etc. Is it possible that I did not add something required for this to work?

orbeckst commented 1 year ago

Have a look at PR #257 — seems to work.

There shouldn't be any restrictions on imports, there's nothing in MDPOW that messes with Python's import machinery.

I think we had some circular imports involving the registry (base imports registry, dihedrals imports base, registry imports dihedrals) and these circular imports are generally bad because they can lead to memory leaks, but in the PR I broke the import by importing the registry inside base inside a function so it will only be run when needed. At this time, Python figures out that registry is already in sys.modules and will just use that without trying to go to the actual file. All is good 🦄 🌈 .