Skip to content

Commit

Permalink
Clear results (#183)
Browse files Browse the repository at this point in the history
* fixed ops

* op tests

* bump & comment

* clear results when merging

* bump

---------

Co-authored-by: YaphetKG <[email protected]>
  • Loading branch information
cbizon and YaphetKG authored Jun 1, 2023
1 parent 8a0fa8d commit 09d6627
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion openapi-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ servers:
# url: http://127.0.0.1:5000
termsOfService: http://robokop.renci.org:7055/tos?service_long=ARAGORN&provider_long=RENCI
title: ARAGORN
version: 2.4.7
version: 2.4.8
tags:
- name: translator
- name: ARA
Expand Down
10 changes: 5 additions & 5 deletions src/service_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,8 @@ def merge_answer(result_message, answer, results, qnode_ids):
}
mergedresult["analyses"].append(analysis)

result_message["message"]["results"].append(mergedresult)
#result_message["message"]["results"].append(mergedresult)
return mergedresult


# TODO move into operations? Make a translator op out of this
Expand All @@ -805,7 +806,9 @@ def merge_results_by_node(result_message, merge_qnode):
# TODO : I'm sure there's a better way to handle this with asyncio
new_results = []
for r in grouped_results:
merge_answer(result_message, r, grouped_results[r], original_qnodes)
new_result = merge_answer(result_message, r, grouped_results[r], original_qnodes)
new_results.append(new_result)
result_message["message"]["results"] = new_results
return result_message


Expand Down Expand Up @@ -886,9 +889,6 @@ async def answercoalesce(message, params, guid, coalesce_type="all") -> (dict, i
url = f'{os.environ.get("ANSWER_COALESCE_URL", "https://answercoalesce.renci.org/1.3/coalesce/")}{coalesce_type}'
# url = f'{os.environ.get("ANSWER_COALESCE_URL", "https://answer-coalesce.transltr.io/1.3/coalesce/")}{coalesce_type}'

# with open("crap.json", "w") as outf:
# json.dump(message, outf)

# With the current answercoalesce, we make the result list longer, and frequently much longer. If
# we've already got 10s of thousands of results, let's skip this step...
if "max_input_size" in params:
Expand Down
9 changes: 5 additions & 4 deletions tests/test_query_exam.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import pytest
from src.service_aggregator import merge_answer, create_aux_graph, add_knowledge_edge
from src.service_aggregator import create_aux_graph, add_knowledge_edge, merge_results_by_node
from reasoner_pydantic.results import Analysis, EdgeBinding, Result, NodeBinding
from reasoner_pydantic.auxgraphs import AuxiliaryGraph
from reasoner_pydantic.message import Message, Response
from reasoner_pydantic.qgraph import QueryGraph
from reasoner_pydantic.message import Response

def create_result_graph():
"""Create a "treats" result graph with a query graph."""
Expand All @@ -29,7 +28,9 @@ def test_merge_answer():
result1 = create_result({"input":"MONDO:1234", "output":answer, "node2": "curie:3"}, {"g":"KEDGE:1", "f":"KEDGE:2"}).to_dict()
result2 = create_result({"input":"MONDO:1234", "output":answer, "nodeX": "curie:8"}, {"q":"KEDGE:4", "z":"KEDGE:8"}).to_dict()
results = [result1, result2]
merge_answer(result_message,frozenset([answer]),results,qnode_ids)
#In reality the results will be in the message and we want to be sure that they get cleared out.
result_message["message"]["results"] = results
merge_results_by_node(result_message,"output")
assert len(result_message["message"]["results"]) == 1
assert len(result_message["message"]["results"][0]["node_bindings"]) == 2
assert len(result_message["message"]["results"][0]["analyses"]) == 1
Expand Down

0 comments on commit 09d6627

Please sign in to comment.