Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
saramsey committed Sep 13, 2023
1 parent 974c989 commit d5c210e
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions code/ARAX/ARAXQuery/Expand/kg2_querier.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from typing import Dict, Tuple, Union, Set
import requests
import traceback
import urllib3
import json

sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import expand_utilities as eu
Expand Down Expand Up @@ -184,21 +186,26 @@ def _answer_query_using_plover(qg: QueryGraph, log: ARAXResponse) -> Tuple[Dict[
# Then send the actual query
log.debug(f"Sending query to {rtxc.plover_url}")
try:
response = requests.post(f"{rtxc.plover_url}/query",
json=dict_qg,
timeout=60,
headers={'accept': 'application/json'})
response = urllib3.PoolManager(timeout=60).request("POST",
f"{rtxc.plover_url}/query",
body=json.dumps(dict_qg),
headers={'accept': 'application/json',
'content-type': 'application/json'})
# response = requests.post(f"{rtxc.plover_url}/query",
# json=dict_qg,
# timeout=60,
# headers={'accept': 'application/json'})
except Exception as e:
log.error(f"Error querying PloverDB: {e} "
f"TRACE {traceback.format_exc()}")
raise e
if response.status_code == 200:
log.debug(f"Plover returned status code {response.status_code}")
return response.json(), response.status_code
if response.status == 200:
log.debug(f"Plover returned status code {response.status}")
return json.loads(response.data), response.status
else:
log.warning(f"Plover returned status code {response.status_code}."
f" Response was: {response.text}")
return dict(), response.status_code
log.warning(f"Plover returned status code {response.status}."
f" Response was: {response.data}")
return dict(), response.status

def _load_plover_answer_into_object_model(self, plover_answer: Dict[str, Dict[str, Union[set, dict]]],
log: ARAXResponse) -> QGOrganizedKnowledgeGraph:
Expand Down

0 comments on commit d5c210e

Please sign in to comment.