opensearch-project / opensearch-py

Python Client for OpenSearch
https://opensearch.org/docs/latest/clients/python/
Apache License 2.0
350 stars 175 forks source link

[BUG] import of `AsyncOpenSearch` fails if `aiohttp` is not installed #505

Closed pattrickrice closed 1 year ago

pattrickrice commented 1 year ago

What is the bug?

from opensearchpy import AsyncOpenSearch
ImportError: cannot import name 'AsyncOpenSearch' from 'opensearchpy'

How can one reproduce the bug?

install opensearchpy without aiohttp

What is the expected behavior?

I'd expect an error saying that aiohttp is not installed. something like

ModuleNotFoundError: No module named 'aiohttp'

What is your host/environment?

Ubuntu 20.04

Do you have any screenshots?

n/a

Do you have any additional context?

There was previously a report about this https://github.com/opensearch-project/opensearch-py/issues/332. This bug report is specifically about handling the error more gracefully or at least not swallowing the error silently.

saimedhi commented 1 year ago

@pattrickrice, here's a concise and clear guide for using AsyncOpenSearch. You don't need to install aiohttp separately. It's automatically installed as a dependency. Simply use this one-liner to install opensearch-py[async]: pip install opensearch-py[async]

pattrickrice commented 1 year ago

Thanks for the link! I ran into the issue because the project I am using already had opensearch-py installed and was using the sync client but had not installed via opensearch-py[async]. I agree the documentation is clear and concise and am just raising the issue because the failure's error could be handled better. Feel free to close if we feel the documentation is adequate.