Skip to content

Commit

Permalink
Fixed imports for unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
3coins committed Feb 6, 2024
1 parent c81df71 commit 4c9e985
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions libs/community/langchain_community/graphs/neptune_rdf_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
from types import SimpleNamespace
from typing import Any, Dict, Optional, Sequence

import boto3
import requests
from botocore.auth import SigV4Auth
from botocore.awsrequest import AWSRequest

CLASS_QUERY = """
SELECT DISTINCT ?elem ?com
Expand Down Expand Up @@ -117,7 +114,18 @@ def __init__(
self.hide_comments = hide_comments
self.query_endpoint = f"https://{host}:{port}/sparql"

self.session = boto3.Session() if self.use_iam_auth else None
if self.use_iam_auth:
try:
import boto3

self.session = boto3.Session()
except ImportError:
raise ImportError(
"Could not import boto3 python package. "
"Please install it with `pip install boto3`."
)
else:
self.session = None

# Set schema
self.schema = ""
Expand Down Expand Up @@ -160,9 +168,13 @@ def query(
token=session_token,
region=self.region_name,
)
from botocore.awsrequest import AWSRequest

request = AWSRequest(
method="POST", url=self.query_endpoint, data=data, params=params
)
from botocore.auth import SigV4Auth

SigV4Auth(creds, service, self.region_name).add_auth(request)
request.headers["Content-Type"] = "application/x-www-form-urlencoded"
request_hdr = request.headers
Expand Down

0 comments on commit 4c9e985

Please sign in to comment.