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

[BUG] Async helpers cannot be imported due to import cycle #310

Closed
aiudirog opened this issue Mar 3, 2023 · 0 comments · Fixed by #311
Closed

[BUG] Async helpers cannot be imported due to import cycle #310

aiudirog opened this issue Mar 3, 2023 · 0 comments · Fixed by #311
Labels
bug Something isn't working untriaged Need triage

Comments

@aiudirog
Copy link
Contributor

aiudirog commented Mar 3, 2023

What is the bug?

Async helpers cannot be imported due to an import cycle

How can one reproduce the bug?

Attempt to import async_scan from opensearchpy.helpers and an ImportError will be raised

What is the expected behavior?

async_scan() should be imported and available to use

What is your host/environment?

  • Windows 10 - Python 3.10.6
  • Arch Linux (6.1.12-zen1-1-zen) - Python 3.10.9

Do you have any screenshots?

python -c "from opensearchpy.helpers import async_scan"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name 'async_scan' from 'opensearchpy.helpers' (/home/roger/.local/lib/python3.10/site-packages/opensearchpy/helpers/__init__.py)

If I remove the try block around async imports in opensearchpy/helpers/__init__.py:

python -c "from opensearchpy.helpers import async_scan"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/roger/.local/lib/python3.10/site-packages/opensearchpy/__init__.py", line 46, in <module>
    from .client import OpenSearch
  File "/home/roger/.local/lib/python3.10/site-packages/opensearchpy/client/__init__.py", line 33, in <module>
    from ..transport import Transport, TransportError
  File "/home/roger/.local/lib/python3.10/site-packages/opensearchpy/transport.py", line 39, in <module>
    from .serializer import DEFAULT_SERIALIZERS, Deserializer, JSONSerializer
  File "/home/roger/.local/lib/python3.10/site-packages/opensearchpy/serializer.py", line 39, in <module>
    from .helpers.utils import AttrList
  File "/home/roger/.local/lib/python3.10/site-packages/opensearchpy/helpers/__init__.py", line 60, in <module>
    from .._async.helpers import (
  File "/home/roger/.local/lib/python3.10/site-packages/opensearchpy/_async/helpers.py", line 44, in <module>
    from .client import AsyncOpenSearch  # noqa
  File "/home/roger/.local/lib/python3.10/site-packages/opensearchpy/_async/client/__init__.py", line 32, in <module>
    from ..transport import AsyncTransport, TransportError
  File "/home/roger/.local/lib/python3.10/site-packages/opensearchpy/_async/transport.py", line 40, in <module>
    from ..serializer import JSONSerializer
ImportError: cannot import name 'JSONSerializer' from partially initialized module 'opensearchpy.serializer' (most likely due to a circular import) (/home/roger/.local/lib/python3.10/site-packages/opensearchpy/serializer.py)

Do you have any additional context?

This issue is new in v2.2.0

@aiudirog aiudirog added bug Something isn't working untriaged Need triage labels Mar 3, 2023
aiudirog added a commit to aiudirog/opensearch-py that referenced this issue Mar 3, 2023
…using an import cycle (fixes opensearch-project#310)

Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
dblock pushed a commit that referenced this issue Mar 8, 2023
* Import async helpers through public interface in tests

Signed-off-by: Roger Aiudi <aiudirog@gmail.com>

* Removed unused import of AsyncOpenSearch in async helpers that was causing an import cycle (fixes #310)

Signed-off-by: Roger Aiudi <aiudirog@gmail.com>

* Update CHANGELOG.md

Signed-off-by: Roger Aiudi <aiudirog@gmail.com>

* Change 2.2.1 in the changelog to Unreleased

Signed-off-by: Roger Aiudi <aiudirog@gmail.com>

* Separated changelog entries for 2.2.0 from 2.1.1

Signed-off-by: Roger Aiudi <aiudirog@gmail.com>

---------

Signed-off-by: Roger Aiudi <aiudirog@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged Need triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant