Closed mnorusis closed 1 month ago
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.
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