From 5382c77e0f7a18c246ec1b71f83cf21b36ed33b8 Mon Sep 17 00:00:00 2001 From: Evan Morris Date: Wed, 3 Apr 2024 16:29:27 -0400 Subject: [PATCH] adding optional RESULTS_LIMIT and SUBCLASS_DEPTH env vars / config variables which are applied to all cypher queries --- PLATER/requirements.txt | 2 +- PLATER/services/util/question.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/PLATER/requirements.txt b/PLATER/requirements.txt index 9715ea6..2b71f8f 100644 --- a/PLATER/requirements.txt +++ b/PLATER/requirements.txt @@ -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 diff --git a/PLATER/services/util/question.py b/PLATER/services/util/question.py index 7d7d11c..6ccdf5b 100644 --- a/PLATER/services/util/question.py +++ b/PLATER/services/util/question.py @@ -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]) @@ -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