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]: NeptuneDatabasePropertyGraphStore does not use provided client #16173

Closed
mnorusis opened this issue Sep 24, 2024 · 1 comment · Fixed by #16174
Closed

[Bug]: NeptuneDatabasePropertyGraphStore does not use provided client #16173

mnorusis opened this issue Sep 24, 2024 · 1 comment · Fixed by #16174
Labels
bug Something isn't working triage Issue needs to be triaged/prioritized

Comments

@mnorusis
Copy link
Contributor

Bug Description

When passing an existing client into NeptuneDatabasePropertyGraph, the provided client is not used. Instead it is set to None

Version

0.11.7

Steps to Reproduce

graph_store = NeptuneDatabasePropertyGraphStore(
host = "NeptuneHost", port="8182", "client=neptune_client
)

found in llama-index-graph-stores-neptune v0.2.0

Relevant Logs/Tracbacks

No response

@mnorusis mnorusis added bug Something isn't working triage Issue needs to be triaged/prioritized labels Sep 24, 2024
Copy link

dosubot bot commented Sep 24, 2024

Hello @mnorusis! I'm here to help you with any bugs, questions, or contributions you have. Let's work through this together!

The issue arises because of a bug in the create_neptune_database_client function. Specifically, the line client = client should be client = provided_client to correctly use the provided client. As it stands, the provided client is not being assigned to the client variable, which means the function will proceed to create a new client if provided_client is not None.

Here is the relevant part of the code that needs to be corrected:

def create_neptune_database_client(
    host: str,
    port: int,
    provided_client: Any,
    credentials_profile_name: str,
    region_name: str,
    sign: bool,
    use_https: bool,
):
    """Create a Neptune Database Client.

    Args:
            host (str): The host endpoint
            port (int, optional): The port. Defaults to 8182.
            client (Any, optional): If provided, this is the client that will be used. Defaults to None.
            credentials_profile_name (Optional[str], optional): If provided this is the credentials profile that will be used. Defaults to None.
            region_name (Optional[str], optional): The region to use. Defaults to None.
            sign (bool, optional): True will SigV4 sign all requests, False will not. Defaults to True.
            use_https (bool, optional): True to use https, False to use http. Defaults to True.

    Returns:
        Any: The neptune client
    """
    try:
        client = None
        if provided_client is not None:
            client = provided_client  # This line should be client = provided_client
        else:
            if credentials_profile_name is not None:
                session = boto3.Session(profile_name=credentials_profile_name)
            else:
                # use default credentials
                session = boto3.Session()

            client_params = {}
            if region_name:
                client_params["region_name"] = region_name

            protocol = "https" if use_https else "http"

            client_params["endpoint_url"] = f"{protocol}://{host}:{port}"

            if sign:
                client = session.client("neptunedata", **client_params)
            else:
                client = session.client(
                    "neptunedata",
                    **client_params,
                    config=Config(signature_version=UNSIGNED),
                )
        return client
    except ImportError:
        raise ModuleNotFoundError(
            "Could not import boto3 python package. "
            "Please install it with `pip install boto3`."
        )
    except Exception as e:
        if type(e).__name__ == "UnknownServiceError":
            raise ModuleNotFoundError(
                "Neptune Database requires a boto3 version 1.34.40 or greater."
                "Please install it with `pip install -U boto3`."
            ) from e
        else:
            raise ValueError(
                "Could not load credentials to authenticate with AWS client. "
                "Please check that credentials in the specified "
                "profile name are valid."
            ) from e

This change will ensure that the provided client is used correctly during initialization [1].

To continue talking to Dosu, mention @dosu.

@mnorusis mnorusis changed the title [Bug]: NeptuneDatabasePropertyGraphStore does not use prodided client [Bug]: NeptuneDatabasePropertyGraphStore does not use provided client Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Issue needs to be triaged/prioritized
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant