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

[Doc] Improve opensearch.client documentation #718

Open
Plutone11011 opened this issue Apr 13, 2024 · 5 comments
Open

[Doc] Improve opensearch.client documentation #718

Plutone11011 opened this issue Apr 13, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@Plutone11011
Copy link

Related to #380

Opensearch client methods create, index, delete could benefit from:

  • updated parameters description in documentation, as well as return value and error handling, if relevant
  • return values and error handling in user guide

I can contribute to this issue

@Plutone11011 Plutone11011 added bug Something isn't working untriaged Need triage labels Apr 13, 2024
@saimedhi saimedhi removed the untriaged Need triage label Apr 14, 2024
@rbpasker
Copy link

rbpasker commented Jun 25, 2024

+1 on the 'error handling'

it seems that HTTP responses (eg GET /<index>/_search AKA response = client.search(index="<index>") on a non-existing index) are thrown as errors rather than returned in the response. This is unexpected since response is the nominal return variable for python requests, where one would check response.status_code == 404.

This behavior should be clearly explained in the user guide

https://opensearch-project.github.io/opensearch-py/api-ref/exceptions.html

@dblock
Copy link
Member

dblock commented Jun 25, 2024

We could use a detailed error handling guide in https://github.com/opensearch-project/opensearch-py/tree/main/guides. Ultimately we want all API docs to be generated from https://github.com/opensearch-project/opensearch-api-specification, and all client-language-specific things to be in the GitHub repo. The API-ref that's auto-published to https://opensearch-project.github.io/opensearch-py/ could have the guides published in a nicer format, too.

Your help is much appreciated!

@rbpasker
Copy link

rbpasker commented Jun 25, 2024

its actually worse because there's no semantic error checking, eg

*** Error: RequestError(400, 'resource_already_exists_exception', 'index [opinions/FduukSQQQcuRcp4ZK0w51g] already exists')
requires:

except TransportError as e:
    if e.status_code == 400 and e.error == 'resource_already_exists_exception':
        # Handle the specific exception
        print("Resource already exists.")
    else:
        # Handle other TransportError exceptions
        print(f"TransportError occurred: {e}")

so i have to write a helper that converts exceptions to semantic errors:

except TransportError as e:
     return transform_exception_to_return_value(e)

https://opensearch-project.github.io/opensearch-py/api-ref/exceptions.html#opensearchpy.TransportError

@dblock
Copy link
Member

dblock commented Jun 25, 2024

You're saying that resource_already_exists_exception should be a specialized ResourceAlreadyExistsError? That would make sense, it's a feature request (please open?).

@rbpasker
Copy link

rbpasker commented Jun 25, 2024

yep, there are probably also other errors that I haven't encountered yet that could probably benefit from specialization

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

No branches or pull requests

4 participants