Skip to content

Commit

Permalink
adding optional RESULTS_LIMIT and SUBCLASS_DEPTH env vars / config va…
Browse files Browse the repository at this point in the history
…riables which are applied to all cypher queries
  • Loading branch information
EvanDietzMorris committed Apr 3, 2024
1 parent 62ec55d commit 5382c77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PLATER/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pyaml==20.4.0
pytest==7.4.3
pytest-asyncio==0.21.1
uvicorn==0.24.0
reasoner-transpiler==2.0.8
reasoner-transpiler==2.0.9
reasoner-pydantic==4.1.6
httpx==0.25.1
pytest-httpx==0.26.0
Expand Down
9 changes: 7 additions & 2 deletions PLATER/services/util/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ class Question:
def __init__(self, question_json):
self._question_json = copy.deepcopy(question_json)

# self.toolkit = toolkit
self.provenance = config.get('PROVENANCE_TAG', 'infores:automat.notspecified')
self.results_limit = config.get('RESULTS_LIMIT', None)
self.subclass_depth = config.get('SUBCLASS_DEPTH', None)

def compile_cypher(self, **kwargs):
query_graph = copy.deepcopy(self._question_json[Question.QUERY_GRAPH_KEY])
Expand Down Expand Up @@ -189,7 +190,11 @@ async def answer(self, graph_interface: GraphInterface):
otel_span = None

# compile a cypher query and return a string
cypher_query = self.compile_cypher(**{"use_hints": True, "relationship_id": "internal", "primary_ks_required": True})
cypher_query = self.compile_cypher(**{"use_hints": True,
"relationship_id": "internal",
"limit": self.results_limit,
"subclass_depth": self.subclass_depth})
print(cypher_query)
# convert the incoming TRAPI query into a string for logging and tracing
trapi_query = str(orjson.dumps(self._question_json), "utf-8")
# create a probably-unique id to be associated with this query in the logs
Expand Down

0 comments on commit 5382c77

Please sign in to comment.