ome / omero-py

Python project containing Ice remoting code for OMERO
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
22 stars 32 forks source link

circular import error in Omero modules #179

Open bgruening opened 4 years ago

bgruening commented 4 years ago

This works for us, but does not following the python linting recommendations.

from omero.gateway import BlitzGateway  # noqa
from omero.constants.namespaces import NSBULKANNOTATIONS  # noqa

This is crashing:

from omero.constants.namespaces import NSBULKANNOTATIONS 
from omero.gateway import BlitzGateway 

with the following traceback, indicating a circular import.

| Dataset Job Standard Error:
|  Traceback (most recent call last):
|  File "/home/travis/.planemo/planemo_tmp_1gpdzvum/idr_download_by_ids.py", line 7, in <module>
|  from omero.gateway import BlitzGateway
|  File "/usr/local/lib/python3.8/site-packages/omero/gateway/__init__.py", line 57, in <module>
|  import omero.clients
|  File "/usr/local/lib/python3.8/site-packages/omero/clients.py", line 20, in <module>
|  model = __import__('omero.model')
|  File "/usr/local/lib/python3.8/site-packages/omero/model/__init__.py", line 10, in <module>
|  from omero import ObjectFactoryRegistrar
|  File "/usr/local/lib/python3.8/site-packages/omero/ObjectFactoryRegistrar.py", line 10, in <module>
|  class AcquisitionModeObjectFactory(Ice.ObjectFactory):
|  File "/usr/local/lib/python3.8/site-packages/omero/ObjectFactoryRegistrar.py", line 12, in AcquisitionModeObjectFactory
|  from omero_model_AcquisitionModeI import AcquisitionModeI
|  File "/usr/local/lib/python3.8/site-packages/omero_model_AcquisitionModeI.py", line 18, in <module>
|  IceImport.load("omero_model_DetailsI")
|  File "/usr/local/lib/python3.8/site-packages/IceImport.py", line 22, in load
|  __import__(target)
|  File "/usr/local/lib/python3.8/site-packages/omero_model_DetailsI.py", line 14, in <module>
|  IceImport.load("omero_model_Details_ice")
|  File "/usr/local/lib/python3.8/site-packages/IceImport.py", line 22, in load
|  __import__(target)
|  File "/usr/local/lib/python3.8/site-packages/omero_model_Details_ice.py", line 263, in <module>
|  ('_owner', (), _M_omero.model._t_Experimenter, False, 0),
|  AttributeError: partially initialized module 'omero.model' has no attribute '_t_Experimenter' (most likely due to a circular import)
jburel commented 4 years ago

Thanks @bgruening for the report. Using Ice creates headache for imports. It is a major problem. This will require some major rework. We are aiming to remove the usage of Ice in the near future. Not following the linting recommendations is the best approach at this point in time