marieai / marie-ai

Integrate AI-powered Document Analysis Pipelines
MIT License
60 stars 5 forks source link

circular import #101

Closed Rithsek99 closed 9 months ago

Rithsek99 commented 9 months ago

Describe the bug when oc-gradio we get the follow error, potentially circular import.

File "/home/rngem/Desktop/rms/marie-ai/workspaces/ocr-gradio/app.py", line 12, in from marie.renderer import TextRenderer File "/home/rngem/Desktop/rms/marie-ai/marie/renderer/init.py", line 7, in from .text_renderer import TextRenderer File "/home/rngem/Desktop/rms/marie-ai/marie/renderer/text_renderer.py", line 8, in from marie.renderer import ResultRenderer ImportError: cannot import name 'ResultRenderer' from partially initialized module 'marie.renderer' (most likely due to a circular import)

Describe how you solve it this can happen when using code formatter (black) or isort

Rithsek99 commented 9 months ago

skip isort to prevent this issue

gregbugaj commented 9 months ago

This have been already addressed via commit c8040afdbcbe0fd24fabe11d228a8291f2469310

This not only requires skip but also the depends

Example:

from .toast_registry import Toast

from .native_handler import NativeToastHandler  # isort:skip depends on Toast
from .psql_handler import PsqlToastHandler  # isort:skip depends on Toast
from .rabbit_handler import RabbitMQToastHandler  # isort:skip depends on Toast

Make sure that you are on main