mxcubecore module, python path and import
Created by: marcus-oscarsson
Dear All,
The current mechanism of loading HardwareObjects via __import__
in load_module relies on the modules are in the python path.
It means that this logic is needed to append those modules to sys.path.
The consequence of this is that modules that are loaded via the xml and yaml files are imported relatively with the class name.
Using mxcubecore as a python module with this logic as some unwanted side effects:
- sys.path is modified
- Using an absolute import for instance
from mxcubecore.HardwareObjects import <hardware object>
wont result in the same module as the one loaded from the xml files (as the later is relative). Thus the isinstance check for instance fails.
I would suggest to change load_module
so that it uses absolute imports instead.
Are there some other ideas or thoughts around this ?