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

Circular import issue: ImportError: cannot import name 'product' from partially initialized module 'mindee' #279

Open
2 tasks done
JakobGM opened this issue Nov 23, 2024 · 0 comments

Comments

@JakobGM
Copy link

JakobGM commented Nov 23, 2024

Prerequisites

Put an X between the brackets on this line if you have done all of the following:

  • Reproduced the problem or exposed a new need
  • Checked the GitHub existing issues

Description

Version 4.14.1 of mindee introduces a circular import issue.

Steps to Reproduce

mkdir /tmp/test
cd /tmp/test
python -m venv .venv
source .venv/bin/activate
python -m pip install 'mindee==4.14.1'
python -c 'import mindee'

Expected behavior:

A successful import of the mindee package.

Actual behavior:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/test/.venv/lib/python3.12/site-packages/mindee/__init__.py", line 1, in <module>
    from mindee import product
ImportError: cannot import name 'product' from partially initialized module 'mindee' (most likely due to a circular import) (/tmp/test/.venv/lib/python3.12/site-packages/mindee/__init__.py)

Reproduces how often:

100%.

Versions

Python 3.12 on Linux.

mindee==4.14.1

Additional Information

We have introduced a caching layer on-top of Mindee in order to reduce duplicate parsings based on checksuming. Up until this point, this was done by mocking out the requests package in mindee.mindee_http.endpoint like this...

def inject_mindee_caching_layer() -> None:
    from mindee.mindee_http import endpoint

    endpoint.requests = MockedRequests

The new structure of the root __init__.py in the mindee package disallows access to this module. I will look into a work-around for this, but I just wanted to mention it here as well until I wait for the circular import issue to be resolved.

Thanks in advance, and have a nice weekend!

  • Jakob
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