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] 2.4.0 introduces hard dependency on aiohttp #592

Closed
anr-tonic opened this issue Nov 15, 2023 · 3 comments · Fixed by #594
Closed

[BUG] 2.4.0 introduces hard dependency on aiohttp #592

anr-tonic opened this issue Nov 15, 2023 · 3 comments · Fixed by #594
Assignees
Labels
bug Something isn't working

Comments

@anr-tonic
Copy link

anr-tonic commented Nov 15, 2023

What is the bug?

Traceback (most recent call last):
  File "/app/logshipper.py", line 14, in <module>
    import opensearchpy
  File "/app/opensearchpy/__init__.py", line 47, in <module>
    from ._async.*** import AsyncOpenSearch
  File "/app/opensearchpy/_async/***/__init__.py", line 44, in <module>
    from ..transport import AsyncTransport, TransportError
  File "/app/opensearchpy/_async/transport.py", line 35, in <module>
    from opensearchpy.connection.base import Connection
  File "/app/opensearchpy/connection/__init__.py", line 30, in <module>
    from .http_async import AsyncHttpConnection
  File "/app/opensearchpy/connection/http_async.py", line 19, in <module>
    from .._async._extra_imports import aiohttp, aiohttp_exceptions  *** type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/opensearchpy/_async/_extra_imports.py", line 43, in <module>
    import aiohttp
ModuleNotFoundError: No module named 'aiohttp'

Looks like originating from this change:
https://github.com/opensearch-project/opensearch-py/pull/563/files#diff-0ce918db323e76243e4d256deb3f7f8f173c3166a1cea914752b1761f1b0442f

How can one reproduce the bug?

Install opensearch-py==2.4.0 w/o aiohttp and attempt to import it

~ (venv:opensearch-test) $ pip install opensearch-py==2.4.0
Collecting opensearch-py==2.4.0
  Downloading opensearch_py-2.4.0-py2.py3-none-any.whl (258 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 258.4/258.4 kB 2.7 MB/s eta 0:00:00
Collecting requests<3.0.0,>=2.4.0
  Downloading requests-2.31.0-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 4.6 MB/s eta 0:00:00
Collecting urllib3>=1.26.18
  Downloading urllib3-2.1.0-py3-none-any.whl (104 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 104.6/104.6 kB 5.8 MB/s eta 0:00:00
Collecting certifi>=2022.12.07
  Downloading certifi-2023.7.22-py3-none-any.whl (158 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 158.3/158.3 kB 7.0 MB/s eta 0:00:00
Collecting six
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting python-dateutil
  Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting charset-normalizer<4,>=2
  Downloading charset_normalizer-3.3.2-cp39-cp39-macosx_11_0_arm64.whl (120 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 120.4/120.4 kB 6.5 MB/s eta 0:00:00
Installing collected packages: urllib3, six, idna, charset-normalizer, certifi, requests, python-dateutil, opensearch-py
Successfully installed certifi-2023.7.22 charset-normalizer-3.3.2 idna-3.4 opensearch-py-2.4.0 python-dateutil-2.8.2 requests-2.31.0 six-1.16.0 urllib3-2.1.0

[notice] A new release of pip available: 22.2.1 -> 23.3.1
[notice] To update, run: pip install --upgrade pip
~  (venv:opensearch-test) $ python -c "import opensearchpy"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/anr/.venvs/opensearch-test/lib/python3.9/site-packages/opensearchpy/__init__.py", line 47, in <module>
    from ._async.client import AsyncOpenSearch
  File "/Users/anr/.venvs/opensearch-test/lib/python3.9/site-packages/opensearchpy/_async/client/__init__.py", line 44, in <module>
    from ..transport import AsyncTransport, TransportError
  File "/Users/anr/.venvs/opensearch-test/lib/python3.9/site-packages/opensearchpy/_async/transport.py", line 35, in <module>
    from opensearchpy.connection.base import Connection
  File "/Users/anr/.venvs/opensearch-test/lib/python3.9/site-packages/opensearchpy/connection/__init__.py", line 30, in <module>
    from .http_async import AsyncHttpConnection
  File "/Users/anr/.venvs/opensearch-test/lib/python3.9/site-packages/opensearchpy/connection/http_async.py", line 19, in <module>
    from .._async._extra_imports import aiohttp, aiohttp_exceptions  # type: ignore
  File "/Users/anr/.venvs/opensearch-test/lib/python3.9/site-packages/opensearchpy/_async/_extra_imports.py", line 43, in <module>
    import aiohttp
ModuleNotFoundError: No module named 'aiohttp'

What is the expected behavior?

Importing opensearch w/o aiohttp installed works

What is your host/environment?

Operating system, version.

Do you have any screenshots?

If applicable, add screenshots to help explain your problem.

Do you have any additional context?

Add any other context about the problem.

@anr-tonic anr-tonic added bug Something isn't working untriaged Need triage labels Nov 15, 2023
@dblock
Copy link
Member

dblock commented Nov 15, 2023

Yep :(

This is my bad. It's not supposed to do that, I'll take care of it first thing tomorrow unless someone beats me to it.

We definitely need an integration test that exercises the client independently - I just ran into this in https://github.com/dblock/opensearch-python-client-demo.

@dblock dblock self-assigned this Nov 15, 2023
@dblock dblock removed the untriaged Need triage label Nov 15, 2023
@dblock dblock mentioned this issue Nov 16, 2023
@dblock
Copy link
Member

dblock commented Nov 16, 2023

Fix in #594.

@dblock
Copy link
Member

dblock commented Nov 16, 2023

Tested 2.4.1 on https://github.com/dblock/opensearch-python-client-demo successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants