RTXteam / RTX

Software repo for Team Expander Agent (Oregon State U., Institute for Systems Biology, and Penn State U.)
https://arax.ncats.io/
MIT License
33 stars 21 forks source link

ARAX returns different results for `/query` vs. `/asyncquery` #1759

Closed saramsey closed 2 years ago

saramsey commented 2 years ago

Credit to @edeutsch and @amykglen for this bug report, which came out of discussions from today's Expander Agent Mini-Hackathon meeting (and motivated by a lot of painstaking work documented in #1718). Summarizing our reprex here. When I run this query:

{
  "message": {
    "query_graph": {
      "edges": {
        "e01": {
          "object": "n1",
          "predicates": [
            "biolink:treats",
            "biolink:has_real_world_evidence_of_association_with"
          ],
          "subject": "n2"
        }
     },
     "nodes": {
        "n1": {
          "categories": [
            "biolink:DiseaseOrPhenotypicFeature"
          ],
          "ids": [
            "MONDO:0020800",
            "UMLS:C4076113",
            "UMLS:C0586256",
            "MONDO:0006692",
            "MONDO:0005301",
            "UMLS:C4511867",
            "UMLS:C2921627",
            "UMLS:C4511844",
            "MONDO:0009835",
            "UMLS:C1720104",
            "UMLS:C4075966",
            "MONDO:0020800",
            "UMLS:C4510698",
            "UMLS:C4511050",
            "MONDO:0010085",
            "UMLS:C4546140",
            "MONDO:0011380",
            "UMLS:C4511864",
            "UMLS:C4511865",
            "UMLS:C4324721",
            "MONDO:0016430",
            "UMLS:C0393820"
          ]
        },
        "n2": {
          "categories": [
            "biolink:SmallMolecule"
          ]
        }
     }
    }
  }
}

via /query using

#!/usr/bin/env bash
curl -X POST "http://localhost:5010/api/arax/v1.2/query" \
     -H "accept: application/json" \
     -H "Content-Type: application/json" \
     -d @mode-test.json

I get different logging output from ARAX-Expand than when I run using /asyncquery, as shown here:

rt@5d5ebba937d1:/mnt/data/orangeboard/fork-test$ grep Resultify mode-test-results-syncquery.json
      "message": "Pruning any paths that are now dead ends (with help of Resultify)",
      "message": "Calling Resultify from Expand for pruning",
      "message": "Resultify created 1209 results",
rt@5d5ebba937d1:/mnt/data/orangeboard/fork-test$ grep Resultify mode-test-results-asyncquery.json
      "message": "Resultify created 1209 results",

So it appears that when I run using /asyncquery, no pruning happens, which is probably why we are seeing no results in some cases like #1718 when ARAX is passed a multihop query via /asyncquery.

saramsey commented 2 years ago

Copying the two logfiles and the scripts that produced them, here: issue-1759.zip

saramsey commented 2 years ago

So, @amykglen suggests (and @edeutsch concurs) that the probable fix for this issue is to change (in ARAX-expand), the code

mode == "ARAX"

to

mode != "RTXKG2"

so that it picks up (as True) the case where mode is set to asynchronous, as in the asyncquery controller here: https://github.com/RTXteam/RTX/blob/07285bf96f8185a5b3f538969708a345a164e65b/code/UI/OpenAPI/python-flask-server/openapi_server/controllers/asyncquery_controller.py#L27

saramsey commented 2 years ago

Note that in the above testing, I have hardcoded ARAX-expand to only use BTE.

saramsey commented 2 years ago

After the fix:

rt@5d5ebba937d1:/mnt/data/orangeboard/fork-test$ grep Resultify mode-test-results-syncquery-after-fix.json
      "message": "Pruning any paths that are now dead ends (with help of Resultify)",
      "message": "Calling Resultify from Expand for pruning",
      "message": "Resultify created 1209 results",

and

sramsey-laptop:issue-1759 sramsey$ grep Resultify mode-test-results-asyncquery-after-fix.json
      "message": "Pruning any paths that are now dead ends (with help of Resultify)",
      "message": "Calling Resultify from Expand for pruning",
      "message": "Resultify created 1209 results",
saramsey commented 2 years ago

Creating a branch issue-1759 off of production for this work.

saramsey commented 2 years ago

credit for suggesting the fix 691c66f goes to @amykglen

edeutsch commented 2 years ago

The fix has been tested and deployed. There is dancing in the streets. closing.